WEBGPU Special Cases

WebGPU

WebGPU requires glslang and twgsl (including their binaries) to work correctly.

To configure their URLs individually:

javascript

const glslangOptions = {  jsPath: baseUrl + "/glslang/glslang.js",  wasmPath: baseUrl + "/glslang/glslang.wasm",};
const twgslOptions = {  jsPath: baseUrl + "/twgsl/twgsl.js",  wasmPath: baseUrl + "/twgsl/twgsl.wasm",};
const options = {  // ... webgpu options};
const engine = new BABYLON.WebGPUEngine(window.canvas, options);await engine.initAsync(glslangOptions, twgslOptions);

YO @sebavan / @Deltakosh

What if you dont pass these

engine.initAsync();

Where do they come from, I am using a vite react typescript project

          if (navigator.gpu && webgpu) {
              const webgpuEngine = new BABYLON.WebGPUEngine(canvas, {
                ...engineOptions,
                antialias,
                adaptToDeviceRatio,
                setMaximumLimits: true,
                enableAllFeatures:true,
              });
              await webgpuEngine.initAsync();
              engine = (webgpuEngine as any);
          } else {
              engine = new BABYLON.Engine(canvas, antialias, engineOptions, adaptToDeviceRatio);
          }

Did you have a fix on this issue?

Hi MackeyK24! If not specified, both are loaded from default Babylon CDN (https://cdn.babylonjs.com, as of today).

Glslang:

Twgsl:

Also they are not required if you are using only babylon base shaders as all of them were ported to WGSL :slight_smile:

YO @Deltakosh

When you say they are not required, and you dont specify them, are they still LOADED from the cdn… Or is there a way to tell it NOT to try load them at all, if they are not required ?

They are loaded ONLY if we find that you use a glsl shader in a WebGPU engine context

1 Like

Thanks for the clarification :slight_smile: