Create a new StorageBuffer instance.
The graphics device used to manage this storage buffer.
The size of the storage buffer in bytes.
OptionalbufferUsage: 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.
OptionaladdStorageUsage: boolean = trueIf true, automatically adds BUFFERUSAGE_STORAGE flag. Set to false for staging buffers that use BUFFERUSAGE_WRITE. Defaults to true.
Clear the content of a storage buffer to 0.
Optionaloffset: number = 0The byte offset of data to clear. Defaults to 0.
Optionalsize: number = ...The byte size of data to clear. Defaults to the full size of the buffer minus the offset.
Copy data from another storage buffer into this storage buffer.
The source storage buffer to copy from.
OptionalsrcOffset: number = 0The byte offset in the source buffer. Defaults to 0.
OptionaldstOffset: number = 0The byte offset in this buffer. Defaults to 0.
Optionalsize: number = ...The byte size of data to copy. Defaults to the full size of the source buffer minus the source offset.
Frees resources associated with this storage buffer.
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.