API

Interface StorageBufferOptions

Options for createStorageBuffer. Writable/vertex/index/indirect allocations keep no CPU mirror and require recreation after device loss.

interface StorageBufferOptions {
    index?: boolean;
    indirect?: boolean;
    label?: string;
    vertex?: boolean;
    writable?: boolean;
}
Index
index?: boolean

Also mark the allocation GPUBufferUsage.INDEX so meshes can SHARE one topology.

createMeshFromStorageBuffer uploads a fresh index buffer per mesh when given a typed array, which is right for meshes with their own topology and wrong for a slab of uniform slots: every slot in such a slab has byte-identical indices, so a few thousand of them duplicate the same kilobytes a few thousand times. Pass one index: true allocation to every mesh instead and the topology is uploaded once. The allocation outlives the meshes and is the caller's to dispose.

indirect?: boolean

Also mark the allocation GPUBufferUsage.INDIRECT so compute can produce workgroup counts or draw arguments without CPU readback.

label?: string
vertex?: boolean

Also mark the allocation GPUBufferUsage.VERTEX so a mesh can draw straight from it — letting a compute pass produce geometry with no readback and no copy.

writable?: boolean

Bind as var<storage, read_write> so shaders — including compute — can write it.

A writable allocation keeps NO CPU shadow copy: its contents are produced on the GPU, so there is nothing meaningful to mirror, and shadowing a large slab would double its memory. Automatic recovery of writable allocations is deferred; recreate the allocation and its consumers after device loss.