samdauwe / webgpu-native-examples

Collection of C-language examples that demonstrate basic rendering and computation in WebGPU native.
Apache License 2.0
373 stars 21 forks source link

Multiple errors when running with latest Dawn #13

Closed gabrieldechichi closed 3 months ago

gabrieldechichi commented 3 months ago

When following the instructions on the README I currently get this after I try running make all, as well as bash ./build.sh -webgpu_native_examples if using Docker.

wgpu_native.cpp:61:36: error: ‘class dawn::native::Instance’ has no member named ‘EnableBackendValidation’
   61 |   gpuContext.dawn_native.instance->EnableBackendValidation(true);
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/wgpu_native.dir/build.make:76: CMakeFiles/wgpu_native.dir/lib/wgpu_native/wgpu_native.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1639: CMakeFiles/wgpu_native.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

The compile error can be fixed by using switching the line to:

gpuContext.dawn_native.instance->SetBackendValidationLevel(dawn::native::BackendValidationLevel::Full);

However, this then trigger runtime errors related to the use of SwapChain.

➜  webgpu-native-examples git:(master) ✗ ./build/Releasex64/wgpu_sample_launcher -s triangle
Running example: triangle
Available adapters:
  AMD Radeon Graphics (RADV RENOIR) (radv: Mesa 24.1.1 - kisak-mesa PPA)
    deviceID=5688, vendorID=0x1002, BackendType::Vulkan, AdapterType::Integrated GPU
  NVIDIA GeForce RTX 3060 Laptop GPU (NVIDIA: 535.171.04 535.171.4.0)
    deviceID=9504, vendorID=0x10de, BackendType::Vulkan, AdapterType::Discrete GPU
  llvmpipe (LLVM 17.0.6, 256 bits) (llvmpipe: Mesa 24.1.1 - kisak-mesa PPA (LLVM 17.0.6) 0.0.1)
    deviceID=0, vendorID=0x10005, BackendType::Vulkan, AdapterType::CPU
  Null backend ()
    deviceID=0, vendorID=0x0, BackendType::Null, AdapterType::CPU
Warning: The explicit creation of a SwapChain object is deprecated and should be replaced by Surface configuration.
[1]    3375778 segmentation fault (core dumped)  ./build/Releasex64/wgpu_sample_launcher -s triangle

It looks like the webgpu_native headers are probably out of sync with the latest dawn? My suggestion would be to lock dawn to a specific tag on the download script.

samdauwe commented 3 months ago

Hi Gabriel,

Thanks for trying out this project and reporting these issues!

I am currently using an older Google Dawn version and I am not sure yet what is happening with the use of the SwapChain with the latest Dawn version, but I am also getting segmentation faults on my side. I followed your suggestion and locked the Dawn version to an older version that results in functional examples again. Over time I will upgrade the Dawn version when I figured out what is triggering the runtime errors related to the use of SwapChain.

Could you pull the most recent changes and then run the download script again (locked to Google Dawn version 'chromium/6370'):

cd external/dawn/ rm -rf dawn depot_tools bash download_dawn.sh

After a rebuild of the project the examples should work.

If you encounter any issues feel free to let me know.

With best regards, Sam

gabrieldechichi commented 3 months ago

Hi @samdauwe thanks for the timely fix. Just pulled latest and can confirm the examples work! Excited to dive in!

Thanks again,

Gabriel