Create a new StorageBuffer instance.
The graphics device used to manage this storage buffer.
The size of the storage buffer in bytes.
Optional
bufferUsage: number = 0The usage type of the storage buffer. Can be a combination of BUFFERUSAGE_READ, BUFFERUSAGE_WRITE, BUFFERUSAGE_COPY_SRC and BUFFERUSAGE_COPY_DST flags. This parameter can be omitted if no special usage is required.
Clear the content of a storage buffer to 0.
Optional
offset: number = 0The byte offset of data to clear. Defaults to 0.
Optional
size: number = ...The byte size of data to clear. Defaults to the full size of the buffer minus the offset.
Issues a write operation of the provided data into a storage buffer.
The offset in bytes to start writing to the storage buffer.
The data to write to the storage buffer.
Offset in data to begin writing from. Given in elements if data is a TypedArray and bytes otherwise.
Size of content to write from data to buffer. Given in elements if data is a TypedArray and bytes otherwise.
A storage buffer represents a memory which both the CPU and the GPU can access. Typically it is used to provide data for compute shader, and to store the result of the computation. Note that this class is only supported on the WebGPU platform.