twgsl (from "to WGSL") is a small "adapter" layer exposing the SPIR-V to WGSL transpilation capabilities of Google's Tint library to JavaScript.
I recommend building from a Linux VM set up explicitly for this purpose.
- Set up Emscripten, making sure to add its tools to your path.
- Set up Chrome Depot Tools, making sure to add the tools to your path.
- Clone twgsl and download the Tint submodule.
git clone https://github.com/BabylonJS/twgsl.git cd twgsl git submodule update --init --recursive
- Set up the Tint repository
to build.
cd Dependencies/Tint cp standalone.gclient .gclient gclient sync
- Create a build folder outside the
twgsl
folder (assumed in this example to be adjacent), then configure cmake using Emscripten's CMake wrapper.mkdir twgsl_build cd twgsl_build emcmake cmake ../twgsl
- Build the
twgsl
target using Emscripten's Make wrapper.Significant optimizations are turned on, so this build may take a very long time.emmake make twgsl