docs.unity3d.com
    Show / Hide Table of Contents

    Class GenericBuffer<T>

    This class encapsulate the resident on CPU and provide functionality to exchange data between the GPU and the CPU memory.

    Inheritance
    Object
    ExchangeBuffer
    GenericBuffer<T>
    GenericCircularBuffer<T>
    PointCloud
    Inherited Members
    ExchangeBuffer.GPUData
    ExchangeBuffer.Stride
    ExchangeBuffer.Count
    ExchangeBuffer.Capacity
    ExchangeBuffer.isGPUOnly
    ExchangeBuffer.Allocate(Int32, Boolean)
    ExchangeBuffer.Release()
    ExchangeBuffer.UploadOnGPU()
    ExchangeBuffer._isDirty
    ExchangeBuffer._GPUData
    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
    ExchangeBuffer.InternalAllocate(Int32)

    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
    ExchangeBuffer.InternalGetElementStride()

    InternalRelease()

    Used to deallocate CPU-side buffer.

    Declaration
    protected override void InternalRelease()
    Overrides
    ExchangeBuffer.InternalRelease()

    InternalUpdateBuffer()

    Used to upload child structured data on the GPU.

    Declaration
    protected override void InternalUpdateBuffer()
    Overrides
    ExchangeBuffer.InternalUpdateBuffer()
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023