Update wgsl compiler.
fyellin opened this issue · 4 comments
I notice that the WGSL accepted by JavaScript/Chrome (on my Macos) is different than the WGSL accepted when running wgpu-py.
In particular:
-
The Python version doesn't know about
override
. This keyword and the@id()
annotation are errors. -
The Python version requires stricter typing. On JS I can write:
var temp = 0u; temp += 1.
In Python the compiler complains about mismatched types unless I write1u
.
Is wgpu-py using a WGSL compiler from elsewhere? Can I easily update that compiler to match what's in Chrome?
There's essentially two competing implementations: Dawn (google) and wgpu-native (mozilla). Wgpu-py is based on wgpu-native today. The wgsl compiler is Naga in our case.
Updating it is not trivial. It's part of wgpu-native so it means updating the version of wgpu-native that is wrapped here. There's some docs and instructions in the repo for doing that.
Ah. Thanks for the info. At least now I understand what’s going on. I’ll close this.
I’ve been teaching myself WebGPU by taking examples from Chrome/JS and converting them to Python. I was surprised when the shaders wouldn’t compile.
Here are the docs I referred to in my previous post: https://github.com/pygfx/wgpu-py/blob/main/codegen/README.md
It's worth noting that both implementations are moving towards the same spec. At least for the C-API, but I also expect that they converge on the same wgsl spec eventually. (Though no doubt there will be edge-cases where the spec is not fully unambiguous, and the implementations will differ 🤷 )