Class Buffer.Constant
Helper methods for creating Constant Buffers.
public static class Buffer.Constant
- Inheritance
-
objectBuffer.Constant
Remarks
A Constant Buffer is a Buffer that is used to pass shader constants / parameters to shaders. They have fast access due to special hardware optimizations, being read-only to shaders, and being of a limited size (64 kB usually).
Methods
New(GraphicsDevice, DataPointer, GraphicsResourceUsage)
Creates a new Constant Buffer with initial data.
[Obsolete("This method is obsolete. Use the span-based methods instead")]
public static Buffer New(GraphicsDevice device, DataPointer dataPointer, GraphicsResourceUsage usage = GraphicsResourceUsage.Dynamic)
Parameters
deviceGraphicsDeviceThe GraphicsDevice.
dataPointerDataPointerThe data pointer to the data to initialize the Constant Buffer.
usageGraphicsResourceUsageThe usage for the Buffer, which determines who can read/write data. By default, it is Dynamic.
Returns
New(GraphicsDevice, int, GraphicsResourceUsage)
Creates a new Constant Buffer of a given size.
public static Buffer New(GraphicsDevice device, int bufferSize, GraphicsResourceUsage usage = GraphicsResourceUsage.Dynamic)
Parameters
deviceGraphicsDeviceThe GraphicsDevice.
bufferSizeintSize of the Buffer in bytes.
usageGraphicsResourceUsageThe usage for the Buffer, which determines who can read/write data. By default, it is Dynamic.
Returns
New(GraphicsDevice, ReadOnlySpan<byte>, GraphicsResourceUsage)
Creates a new Constant Buffer with initial data.
public static Buffer New(GraphicsDevice device, ReadOnlySpan<byte> data, GraphicsResourceUsage usage = GraphicsResourceUsage.Dynamic)
Parameters
deviceGraphicsDeviceThe GraphicsDevice.
dataReadOnlySpan<byte>The data to initialize the Constant Buffer.
usageGraphicsResourceUsageThe usage for the Buffer, which determines who can read/write data. By default, it is Dynamic.
Returns
New<T>(GraphicsDevice)
Creates a new Constant Buffer with Dynamic usage.
public static Buffer<T> New<T>(GraphicsDevice device) where T : unmanaged
Parameters
deviceGraphicsDeviceThe GraphicsDevice.
Returns
Type Parameters
TType of the data stored in the Buffer.
New<T>(GraphicsDevice, ref readonly T, GraphicsResourceUsage)
Creates a new Constant Buffer with initial data.
public static Buffer<T> New<T>(GraphicsDevice device, ref readonly T value, GraphicsResourceUsage usage = GraphicsResourceUsage.Dynamic) where T : unmanaged
Parameters
deviceGraphicsDeviceThe GraphicsDevice.
valueTThe value to initialize the Constant Buffer.
usageGraphicsResourceUsageThe usage for the Buffer, which determines who can read/write data. By default, it is Dynamic.
Returns
Type Parameters
TType of the data stored in the Buffer.
New<T>(GraphicsDevice, T[], GraphicsResourceUsage)
Creates a new Constant Buffer with initial data.
public static Buffer<T> New<T>(GraphicsDevice device, T[] data, GraphicsResourceUsage usage = GraphicsResourceUsage.Dynamic) where T : unmanaged
Parameters
deviceGraphicsDeviceThe GraphicsDevice.
dataT[]The data to initialize the Constant Buffer.
usageGraphicsResourceUsageThe usage for the Buffer, which determines who can read/write data. By default, it is Dynamic.
Returns
Type Parameters
TType of the data stored in the Buffer.