Class GenericBuffer<T>
This class encapsulate the resident on CPU and provide functionality to exchange data between the GPU and the CPU memory.
Inherited Members
Namespace: Mechatronics.SystemGraph
Syntax
public class GenericBuffer<T> : ExchangeBuffer where T : struct
Type Parameters
Name | Description |
---|---|
T |
Fields
_data
A byte array containing structured or non-structured data. This is only used when creating the GenericBuffer without gpuOnly support.
Declaration
protected NativeArray<T> _data
Field Value
Type | Description |
---|---|
NativeArray<T> |
Properties
Item[Int32]
Used to get a CPU read/write access to the internal buffer. WARNING: One must make sure to call AsyncReackback before reading from the array if the data has been updated on the GPU otherwise it will be in the same state as before submitting to the GPU OR will be disposed. For performance reason, one should use the native array instead if he want to iterate through a lot of elements instead of using this interface.
Declaration
public T this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index |
Property Value
Type | Description |
---|---|
T |
Methods
AsyncReadback(Action<NativeArray<T>>)
Transfer data from GPU to CPU NativeArray asynchronously. It's usually happening at the beginning of the next frame.
Declaration
public AsyncGPUReadbackRequest AsyncReadback(Action<NativeArray<T>> callback)
Parameters
Type | Name | Description |
---|---|---|
Action<NativeArray<T>> | callback | Action to execute once transfer is done. The user can set the callback to null and yield until the request is done. |
Returns
Type | Description |
---|---|
AsyncGPUReadbackRequest | Object that you can use to determine when the data is available or if an error occurred. |
CopyFrom(T[], Int32)
Copy an array of type T into the native array used to exchange data with the GPU.
Declaration
public void CopyFrom(T[] src, int elementCount)
Parameters
Type | Name | Description |
---|---|---|
T[] | src | |
Int32 | elementCount |
GetInternalBuffer()
Used to get a CPU read/write access to the internal buffer. WARNING: One must make sure to call AsyncReackback before reading from the array if the data has been updated on the GPU otherwise it will be in the same state as before submitting to the GPU OR will be disposed.
Declaration
public NativeArray<T> GetInternalBuffer()
Returns
Type | Description |
---|---|
NativeArray<T> |
InternalAllocate(Int32)
Used to allocate an element buffer on CPU side to contain the data.
Declaration
protected override void InternalAllocate(int elementCountMax)
Parameters
Type | Name | Description |
---|---|---|
Int32 | elementCountMax | Number of elements the buffer must contain. |
Overrides
InternalGetElementStride()
Retrieves the size of an element in bytes.
Declaration
protected override int InternalGetElementStride()
Returns
Type | Description |
---|---|
Int32 | Number of bytes corresponding to the size of the element. |
Overrides
InternalRelease()
Used to deallocate CPU-side buffer.
Declaration
protected override void InternalRelease()
Overrides
InternalUpdateBuffer()
Used to upload child structured data on the GPU.
Declaration
protected override void InternalUpdateBuffer()