# WebGPU instancing does not render

**URL:** <https://forum.babylonjs.com/t/webgpu-instancing-does-not-render/31622>\
**Category:** Bugs\
**Created:** [June 23, 2022, 7:35am UTC](https://forum.babylonjs.com/t/webgpu-instancing-does-not-render/31622 "2022-06-23T07:35:15Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johan\_Rabie](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johan_rabie/32/24242_2.png) [@Johan\_Rabie](https://forum.babylonjs.com/u/Johan_Rabie)\
**Post date:** [June 23, 2022, 7:35am UTC](https://forum.babylonjs.com/t/webgpu-instancing-does-not-render/31622/1 "2022-06-23T07:35:16Z")

</div>

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

> **[Babylon.js Playground](https://playground.babylonjs.com/#HJGC2G)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

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

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/2/d2a4a383519325cebf8244ad92ab1b59f6053546.png)

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

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [June 23, 2022, 7:51am UTC](https://forum.babylonjs.com/t/webgpu-instancing-does-not-render/31622/2 "2022-06-23T07:51:33Z")

</div>

ping @Evgeni_Popov @sebavan

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 23, 2022, 3:09pm UTC](https://forum.babylonjs.com/t/webgpu-instancing-does-not-render/31622/3 "2022-06-23T15:09:24Z")

</div>

@Evgeni_Popov is it a known limitation ?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 23, 2022, 4:04pm UTC](https://forum.babylonjs.com/t/webgpu-instancing-does-not-render/31622/4 "2022-06-23T16:04:33Z")

</div>

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:

```nohighlight
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:

> **[Babylon.js Playground](https://playground.babylonjs.com/#HJGC2G%23163)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

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.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [July 21, 2022, 12:07pm UTC](https://forum.babylonjs.com/t/webgpu-instancing-does-not-render/31622/5 "2022-07-21T12:07:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 21, 2022, 2:15pm UTC](https://forum.babylonjs.com/t/webgpu-instancing-does-not-render/31622/7 "2022-07-21T14:15:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 21, 2022, 4:45pm UTC](https://forum.babylonjs.com/t/webgpu-instancing-does-not-render/31622/8 "2022-07-21T16:45:06Z")

</div>

all good for me

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [July 21, 2022, 6:40pm UTC](https://forum.babylonjs.com/t/webgpu-instancing-does-not-render/31622/9 "2022-07-21T18:40:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Johan\_Rabie](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johan_rabie/32/24242_2.png) [@Johan\_Rabie](https://forum.babylonjs.com/u/Johan_Rabie)\
**Post date:** [July 22, 2022, 7:35am UTC](https://forum.babylonjs.com/t/webgpu-instancing-does-not-render/31622/10 "2022-07-22T07:35:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [November 24, 2022, 2:31pm UTC](https://forum.babylonjs.com/t/webgpu-instancing-does-not-render/31622/11 "2022-11-24T14:31:45Z")

</div>

PR created:

> <https://github.com/BabylonJS/Babylon.js/pull/13282>
>
> See https://forum.babylonjs.com/t/webgpu-instancing-does-not-render/31622/4
> 
> I…nstead of creating a new method I have added a boolean that forces updating the matrix buffer even in frozen mode.

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:

> **[Babylon.js Playground](https://playground.babylonjs.com/#HJGC2G%23200)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes
