Buffer<T> Class
Namespace: Stride.GraphicsAssembly: Stride.Graphics.dll
A buffer with typed information.
public class Buffer<T> : Buffer, IDisposable, IComponent, IReferencable, ICollectorHolder where T : struct
Type Parameters
Name | Description |
---|---|
T | Type of an element of this buffer. |
Name | Description | |
---|---|---|
Constructors | ||
Buffer(GraphicsDevice, BufferDescription, BufferFlags, PixelFormat, IntPtr) | ||
Fields | ||
ElementSize | Gets the size of element T. |
|
Methods | ||
GetData(CommandList) | Gets the content of this texture to an array of data. |
|
SetData(CommandList, ref T, Int32) | Copies the content of a single structure data from CPU memory to this buffer into GPU memory. |
|
SetData(CommandList, T[], Int32) | Copies the content an array of data from CPU memory to this buffer into GPU memory. |
Constructors
Buffer(GraphicsDevice, BufferDescription, BufferFlags, PixelFormat, IntPtr)
protected Buffer(GraphicsDevice device, BufferDescription description, BufferFlags viewFlags, PixelFormat viewFormat, IntPtr dataPointer)
Parameters
Type | Name | Description |
---|---|---|
GraphicsDevice | device | |
BufferDescription | description | |
BufferFlags | viewFlags | |
PixelFormat | viewFormat | |
System.IntPtr | dataPointer |
Fields
ElementSize
Gets the size of element T.
public readonly int ElementSize
Field Value
Type | Description |
---|---|
System.Int32 |
Methods
GetData(CommandList)
Gets the content of this texture to an array of data.
public T[] GetData(CommandList commandList)
Parameters
Type | Name | Description |
---|---|---|
CommandList | commandList |
Returns
Type | Description |
---|---|
T[] | An array of data. |
Remarks
This method is only working when called from the main thread that is accessing the main GraphicsDevice. This method creates internally a stagging resource if this texture is not already a stagging resouce, copies to it and map it to memory. Use method with explicit staging resource for optimal performances.
SetData(CommandList, ref T, Int32)
Copies the content of a single structure data from CPU memory to this buffer into GPU memory.
public void SetData(CommandList commandList, ref T fromData, int offsetInBytes = 0)
Parameters
Type | Name | Description |
---|---|---|
CommandList | commandList | |
T | fromData | The data to copy from. |
System.Int32 | offsetInBytes | The offset in bytes to write to. |
Remarks
This method is only working when called from the main thread that is accessing the main GraphicsDevice. See the unmanaged documentation about Map/UnMap for usage and restrictions.
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
SetData(CommandList, T[], Int32)
Copies the content an array of data from CPU memory to this buffer into GPU memory.
public void SetData(CommandList commandList, T[] fromData, int offsetInBytes = 0)
Parameters
Type | Name | Description |
---|---|---|
CommandList | commandList | |
T[] | fromData | The data to copy from. |
System.Int32 | offsetInBytes | The offset in bytes to write to. |
Remarks
This method is only working when called from the main thread that is accessing the main GraphicsDevice. See the unmanaged documentation about Map/UnMap for usage and restrictions.