WebGPU instancing does not render

I downloaded the latest chrome canari and enabled webgpu in the about::flags
I wanted to test the instancing performance using a existing playground.

In webgl it renders fine, but in webgpu it just renders a blue screen

Canari version:
Version 105.0.5137.2 (Official Build) canary (64-bit)

1 Like

ping @Evgeni_Popov @sebavan

@Evgeni_Popov is it a known limitation ?

It is not a problem with WebGPU, it is working in WebGL because of a side effect: the parallel compilation of shaders let some time before the scene is ready, so scene.freezeActiveMeshes(true) is postponed a bit (because this function is using scene.executeWhenReady internally) and for some reason it makes it work.

Honestly, I think it’s a bug in WebGL. In frozen mode, the vertex buffers should not be updated as there’s this bug:

if (!this._instanceDataStorage.isFrozen) {
    instancesBuffer!.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
    if (this._scene.needsPreviousWorldMatrices && (!this._instanceDataStorage.manualUpdate || this._instanceDataStorage.previousManualUpdate)) {
        instancesPreviousBuffer!.updateDirectly(instanceStorage.instancesPreviousData, 0, instancesCount);

But because of the delay the master mesh is not flagged as frozen.

If you disable parallel shader compilation, it is not working in WebGL neither:

I think we should add a method to perform the updateDirectly calls on the matrix buffer so that the user can update the matrices even in frozen mode.


@Evgeni_Popov would you like me to create an issue to track this? :thinking:

1 Like

Yes, if @sebavan is ok I think we should add this method.

all good for me

Add method to update matrices directly even when in frozen mode · Issue #12780 · BabylonJS/Babylon.js (github.com)


Thank you very much for all your effort guys, much appreciated.

PR created:

For this to work, the master mesh must be visible (because it must be an active mesh). If you really don’t want to display it, you can set a material that will hide it (disableColorWrite = true / disableDepthWrite = true).

Here’s a PG that will work once the PR is merged:

1 Like