Open bakkot opened 1 year ago
There's an interesting language called Shadeup that compiles to a mix of JavaScript and WGSL. It lets you write shaders inline, and "close over" the shader code from the CPU code to access data and types without having to explicitly set up buffers and descriptors etc. They have structs that can be defined on the CPU or GPU (which automatically map to array buffers via typed arrays on the JS-side). Having Shadeup-style structs in JavaScript would make working with WGSL much nicer.
Ideally, we should be able to pretty much copy and paste a WGSL struct into JS, instantiate it in JS (or Wasm), and pass it over to WGSL with all the bytes in the expected locations.
WebAssembly is important, but WGSL already has structs, so JS and WebAssembly should take their lead from WebGPU.
The WebGPU proposal has mentioned that they want something like this:
The v1 of that proposal does not have multithreading, but it may become relevant to a future version.