Skip to content

compute.createStorageBuffer#destroy

Summary

compute.createStorageBuffer#destroy invalidates a storage wrapper. It also destroys the raw buffer for allocated storage and for wrappers created with ownBuffer: true.

Syntax

destroy(): void
storage.destroy();

Returns

void - Repeated calls have no effect. Later writes, reads and binding normalization through the wrapper fail. A borrowed GPU buffer remains the caller's responsibility.

Example

const wgpu = await WasmGPU.create(document.querySelector("canvas"));
const storage = wgpu.compute.createStorageBuffer({ byteLength: 64 });
storage.destroy();

Notes

Submit all recorded work that uses owned storage before destroying it. Destroying the wrapper does not track or invalidate other wrappers around the same raw handle. Keep the raw buffer live while any alias still uses it.

See Also