Skip to content

gpu-dawn: standalone usage: headers are hard to find, need simple C webgpu.h example #605

@ghost

Description

Hi slimsag,

You mention:

If you intend to actually call the WebGPU API, you should build these two source files as part of your application:

dawn_proc.c
webgpu_dawn_native_proc.cpp

But dawn_proc.c references 'dawn/dawn_proc.h' which is nowhere to be found.

If you include a single working hello world triangle C language example that compiles manually with, e.g., 'zig cc' or MSYS2 gcc/clang that would be extremely helpful to those of us who are not build engineers.

I tried building dawn from source following exactly your instructions with newest zig nightly to see if this process would generate the missing glue. I need to build for Windows from Linux so I ran:

/mnt/c/src/mach-gpu-dawn$ zig build -Dtarget=x86_64-windows-gnu

This eventually failed trying to compile DX dependencies, first few build errors were:

/mnt/c/src/mach-gpu-dawn/libs/DirectXShaderCompiler/lib/Support/TimeValue.cpp:1:1: error: unable to build C object: clang exited with code 1
/mnt/c/src/mach-gpu-dawn/libs/DirectXShaderCompiler/lib/Support/ThreadLocal.cpp:1:1: error: unable to build C object: clang exited with code 1
/mnt/c/src/mach-gpu-dawn/libs/DirectXShaderCompiler/lib/Support/Threading.cpp:1:1: error: unable to build C object: clang exited with code 1
[...]

I've spent several hours at this.

Alas, I'm forced to give up on Zig for now due to my lack of sufficient problem solving skills. On Windows MSYS2 I've built SDL2 with DX9, DX11, and DX12 SDL renderer backends and it all 'just works'.

I built Google Angle before going through the whole depot_tools rigamarole and it did, in the end, 'just work'.

From this day forward, if some Zig evangelist on HN says Zig builds 'just work', I'm sharing my counter-experience that for me it did not 'just work' even after hours upon hours of frustration.

But if I can compile a single C language webgpu.h hello triangle example for Windows then I will share that at least I got that much working. There is a repo that has a bunch of C webgpu.h Dawn examples but they only build on Linux for Linux, no Windows build:

https://github.com/samdauwe/webgpu-native-examples

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions