I’m attempting to teach myself WebGPU by going through the various examples at webgpufundaments.org, and then converting each of from JS to Python and accessing WebGPU via wgpu-py.
I am discovering subtle differences between the WGSL accepted by Python versus the WGSL accepted by JS, even though I’m running both on the same hardware. The two biggest differences I’ve discovered are:
-
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
.
I have to assume that the compiler is inside the Python library and insider the browser rather than on the GPU itself. And that they are using different compilers.
So there are clearly “versions” of the language. The language spec just gives a list of previous drafts with no indication of what has changed. Neither the JS nor the Python library seems to have any “version” variable.
Does any sort of language versioning exist? Or is WGSL just a slowly evolving specification, and implementors can grab the spec at any point?
JS: Chrome Version 124.0.6367.156 (Official Build) (arm64)
Python: 3.12.0
MacOS Apple M1 Pro running Sonoma 14.4.1
Metal 3
WGPU-PY version 0.15.1