cwoffenden / hello-webgpu

Cross-platform C++ example for WebGPU and Dawn
272 stars 36 forks source link

error: no member named 'source' in 'WGPUShaderModuleWGSLDescriptor' #19

Closed jvanlangen closed 8 months ago

jvanlangen commented 1 year ago

The example runs in VS2022 on windows but running into an error when trying to build for web:

$ ./build-web.bat
shared:INFO: (Emscripten: Running sanity checks)
src/main.cpp:182:7: error: no member named 'source' in 'WGPUShaderModuleWGSLDescriptor'
  182 |         wgsl.source = code;
      |         ~~~~ ^
1 error generated.
emcc: error: 'C:/Dev/VanLangen/Research/emsdk/upstream/bin\clang++.exe -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default --sysroot=C:\Dev\VanLangen\Research\emsdk\upstream\emscripten\cache\sysroot -Xclang -iwithsysroot/include\fakesdl -Xclang -iwithsysroot/include\compat -std=c++11 -Wall -Wextra -Werror -Wno-nonportable-include-path -fno-exceptions -fno-rtti -g0 -DNDEBUG=1 -flto -O3 -Iinc src/main.cpp -c -o C:\Users\jvanl\AppData\Local\Temp\emscripten_temp_32syw_dx\main_3.o' failed (returned 1)

I'm very new to emscripten/wasm etc. Any ideas?

cwoffenden commented 1 year ago

The API is a bit of a moving target sometimes and I need to update this repo (but the code to get an adapter changed so much that it requires more time that I have at the moment). It looks like .source is now .code:

https://github.com/webgpu-native/webgpu-headers/blob/d12388575785f254b5c186667e0c1b79e4da46b1/webgpu.h#L1032

Let me know if that works.

hymn4u commented 11 months ago

I met same problem, and .source->.code works, thx

cwoffenden commented 8 months ago

I committed fixes for this and other WebGPU spec changes. It's only working in the browser as the native versions need a rewrite of the adapter code.