Class StorageBuffer
Namespace: ValveResourceFormat.Renderer.Buffers
Assembly: Renderer.dll
Shader storage buffer object for large read-write data arrays on the GPU.
public class StorageBuffer : BufferInheritance
object ← Buffer ← StorageBuffer
Inherited Members
Buffer.Target, Buffer.Handle, Buffer.BindingPoint, Buffer.Name, Buffer.Size, Buffer.BindBufferBase(), Buffer.BindBufferBase(ReservedBufferSlots), Buffer.Delete()
Constructors
StorageBuffer(ReservedBufferSlots, string)
Initializes a new storage buffer bound to the given reserved slot.
public StorageBuffer(ReservedBufferSlots bindingPoint, string name)Parameters
bindingPoint ReservedBufferSlots
The reserved slot to bind the buffer to.
name string
Debug name for the buffer. Named explicitly because reuses its values between the uniform and storage namespaces, so a slot cannot name itself: the scratch slots have no meaningful name of their own, and the rest would report the uniform slot sharing their value.
Methods
Allocate<T>(ReservedBufferSlots, string, int, BufferUsage)
Allocates a new storage buffer sized for the given number of elements.
public static StorageBuffer Allocate<T>(ReservedBufferSlots bindingPoint, string name, int elements, BufferUsage usage)Parameters
bindingPoint ReservedBufferSlots
The reserved slot to bind the buffer to.
name string
Debug name for the buffer, see .
elements int
Number of elements to allocate space for.
usage BufferUsage
Who writes the buffer and who reads it.
Returns
The newly allocated .
Type Parameters
T
The element type used to compute the total byte size.
Remarks
creates a mapped bufferClear()
Zeroes the entire contents of this buffer.
public void Clear()Create<T>(List<T>, BufferUsage)
Uploads the contents of a list to this buffer, replacing any existing data.
public void Create<T>(List<T> data, BufferUsage usage) where T : structParameters
data List<T>
The source list to upload.
usage BufferUsage
Who writes the buffer and who reads it.
Type Parameters
T
Create<T>(T[], int, BufferUsage)
Uploads a typed array to this buffer with the given total byte size.
public void Create<T>(T[] data, int totalSizeInBytes, BufferUsage usage) where T : structParameters
data T[]
The source array to upload.
totalSizeInBytes int
Total number of bytes to upload from data.
usage BufferUsage
Who writes the buffer and who reads it.
Type Parameters
T
Create<T>(ReadOnlySpan<T>, BufferUsage)
Uploads a read-only span to this buffer.
public void Create<T>(ReadOnlySpan<T> data, BufferUsage usage) where T : structParameters
data ReadOnlySpan<T>
The source span to upload.
usage BufferUsage
Who writes the buffer and who reads it.
Type Parameters
T
Delete()
Deletes the underlying OpenGL buffer object.
public override void Delete()Fill(uint)
Fills the entire buffer with a repeating 32 bit value.
public void Fill(uint value)Parameters
value uint
The value written to every 32 bit word.
Read<T>(ref T)
Reads the buffer's contents back from the GPU into the given struct.
public void Read<T>(ref T output) where T : structParameters
output T
The struct to populate with buffer data.
Type Parameters
T
Update<T>(ReadOnlySpan<T>, int)
Updates a region of this buffer from a span.
public void Update<T>(ReadOnlySpan<T> data, int offset) where T : structParameters
data ReadOnlySpan<T>
The source span to upload.
offset int
Byte offset into the buffer at which to begin writing.
Type Parameters
T
Update<T>(T[], int, int)
Updates a region of this buffer with new data, allocating it first if empty.
public void Update<T>(T[] data, int offset, int size) where T : structParameters
data T[]
The source array containing new data.
offset int
Byte offset into the buffer at which to begin writing.
size int
Number of bytes to write.
Type Parameters
T

