Table of Contents

Class Buffer.StructuredCounter

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll

Helper methods for creating Structured Counter Buffers.

public static class Buffer.StructuredCounter
Inheritance
object
Buffer.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

device GraphicsDevice

The GraphicsDevice.

dataPointer DataPointer

The data pointer to the data to initialize the Structured Counter Buffer.

elementSize int

The size in bytes of each element (the structure).

Returns

Buffer

A new instance of Buffer.

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

device GraphicsDevice

The GraphicsDevice.

elementCount int

The number of elements in the Buffer.

elementSize int

The size in bytes of each element (the structure).

Returns

Buffer

A new instance of Buffer.

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

device GraphicsDevice

The GraphicsDevice.

data ReadOnlySpan<byte>

The data to initialize the Structured Counter Buffer.

elementSize int

The size in bytes of each element (the structure).

Returns

Buffer

A new instance of Buffer.

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

device GraphicsDevice

The GraphicsDevice.

elementCount int

The number of elements in the Buffer.

Returns

Buffer<T>

A new instance of Buffer.

Type Parameters

T

Type 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

device GraphicsDevice

The GraphicsDevice.

data T[]

The data to initialize the Structured Counter Buffer.

Returns

Buffer

A new instance of Buffer.

Type Parameters

T

Type of the StructuredCounter buffer to get the sizeof from

See Also