Class Buffer.StructuredCounter
Helper methods for creating Structured Counter Buffers.
public static class Buffer.StructuredCounter
- Inheritance
-
objectBuffer.StructuredCounter
Remarks
A Structured Counter Buffer is a Buffer that allows atomic append operations from shaders (similar to Append / Consume Buffers, see Buffer.StructuredAppend), but with an associated counter. That counter can be read / written atomically from shaders. They are a special kind of Structured Buffers, so they are also an array of uniformly sized structures.
An example of this kind of Buffer in SLSL would be:
StructuredBuffer<float4> sb;
RWStructuredBuffer<float4> rwsb; // For structured buffers supporting unordered access
Methods
New(GraphicsDevice, DataPointer, int)
Creates a new Structured Counter Buffer with initial data.
[Obsolete("This method is obsolete. Use the span-based methods instead")]
public static Buffer New(GraphicsDevice device, DataPointer dataPointer, int elementSize)
Parameters
deviceGraphicsDeviceThe GraphicsDevice.
dataPointerDataPointerThe data pointer to the data to initialize the Structured Counter Buffer.
elementSizeintThe size in bytes of each element (the structure).
Returns
New(GraphicsDevice, int, int)
Creates a new Structured Counter Buffer of a given size.
public static Buffer New(GraphicsDevice device, int elementCount, int elementSize)
Parameters
deviceGraphicsDeviceThe GraphicsDevice.
elementCountintThe number of elements in the Buffer.
elementSizeintThe size in bytes of each element (the structure).
Returns
New(GraphicsDevice, ReadOnlySpan<byte>, int)
Creates a new Structured Counter Buffer with initial data.
public static Buffer New(GraphicsDevice device, ReadOnlySpan<byte> data, int elementSize)
Parameters
deviceGraphicsDeviceThe GraphicsDevice.
dataReadOnlySpan<byte>The data to initialize the Structured Counter Buffer.
elementSizeintThe size in bytes of each element (the structure).
Returns
New<T>(GraphicsDevice, int)
Creates a new Structured Counter Buffer of a given size.
public static Buffer<T> New<T>(GraphicsDevice device, int elementCount) where T : unmanaged
Parameters
deviceGraphicsDeviceThe GraphicsDevice.
elementCountintThe number of elements in the Buffer.
Returns
Type Parameters
TType of the data stored in the Buffer.
New<T>(GraphicsDevice, T[])
Creates a new Structured Counter Buffer with initial data.
public static Buffer New<T>(GraphicsDevice device, T[] data) where T : unmanaged
Parameters
deviceGraphicsDeviceThe GraphicsDevice.
dataT[]The data to initialize the Structured Counter Buffer.
Returns
Type Parameters
TType of the StructuredCounter buffer to get the sizeof from