Hey there!
I am working on procedural terrain generation to make a system that loads and destroys terrain chunks on the fly.
As all chunks have the same triangle topology, I thought sharing the index buffer between all the chunks would be a nice optimization to reduce memory consumption.
In this PG, 2 terrain chunks share the same index buffer:
However, when I dispose one of the chunks (press the “d” key), it crashes WebGPU. I believe disposing the chunk could be disposing the shared index buffer, hence the remaining chunk is in for a bad time ^^
So my question is: how can I dispose my chunks without disposing the shared index buffer in order to keep using it for other chunks?