Skip to content

examples: Outcomes of running the examples on Windows #1429

@msg-programs

Description

@msg-programs

A #1315-styled overview of the results of trying to compile and run all examples with all sysgpu backends on Win10 64 bit.

Mach: current mach master (8ef4227...)
Zig: 0.14.0-dev.2577+271452d22
iGPU: Intel UHD Graphics 620 (i7-8550U)
dGPU: NVIDIA GeForce GTX 1050

D3D12 versions were tested with both the iGPU and dGPU. Vulkan seems to ignore the Windows GPU setting, so the tests were only done for the dGPU.

Example D3D12 OpenGL Vulkan WebGPU Metal
core-custom-entrypoint #1427 #1427 #1427 #1427 #1427
core-triangle OK 🔥 [args, context] ↔️ 🛠️
core-transparent-window see heading 🔥 [args, context] ↔️ 🛠️
custom-renderer OK 🔥 [args, context, ints] 💾 [1] 🛠️
glyphs see heading 🔥 [args, context, ints] 💾 [2] 🛠️
hardware-check ⚠️, #1336 🔥 [args x2, context, ints] 💾 [2] 🛠️
piano OK 🔥 [context, ints] ↔️ 🛠️
play-opus OK 🔥 [context, ints] ↔️ 🛠️
sprite ⚠️, #1336 🔥 [args, context, ints] 💾 [2] 🛠️
text ⚠️ 🔥 [args, context, ints] 💾 [2] 🛠️

Explainations

❓(Metal only): Fails to compile with the following error

src\sysgpu\metal.zig:2:20: error: no module named 'objc' available within module mach
const ca = @import("objc").quartz_core;
                   ^~~~~~
referenced by:
    sysgpu.metal.Surface: src\sysgpu\metal.zig:134:13
    Surface: src\sysgpu\metal.zig:132:21
    16 reference(s) hidden; use '-freference-trace=18' to see all references
src\sysgpu\metal.zig:4:21: error: no module named 'objc' available within module mach
const mtl = @import("objc").metal;
                    ^~~~~~

As Metal is iOS-only and the error is ObjectiveC-related, this might be the expected outcome.


🔥 Fails to compile due to the listed OpenGL-related errors, see below for further info.

args

Shown here for the custom-renderer example.

src\sysgpu\main.zig:557:41: error: member function expected 1 argument(s), found 2
            const shader_module = device.createShaderModuleSpirv(spirv_descriptor.code, spirv_descriptor.code_size) catch @panic("api error");
                                  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
src\sysgpu\opengl.zig:452:9: note: function declared here
    pub fn createShaderModuleSpirv(device: *Device, code: []const u8) !*ShaderModule {
    ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src\sysgpu\sysgpu\device.zig:194:45: note: called from here
        return Impl.deviceCreateShaderModule(device, descriptor);
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
src\sysgpu\sysgpu\device.zig:203:41: note: called from here
        return device.createShaderModule(&ShaderModule.Descriptor{
               ~~~~~~~~~~~~~~~~~~~~~~~~~^
examples\custom-renderer\Renderer.zig:39:56: note: called from here
    const shader_module = device.createShaderModuleWGSL("shader.wgsl", @embedFile("shader.wgsl"));
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

context

src\sysgpu\opengl.zig:177:24: error: root source file struct 'sysgpu.opengl.c' has no member named 'WGLCreateContext'
        const hglrc = c.WGLCreateContext(hdc);
                      ~^~~~~~~~~~~~~~~~~
src\sysgpu\opengl\c.zig:1:1: note: struct declared here
pub usingnamespace @cImport({
^~~
referenced by:
    initWindow: src\sysgpu\main.zig:45:44
    initWindow: src\core\Windows.zig:264:28
    12 reference(s) hidden; use '-freference-trace=14' to see all references

ints

src\sysgpu\opengl.zig:1845:52: error: expected type 'c_int', found 'usize'
                        gl.drawBuffers(draw_buffers.len, &draw_buffers.buffer);
                                       ~~~~~~~~~~~~^~~~
src\sysgpu\opengl.zig:1845:52: note: signed 32-bit int cannot represent all possible unsigned 64-bit values

🛠️ (WebGPU only): Reports itself as being unsupported:

src\sysgpu\main.zig:27:13: error: unsupported backend
    else => @compileError("unsupported backend"),
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
    init: src\sysgpu\main.zig:34:52
    init: src\Core.zig:126:25
    7 reference(s) hidden; use '-freference-trace=9' to see all references

Nothing to do here really, this error is quite clear.


glyphs

Renders one frame every ~7 seconds on the iGPU. When a frame finally renders, a message like this being written out.

B:\c-workspace\mach\zig-out\bin\d3d12\Shader@0x000002CAD1123708(14,22): warning X3578: Output value 'vertMain' is not completely initialized

App is otherwise unresponsive and has to be killed externally (^C, task manager).

(Address after the Shader@ differs between executions and programs, position after address differs between programs).

On the dGPU, the program crashes after failing to allocate a texture:

thread 2804 panic: api error
B:\c-workspace\mach\src\sysgpu\d3d12.zig:1101:27: 0x7ff7a07e45e5 in createResource (glyphs.exe.obj)
        if (hr != c.S_OK) return gpu_allocator.Error.Other;
                          ^
B:\c-workspace\mach\src\sysgpu\d3d12.zig:1748:13: 0x7ff7a07e3e4f in init (glyphs.exe.obj)
            return error.CreateTextureFailed;
            ^
B:\c-workspace\mach\src\sysgpu\d3d12.zig:567:9: 0x7ff7a07e48fc in createTexture (glyphs.exe.obj)
        return Texture.init(device, desc);
        ^
B:\c-workspace\mach\examples\glyphs\App.zig:104:46: 0x7ff7a07eb960 in setupPipeline (glyphs.exe.obj)
    app.texture = window.device.createTexture(&.{
                                             ^
B:\c-workspace\mach\examples\glyphs\App.zig:225:51: 0x7ff7a07f2336 in tick (glyphs.exe.obj)
            .window_open => |ev| try setupPipeline(core, app, sprite, ev.window_id),
                                                  ^
B:\c-workspace\mach\src\module.zig:762:29: 0x7ff7a07bdea6 in run__anon_36057 (glyphs.exe.obj)
                    switch (@typeInfo(Ret)) {
                            ^
B:\c-workspace\mach\src\module.zig:785:57: 0x7ff7a079e661 in callDynamic (glyphs.exe.obj)
                        inline else => |fn_name| mod.run(fn_name),
                                                        ^
B:\c-workspace\mach\src\module.zig:748:61: 0x7ff7a077182b in run (glyphs.exe.obj)
                                        modules2.callDynamic(fn_id);
                                                            ^
B:\c-workspace\mach\src\module.zig:502:19: 0x7ff7a077f56f in run (glyphs.exe.obj)
            r._run(r._ctx, fn_id);
                  ^
B:\c-workspace\mach\src\Core.zig:259:17: 0x7ff7a077f4d8 in main (glyphs.exe.obj)
    core_mod.run(core.on_tick.?);
                ^
// snip, rest is stacktrace through the module system and main.

⚠️: Prints the a warning like this on startup

B:\c-workspace\mach\zig-out\bin\d3d12\Shader@0x000002059DC09CF8(23,22): warning X3578: Output value 'vertMain' is not completely initialized

(Address after the Shader@ differs between executions and programs, position after address differs between programs).


core-transparent-window

This example behaves very oddly:

  • The window is not transparent but has a black background
  • Pressing left moves the window's right edge to the left and the bottom edge upwards as if up had been pressed.
  • Pressing right moves the window's right edge to the right and the bottom edge upwards as if up had been pressed
  • Pressing up moves the window's left edge left by a couple of pixels and the window's bottom edge upwards.
  • Pressing down moves the window's left edge left by a couple of pixels and the bottom edge upwards as if up had been pressed twice or thrice.
  • Pressing down or left while the window is very small can crash the program:
thread 6840 panic: integer overflow
B:\c-workspace\mach\examples\core-transparent-window\App.zig:104:99: 0x7ff788058207 in tick (core-transparent-window.exe.obj)
                        core.windows.set(app.window, .width, core.windows.get(app.window, .width) - 10);
                                                                                                  ^
B:\c-workspace\mach\src\module.zig:762:29: 0x7ff78803d06b in run__anon_33633 (core-transparent-window.exe.obj)
                    switch (@typeInfo(Ret)) {
                            ^
B:\c-workspace\mach\src\module.zig:785:57: 0x7ff78801dce1 in callDynamic (core-transparent-window.exe.obj)
                        inline else => |fn_name| mod.run(fn_name),
                                                        ^
B:\c-workspace\mach\src\module.zig:748:61: 0x7ff787ff0eeb in run (core-transparent-window.exe.obj)
                                        modules2.callDynamic(fn_id);
                                                            ^
B:\c-workspace\mach\src\module.zig:502:19: 0x7ff787ffec2f in run (core-transparent-window.exe.obj)
            r._run(r._ctx, fn_id);
                  ^
B:\c-workspace\mach\src\Core.zig:277:17: 0x7ff788028566 in platform_update_callback (core-transparent-window.exe.obj)
    core_mod.run(core.on_tick.?);
                ^
// snip, rest is stacktrace through the module system and main.

↔️: Crash on window resize

Trace is from core-triangle

Segmentation fault at address 0x200
???:?:?: 0x7ffd2fd7874e in ??? (nvoglv64.dll)
???:?:?: 0x7ffd2fd78c20 in ??? (nvoglv64.dll)
???:?:?: 0x7ffd2fcf94db in ??? (nvoglv64.dll)
C:\Users\missing\AppData\Local\zig\p\12208333c8b3551908b66b8a421e7127bdf0c1806063836576283860eff99c99c521\vk.zig:32118:47: 0x7ff64842270b in cmdPipelineBarrier (core-triangle.exe.obj)
            self.dispatch.vkCmdPipelineBarrier(
                                              ^
B:\c-workspace\mach\src\sysgpu\vulkan.zig:2924:31: 0x7ff648350e7c in flush (core-triangle.exe.obj)
        vkd.cmdPipelineBarrier(
                              ^
B:\c-workspace\mach\src\sysgpu\vulkan.zig:2657:36: 0x7ff648351998 in finish (core-triangle.exe.obj)
        encoder.state_tracker.flush(vk_command_buffer);
                                   ^
B:\c-workspace\mach\src\sysgpu\vulkan.zig:3441:62: 0x7ff648351e76 in submit (core-triangle.exe.obj)
            const command_buffer = try command_encoder.finish(&.{});
                                                             ^
B:\c-workspace\mach\examples\core-triangle\App.zig:135:24: 0x7ff6482ead2d in tick (core-triangle.exe.obj)
    window.queue.submit(&[_]*gpu.CommandBuffer{command});
                       ^
B:\c-workspace\mach\src\module.zig:762:29: 0x7ff6482cb8db in run__anon_53634 (core-triangle.exe.obj)
                    switch (@typeInfo(Ret)) {
                            ^
B:\c-workspace\mach\src\module.zig:785:57: 0x7ff6482aa971 in callDynamic (core-triangle.exe.obj)
                        inline else => |fn_name| mod.run(fn_name),
                                                        ^
B:\c-workspace\mach\src\module.zig:748:61: 0x7ff64827183b in run (core-triangle.exe.obj)
                                        modules2.callDynamic(fn_id);
                                                            ^
B:\c-workspace\mach\src\module.zig:502:19: 0x7ff64828b5cf in run (core-triangle.exe.obj)
            r._run(r._ctx, fn_id);
                  ^
B:\c-workspace\mach\src\Core.zig:277:17: 0x7ff6482b69e6 in platform_update_callback (core-triangle.exe.obj)
    core_mod.run(core.on_tick.?);
                ^
// snip, rest is stacktrace through the module system and main.

💾: Crashes with OOM error

Variant 1

thread 9728 panic: api error
C:\Users\missing\AppData\Local\zig\p\12208333c8b3551908b66b8a421e7127bdf0c1806063836576283860eff99c99c521\vk.zig:29925:54: 0x7ff65ffe610b in allocateMemory (custom-renderer.exe.obj)
                Result.error_out_of_device_memory => return error.OutOfDeviceMemory,
                                                     ^
B:\c-workspace\mach\src\sysgpu\vulkan.zig:1191:24: 0x7ff65ffe4aa6 in init (custom-renderer.exe.obj)
        const memory = try vkd.allocateMemory(vk_device, &.{
                       ^
B:\c-workspace\mach\src\sysgpu\vulkan.zig:629:9: 0x7ff65ffe723c in createBuffer (custom-renderer.exe.obj)
        return Buffer.init(device, desc);
        ^
B:\c-workspace\mach\examples\custom-renderer\Renderer.zig:59:63: 0x7ff65fff5a08 in init (custom-renderer.exe.obj)
        .size = @sizeOf(UniformBufferObject) * uniform_offset * num_bind_groups,
                                                              ^
B:\c-workspace\mach\src\module.zig:762:29: 0x7ff65ff8dd56 in run__anon_54737 (custom-renderer.exe.obj)
                    switch (@typeInfo(Ret)) {
                            ^
B:\c-workspace\mach\src\module.zig:785:57: 0x7ff65ff6b7d8 in callDynamic (custom-renderer.exe.obj)
                        inline else => |fn_name| mod.run(fn_name),
                                                        ^
B:\c-workspace\mach\src\module.zig:748:61: 0x7ff65ff325ab in run (custom-renderer.exe.obj)
                                        modules2.callDynamic(fn_id);
                                                            ^
B:\c-workspace\mach\src\module.zig:502:19: 0x7ff66002188f in run (custom-renderer.exe.obj)
            r._run(r._ctx, fn_id);
                  ^
B:\c-workspace\mach\src\module.zig:507:18: 0x7ff65ffaef62 in call__anon_59253 (custom-renderer.exe.obj)
            r.run(fn_id);
                 ^
B:\c-workspace\mach\examples\custom-renderer\App.zig:98:34: 0x7ff65ffad2a4 in tick (custom-renderer.exe.obj)
                renderer_mod.call(.init);
                                 ^
// snip, rest is stacktrace through the module system and main.

Variant 2

Here shown for the glyphs example.

thread 9232 panic: api error
C:\Users\missing\AppData\Local\zig\p\12208333c8b3551908b66b8a421e7127bdf0c1806063836576283860eff99c99c521\vk.zig:29925:54: 0x7ff6875177bb in allocateMemory (glyphs.exe.obj)
                Result.error_out_of_device_memory => return error.OutOfDeviceMemory,
                                                     ^
B:\c-workspace\mach\src\sysgpu\vulkan.zig:1191:24: 0x7ff6875195e6 in init (glyphs.exe.obj)
        const memory = try vkd.allocateMemory(vk_device, &.{
                       ^
B:\c-workspace\mach\src\sysgpu\vulkan.zig:943:28: 0x7ff68751b445 in acquire (glyphs.exe.obj)
            const buffer = try Buffer.init(device, &.{
                           ^
B:\c-workspace\mach\src\sysgpu\vulkan.zig:2345:28: 0x7ff68751b7da in upload (glyphs.exe.obj)
            const buffer = try streaming_manager.acquire();
                           ^
B:\c-workspace\mach\src\sysgpu\vulkan.zig:2664:24: 0x7ff68759a2c0 in writeBuffer (glyphs.exe.obj)
        const stream = try encoder.command_buffer.upload(size);
                       ^
B:\c-workspace\mach\src\gfx\Sprite.zig:473:41: 0x7ff687515430 in renderPipeline (glyphs.exe.obj)
    encoder.writeBuffer(pipeline.built.?.uniforms, 0, &[_]Uniforms{uniforms});
                                        ^
B:\c-workspace\mach\src\gfx\Sprite.zig:205:23: 0x7ff68750b691 in tick (glyphs.exe.obj)
        renderPipeline(sprite, core, pipeline_id);
                      ^
B:\c-workspace\mach\src\module.zig:762:29: 0x7ff6874ec356 in run__anon_56124 (glyphs.exe.obj)
                    switch (@typeInfo(Ret)) {
                            ^
B:\c-workspace\mach\src\module.zig:785:57: 0x7ff6874cb101 in callDynamic (glyphs.exe.obj)
                        inline else => |fn_name| mod.run(fn_name),
                                                        ^
B:\c-workspace\mach\src\module.zig:748:61: 0x7ff68749216b in run (glyphs.exe.obj)
                                        modules2.callDynamic(fn_id);
                                                            ^
B:\c-workspace\mach\src\module.zig:502:19: 0x7ff6875a64bf in run (glyphs.exe.obj)
            r._run(r._ctx, fn_id);
                  ^
B:\c-workspace\mach\src\module.zig:507:18: 0x7ff687533802 in call__anon_62519 (glyphs.exe.obj)
            r.run(fn_id);
                 ^
B:\c-workspace\mach\examples\glyphs\App.zig:318:20: 0x7ff687532817 in tick (glyphs.exe.obj)
    sprite_mod.call(.tick);
                   ^
// snip, rest is stacktrace through the module system and main.

I might have snipped too much of some of the stacktraces in order to not make the issue longer than it already is. Let me know and I'll provide the full trace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageIssues that need triaging

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions