The Web High-level Shading Language provides a human-writable, safe programming language for the WebGPU API.
- Formally proven as safe for Web use e.g. the language forbids reading or writing to memory that shouldn't be accessible.
- C-like syntax that is similar to Microsoft's HLSL, and thus compatible with the majority of the world's existing shaders.
- Supports a restricted form of pointers.
The Examples directory has some WHLSL sample code.
We currently support Metal Shading Language as an output format, as well as a debug mode (JSON).
You can get
jsc by checking out and building WebKit
or, if you're using macOS, it can be found in
Alternatively, load Source/json/JSON.html, Source/metal/MSL.html or Source/spirv/SPIRV.html in your browser.
More details can be found in Code Generation. Also, there are some rough notes on the specifics of translating WHLSL to SPIR-V.
Running the Tests
The WHSL source code is exposed as an ES6 Module.
To run the tests:
Or, load Source/Test.html in your browser (assuming your browser supports ES modules, which most modern browsers do).