Search Results for

    Show / Hide Table of Contents

    Class GPUBuffer

    All-in-one GPU buffer class. This class is able to create index buffers, vertex buffers, structured buffer and argument buffers.

    Inheritance
    System.Object
    Object
    GPUResource
    GPUBuffer
    Inherited Members
    GPUResource.ReleaseGPU()
    GPUResource.ResourceType
    GPUResource.MemoryUsage
    GPUResource.Name
    Object.__unmanagedPtr
    Object.__internalId
    Object.Finalize()
    Object.As<T>()
    Object.NewValue(Type)
    Object.New(String)
    Object.Find<T>(Guid, Boolean)
    Object.Find(Guid, Type, Boolean)
    Object.TryFind<T>(Guid)
    Object.TryFind(Guid, Type)
    Object.Destroy(Object, Single)
    Object.DestroyNow(Object)
    Object.Destroy<T>(T, Single)
    Object.Equals(Object)
    Object.GetUnmanagedPtr(Object)
    Object.GetUnmanagedInterface(Object, Type)
    Object.FromUnmanagedPtr(IntPtr)
    Object.MapObjectID(Guid)
    Object.RemapObjectID(Guid)
    Object.GetHashCode()
    Object.ID
    Object.TypeName
    Namespace: FlaxEngine
    Assembly: FlaxEngine.CSharp.dll
    Syntax
    [Unmanaged]
    public sealed class GPUBuffer : GPUResource

    Constructors

    GPUBuffer()

    Initializes a new instance of the GPUBuffer.

    Declaration
    public GPUBuffer()

    Properties

    Description

    Gets buffer description structure.

    Declaration
    [Unmanaged]
    public GPUBufferDescription Description { get; }
    Property Value
    GPUBufferDescription

    ElementsCount

    Gets buffer elements count (size divided by the stride).

    Declaration
    [Unmanaged]
    public uint ElementsCount { get; }
    Property Value
    System.UInt32

    Format

    Gets buffer data format (if used).

    Declaration
    [Unmanaged]
    public PixelFormat Format { get; }
    Property Value
    PixelFormat

    IsAllocated

    Gets a value indicating whether this buffer has been allocated.

    Declaration
    [Unmanaged]
    public bool IsAllocated { get; }
    Property Value
    System.Boolean

    IsDynamic

    Checks if buffer is a dynamic buffer.

    Declaration
    [Unmanaged]
    public bool IsDynamic { get; }
    Property Value
    System.Boolean

    IsShaderResource

    Gets a value indicating whether this buffer is a shader resource.

    Declaration
    [Unmanaged]
    public bool IsShaderResource { get; }
    Property Value
    System.Boolean

    IsStaging

    Checks if buffer is a staging buffer (supports CPU access).

    Declaration
    [Unmanaged]
    public bool IsStaging { get; }
    Property Value
    System.Boolean

    IsUnorderedAccess

    Gets a value indicating whether this buffer is a unordered access.

    Declaration
    [Unmanaged]
    public bool IsUnorderedAccess { get; }
    Property Value
    System.Boolean

    Size

    Gets buffer size in bytes.

    Declaration
    [Unmanaged]
    public uint Size { get; }
    Property Value
    System.UInt32

    Stride

    Gets buffer stride in bytes.

    Declaration
    [Unmanaged]
    public uint Stride { get; }
    Property Value
    System.UInt32

    VertexLayout

    Gets vertex elements layout used by vertex buffers only.

    Declaration
    [Unmanaged]
    public GPUVertexLayout VertexLayout { get; }
    Property Value
    GPUVertexLayout

    Methods

    DownloadData(out Byte[])

    Stops current thread execution to gather buffer data from the GPU. Cannot be called from main thread if the buffer is not a dynamic nor staging readback.

    Declaration
    [Unmanaged]
    public bool DownloadData(out byte[] result)
    Parameters
    System.Byte[] result

    The result data.

    Returns
    System.Boolean

    True if cannot download data, otherwise false.

    GetData(out Byte[])

    Gets the buffer data via map/memcpy/unmap sequence. Always supported for dynamic and staging buffers (other types support depends on graphics backend implementation).

    Declaration
    [Unmanaged]
    public bool GetData(out byte[] output)
    Parameters
    System.Byte[] output

    The output data container.

    Returns
    System.Boolean

    True if failed, otherwise false.

    Init(ref GPUBufferDescription)

    Creates new buffer.

    Declaration
    [Unmanaged]
    public bool Init(ref GPUBufferDescription desc)
    Parameters
    GPUBufferDescription desc

    The buffer description.

    Returns
    System.Boolean

    True if cannot create buffer, otherwise false.

    Map(GPUResourceMapMode)

    Gets a CPU pointer to the resource by mapping its contents. Denies the GPU access to that resource.

    Declaration
    [Unmanaged]
    public IntPtr Map(GPUResourceMapMode mode)
    Parameters
    GPUResourceMapMode mode

    The map operation mode.

    Returns
    System.IntPtr

    The pointer of the mapped CPU buffer with resource data or null if failed.

    Remarks

    Always call Unmap if the returned pointer is valid to release resources.

    Resize(UInt32)

    Tries to resize the buffer (warning: contents will be lost).

    Declaration
    [Unmanaged]
    public bool Resize(uint newSize)
    Parameters
    System.UInt32 newSize

    The new size (in bytes).

    Returns
    System.Boolean

    True if cannot resize buffer, otherwise false.

    SetData(IntPtr, UInt32)

    Sets the buffer data via map/memcpy/unmap sequence. Always supported for dynamic buffers (other types support depends on graphics backend implementation).

    Declaration
    [Unmanaged]
    public void SetData(IntPtr data, uint size)
    Parameters
    System.IntPtr data

    The source data to upload.

    System.UInt32 size

    The size of data (in bytes).

    Unmap()

    Invalidates the mapped pointer to a resource and restores the GPU's access to that resource.

    Declaration
    [Unmanaged]
    public void Unmap()

    View()

    Gets the view for the whole buffer.

    Declaration
    [Unmanaged]
    public GPUBufferView View()
    Returns
    GPUBufferView

    Extension Methods

    Extensions.ReflectiveCompare<T>(T, T)
    Extensions.DeepClone<T>(T)
    Extensions.RawClone<T>(T)

    See Also

    GPUResource
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat