WebGPU + es6 error: Unable to compile effect: #define SHADER_NAME fragment:clearQuad

What’s up Babyloners (Babylonians sounds better maybe?), long time no see!

Please see the following very simple demo:
https://stackblitz.com/edit/vitejs-vite-bswhg9?file=index.html,main.js

It’s just importing babylon es6, and initializing WebGPU.
It throws an error.

if you set WEBGPU = false, you can see that it works with the WebGL engine.

Do I need to importing something else, or is this a bug?
Please send help!
Thank you and have a nice day!

You are missing a few imports to make it work. We have an open issue to take care of that, but for now you will need to import a few files in order for that to work:

import ‘@babylonjs/core/Engines/WebGPU/Extensions/engine.uniformBuffer’;

2 Likes

Thank you!

I ended up including

import "@babylonjs/core/Engines/WebGPU/Extensions/";
in my program, because of more errors.

It kind of works now, but throws a soup of warnings like below.
(I hope theese will be solved in the future.)

chunk-LGXWSSHW.js?v=3b7c0c51:110 BJS - [14:43:18]: Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.

14:43:18.863 twgsl.js:4 'textureSampleCompare' must only be called from uniform control flow
14:43:18.863 twgsl.js:4 
14:43:18.863 twgsl.js:4 control flow depends on non-uniform value
14:43:18.863 twgsl.js:4 
14:43:18.863 twgsl.js:4 reading from module-scope private variable 'index0' may result in a non-uniform value
14:43:18.863 twgsl.js:4 
14:43:19.456 twgsl.js:4 'textureSampleCompare' must only be called from uniform control flow
14:43:19.456 twgsl.js:4 
14:43:19.456 twgsl.js:4 control flow depends on non-uniform value
14:43:19.456 twgsl.js:4 
14:43:19.457 twgsl.js:4 reading from module-scope private variable 'index0' may result in a non-uniform value
14:43:19.457 twgsl.js:4 
14:43:19.473 test.hu/:1 1 warning(s) generated while compiling the shader:
:1398:26 warning: 'textureSampleCompare' must only be called from uniform control flow
      let x_1601 : f32 = textureSampleCompare(shadowSampler0Texture, shadowSampler0Sampler, x_1599.xy, i32(round(x_1599.z)), x_1599.w);
                         ^^^^^^^^^^^^^^^^^^^^

:1341:5 note: control flow depends on non-uniform value
    if (((x_1463 < 3i) & (x_1465 < 1.0f))) {
    ^^

:1332:24 note: reading from module-scope private variable 'index0' may result in a non-uniform value
    let x_1452 : i32 = index0;
                       ^^^^^^

14:43:19.801 test.hu/:1 1 warning(s) generated while compiling the shader:
:1398:26 warning: 'textureSampleCompare' must only be called from uniform control flow
      let x_1601 : f32 = textureSampleCompare(shadowSampler0Texture, shadowSampler0Sampler, x_1599.xy, i32(round(x_1599.z)), x_1599.w);
                         ^^^^^^^^^^^^^^^^^^^^

:1341:5 note: control flow depends on non-uniform value
    if (((x_1463 < 3i) & (x_1465 < 1.0f))) {
    ^^

:1332:24 note: reading from module-scope private variable 'index0' may result in a non-uniform value
    let x_1452 : i32 = index0;
                       ^^^^^^

cc @Evgeni_Popov

Does it throw the same if you use it in the playground?

I tried to include “everything” my program uses, and yes, the warnings are there when I add CascadesShadowGenerator. Also, the environment texture is NEAREST sampled. (Which is somewhere in the warnings too)

https://stackblitz.com/edit/vitejs-vite-bswhg9?file=index.html,main.js

In the babylon playground, there are no warnings.
In the babylon playground, the warnings are the same, as the texture sampling. It has nothing to do with es6 then…

1 Like

The warning are related to the latest spec changes and @Evgeni_Popov will address those soon-ish :slight_smile:

They should not break in subsequent Chrome version as they decided to stay back compat until release IIRC.

3 Likes