WebGPU Status

Note that we will use Chrome Canary as our gauge browser for WebGPU features as other browsers are still lagging in term of feature support as of this writing (2021/09/15).

Make it work: Current status of the port

Most of the features of Babylon.js are now available in WebGPU. Here's a detailed list of what is not working / is partially working.

Features with incomplete support

  • Point Cloud System
    • WebGPU does not support a point size different from 1, so setting a value different from 1 for the point size won't be taken into account

Features not working because not implemented yet

  • Support for triangle fan / line loop drawing mode
    • WebGPU does not support those modes, we will need to emulate them with triangle strip and line strip
  • Multiview / WebXR
    • Not implemented yet but not supported by Chrome / WebGPU specifications neither

Features implemented but not working or fully working because not implemented/fully implemented by Chrome yet

  • MSAA can only be 1 or 4 in Chrome as of this writing

Make it fast: Optimizations

We need to implement some specific mechanisms / features to get the most of our implementation:

  • Use render bundles to improve performances:
    • Done through engine.compatibilityMode = false but needs more work to support more features of the engine
    • Also added engine.snapshotRendering and engine.snapshotRenderingMode to improve performances in some specific cases (when scene is mostly static)
  • Use compute shaders -> the ComputeShader class is now in
    • To perform some conversions when reading data from buffers
  • Use CreatePipelineAsync for asynchronous pipeline creations
  • ...and lots of others!

So, don't try to benchmark your code against WebGL just yet, it won't be representative of the real performances you will get once the steps outlined above are integrated (and notably the first one)!

Browser Caveats

Chrome Canary does not support all WebGPU features yet (or some others are not fully functional yet), so here are some caveats:

  • MSAA limited to values 1 or 4
  • Updating GPU textures with canvas / videos is slow. It means you will see really bad performance if you use dynamic GUIs (GUI that have elements which are updated on each frame) or video elements.
    • Try this PG for eg: Multiple dynamic GUIs + Video
    • Regarding videos, we now support writing WGSL code in the ShaderMaterial class, so you can use the texture_external type object for fast video playing! See the video example in WGSL
  • No WebGPU capabilities (caps) returned by the browser
    • For the time being, we have set some hard values for the caps (4 for MSAA max samples, for eg, as Chrome does not support more yet)
  • error X3511: unable to unroll loop, loop does not appear to terminate in a timely manner (XXX iterations) or unrolled loop is too large, use the [unroll(n)] attribute to force an exact higher number
  • GPU timing in the Inspector does not work because timestamp queries are currently disabled in Chrome. You can start Chrome with the --disable-dawn-features=disallow_unsafe_apis flag if you want to enable them.