Maps readBuffer for CPU access, copies its contents into a new typed array, then unmaps.
The .slice() is required — getMappedRange() returns a view into the mapped GPU memory
which becomes invalid after unmap(), so we copy it out before unmapping.
The buffer then goes back to its device's readback pool (see stageReadback)
— only after a clean unmap; if mapping fails it is destroyed instead.
Maps
readBufferfor CPU access, copies its contents into a new typed array, then unmaps. The.slice()is required —getMappedRange()returns a view into the mapped GPU memory which becomes invalid afterunmap(), so we copy it out before unmapping. The buffer then goes back to its device's readback pool (seestageReadback) — only after a clean unmap; if mapping fails it is destroyed instead.