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?
cc @Evgeni_Popov the WebGPU god
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.