Hey guys … i was wondering what is the current state of WebGPU in babylon.js.
Is it production ready ?
And my biggest question I get about WebGPU… Is what do i get with WebGPU. Which i cant really answer. Because i dont see any difference. Small scenes, larges scenes… I Cant Tell
The WebGPU runs at +100 absolute FPS on average faster on my machine. With WebGL I get 600-700, with WebGPU it goes above 800 FPS. So there are clearly benefits to use WebGPU.
I’m quite new to WebGPU, also I think official devs would be better than me at explaining the benefits.
Still I can give my vision about this :
WebGPU brings an approach which is much closer to the GPU, non-only allowing more control on GPU ressources, but also minimizing CPU overhead
For example :
With WebGL, you could only compute vertex & fragment shaders, the first for vertex position compute, the second for pixel color compute, both being fully oriented toward rendering. If you where to try to do a GP-GPU process (Global Purpose calculation on GPU, for example a particule simulation) it is basically a nightware. For example HERE, particle simulation is computed with WebGL, but it’s a trick, with dozens of fragment shaders which are storing 3D particle position, velocity, force, pressure into some texture2D so basically nothing “logical” since texture2D should be only for images.
With WebGPU, you basically SQUASH this complexity by the usage of compute shader which are exactly for a GPGPU purpose. You just define a whatever calculation and parellize this over the thousands of processors on the GPU. For example HERE is another example where I’m using WebGPU to compute the particle simulation (again nothing about BabylonJS, sorry ^^) but if you have a look at my post about it you can quickly understand how simple it was to implement GPGPU in a web context, compared to using WebGL
I think that the current usage of WebGPU in BabylonJS is basically doing the same (as a result) than what it does in WebGL, but I’m confident that later on, we will be able to leverage the full power of WebGPU from within BabylonJS app to compute crazy good stuffs
Yes, as @Tricotou said, the main advantage of WebGPU is support for compute shaders, which will make it possible to implement new, faster algorithms in the future.
Right now, you can already get better performance using snapshot rendering mode, although it has its limitations, as described in the documentation.
Chrome has officially supported WebGPU 1.0 for a few months now, while other browsers (Safari, Firefox) have yet to release their first implementation, but are making progress.