StructuredBuffer

class StructuredBuffer

Description

StructuredBuffer represent a shader uniform/constant buffer values in array. Structured buffer is human-readable representation of raw shader buffer array data that stored in GPU. This class should be using only for creating a CPU buffer (here in C#) with all shaders variables, and send it to GPU when rendering is happen, or for setup shader buffers. In memory StructuredBuffer looks something like this: [float, float, int, int, int, Matrix4 ..., ..., ...]. Where for example first two floats can represent a Vector2, or middle three ints can represent a position or any other Vector3. At the moment, this API has a number of limitations, one of them is that we cannot send a certain part of the buffer, but only completely.

Properties

StructuredBuffer

Construct new StructuredBuffer from array of values.

StructuredBuffer

Construct new StructuredBuffer from IList collection.

Methods

Set

Send the StructuredBuffer to shader to GPU. All Set the object value at end of the buffer.

Get(int index)

Gets the object value by index from this buffer.

Get

Gets the all elements in sequence array of data.

Clear

Removes all values from this buffer (on CPU side not GPU).

CountOfElements

Returns total count of all elements in this buffer.

Count

Returns count of all objects in this buffer that was initially passed.

Size

Returns the total size in bytes of this buffer.

Operators

operator object[]

Convert StructuredBuffer to array of raw elements.

See Also

Renderer2D, ShaderBufferBlock

Last updated