# Is there a performance difference between these two methods of buffer swapping?

**URL:** <https://forum.babylonjs.com/t/is-there-a-performance-difference-between-these-two-methods-of-buffer-swapping/45699>\
**Category:** Questions\
**Tags:** webgpu, compute-shader\
**Created:** [November 14, 2023, 8:52pm UTC](https://forum.babylonjs.com/t/is-there-a-performance-difference-between-these-two-methods-of-buffer-swapping/45699 "2023-11-14T20:52:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![christian](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@christian](https://forum.babylonjs.com/u/christian)\
**Post date:** [November 14, 2023, 8:52pm UTC](https://forum.babylonjs.com/t/is-there-a-performance-difference-between-these-two-methods-of-buffer-swapping/45699/1 "2023-11-14T20:52:05Z")

</div>

The example given in the playground found on the Babylon page about compute shaders shows a buffer swap implemented by creating two nearly identical compute shaders, with the only difference being the order of the buffers. I think you could accomplish the same result by just swapping the buffer pointers in a single compute shader each frame. Is there a performance difference between these two methods or any other reason to use one over the other?

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

---

<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:** [November 15, 2023, 11:09am UTC](https://forum.babylonjs.com/t/is-there-a-performance-difference-between-these-two-methods-of-buffer-swapping/45699/2 "2023-11-15T11:09:36Z")

</div>

cc @Evgeni_Popov the WebGPU god

---

<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 15, 2023, 1:41pm UTC](https://forum.babylonjs.com/t/is-there-a-performance-difference-between-these-two-methods-of-buffer-swapping/45699/3 "2023-11-15T13:41:20Z")

</div>

It’s slightly faster to have two compute shaders and swap between them than to have just one and swap buffer pointers, because in the latter case, the compute shader state changes when you update the pointers, triggering a rebuild of some internal structures. In the former case, the compute shaders do not change and can therefore be reused without internal reconstruction.
