There is a WebGPU sample that doesn't work with Babylon.js 6.0

I tried some of the samples found in the official docs.
Some WebGPU samples don’t seem to work on Chrome 113(beta).

BJS - [01:28:21]: Babylon.js v6.0.0 - WebGPU1 engine
Vertex buffer arrayStride (3) is not a multiple of 4.
 - While validating buffers[0].
 - While validating vertex state.
 - While calling [Device].CreateRenderPipeline([RenderPipelineDescriptor "RenderPipeline_bgra8unorm_depth24plus-stencil8_samples4"]).

Oops. It looks like my misunderstanding. It seems correct(!?) that this sample does not work.

Try this PG, which works in WebGL but not in WebGPU:

Yes, it’s expected to fail in WebGPU as stride can’t be less than 4.

2 Likes

Thank you for teaching me.

I think it’s another problem, but the Babylon.js + WGSL sample below causes an error. Any advice? (It could also be my bug.)

This sample expects a textured cube to be displayed.
https://cx20.github.io/webgpu-test/examples/babylonjs_wgsl/texture/index.html

Tint WGSL reader failure: :41:1 error: unresolved identifier 'vUV'
vUV = uv;
^^^

 - While validating [ShaderModuleDescriptor]
 - While calling [Device].CreateShaderModule([ShaderModuleDescriptor]).

The syntax has changed to access some predefined data, see Writing shaders for WebGPU in WGSL | Babylon.js Documentation for details (we had to make this change because of a change in the specification, but I think the new way of accessing data is better anyway).

I also just created a PR in the documentation to correct this:

@vertex
fn main(input : VertexInputs) -> FragmentInputs {
    gl_Position = scene.viewProjection * mesh.world * vec4<f32>(position, 1.0);
}

into that:

@vertex
fn main(input : VertexInputs) -> FragmentInputs {
    vertexOutputs.position = scene.viewProjection * mesh.world * vec4<f32>(vertexInputs.position, 1.0);
}
2 Likes

Thanks to your advice, I realized that there was a correction mistake.
The sample now works.

2 Likes