TSL and webgl2 vs webgpu

Hiya all, finally it’s been my turn to play around and learn TSL, and I’ve been very excited for this.

Playing around with webgpu, I wanted to ensure I had a webgl fallback, for browsers that didn’t support webgpu, although the webglrenderer, wouldnt take any nodes I fed it. I’ve been looking around this discourse and found a few different posts, initially, I couldn’t understand how TSL was renderer agnostic. Supposedly, the webgpu-renderer uses webgl2 as a fallback, whenever the browser doesn’t support webgpu → TSL compiles to glsl + wgsl, so its agnostic. Gotcha, got it, that makes sense.

But just to be absolutely sure, does that essentially mean, there’s any gotcha’s to be aware of using the webgpu renderer, will anything work on webgpu and webgl2 the same, despite shaders as well?

Compute shaders are not fully compatible with WebGL 2. Depending on what features you are using (e.g. indirect draw calls via IndirectStorageBufferAttribute or atomics), the code will only work with WebGPU. It is also not possible to emulate this code somehow with GLSL/WebGL 2 so make sure you pick the correct feature set if you want to ensure WebGL 2 support as well.

To get an overview, it’s maybe best to go through the compute examples ( three.js examples ) with a WebGL 2 only browser like Firefox to see which one work with WebGL as well.

2 Likes