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
    Object
    ScriptingObject
    GPUResource
    GPUBuffer
    Inherited Members
    ScriptingObject::_gcHandle
    ScriptingObject::_id
    GPUResource::_memoryUsage
    GPUResource::_nameCapacity
    GPUResource::_namePtr
    GPUResource::_nameSize
    ScriptingObject::_type
    ScriptingObject::CanCast(const ScriptingTypeHandle& from, const ScriptingTypeHandle& to)
    ScriptingObject::CanCast(const MClass* from, const MClass* to)
    ScriptingObject::Cast(ScriptingObject* obj)
    ScriptingObject::ChangeID(const Guid& newId)
    ScriptingObject::CreateManaged()
    ScriptingObject::CreateManagedInternal()
    ScriptingObject::Deleted
    Object::DeleteObject(float timeToLive = 0.0f, bool useGameTime=false)
    Object::DeleteObjectNow()
    ScriptingObject::DestroyManaged()
    Object::Flags
    ScriptingObject::FromInterface(void* interfaceObj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::FromInterface(T* interfaceObj)
    ScriptingObject::GetClass()
    ScriptingObject::GetID()
    ScriptingObject::GetManagedInstance()
    GPUResource::GetMemoryUsage()
    GPUResource::GetName()
    ScriptingObject::GetOrCreateManagedInstance()
    ScriptingObject::GetType()
    ScriptingObject::GetTypeHandle()
    GPUResource::GPUResource()
    GPUResource::GPUResource(const SpawnParams& params)
    ScriptingObject::HasManagedInstance()
    ScriptingObject::Is(const ScriptingTypeHandle& type)
    ScriptingObject::Is(const MClass* type)
    ScriptingObject::Is()
    ScriptingObject::IsRegistered()
    GPUResource::LastRenderTime
    ScriptingObject::NewObject(const ScriptingTypeHandle& typeHandle)
    ScriptingObject::NewObject()
    GPUResource::OnDeleteObject()
    GPUResource::OnDeviceDispose()
    ScriptingObject::OnManagedInstanceDeleted()
    ScriptingObject::OnScriptingDispose()
    ScriptingObject::RegisterObject()
    GPUResource::ReleaseGPU()
    GPUResource::Releasing
    ScriptingObject::ScriptingObject(const SpawnParams& params)
    ScriptingObject::SetManagedInstance(MObject* instance)
    GPUResource::SetName(const StringView& name)
    GPUBuffer
    ScriptingObject::ToInterface(ScriptingObject* obj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::ToInterface(ScriptingObject* obj)
    ScriptingObject::ToManaged(const ScriptingObject* obj)
    ScriptingObject::ToNative(MObject* obj)
    ScriptingObject::UnregisterObject()
    GPUResource::~GPUResource()
    Object::~Object()
    ScriptingObject::~ScriptingObject()
    Assembly: FlaxEngine.dll
    File: Engine/Graphics/GPUBuffer.h
    Syntax
    public class GPUBuffer : public GPUResource

    Constructors

    GPUBuffer()

    Declaration
    protected GPUBuffer()

    Fields

    _desc

    Declaration
    protected GPUBufferDescription _desc
    Field Value
    GPUBufferDescription

    _isLocked

    Declaration
    protected bool _isLocked = false
    Field Value
    bool

    Methods

    DownloadData(BytesContainer& result)

    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
    public bool DownloadData(BytesContainer& result)
    Parameters
    BytesContainer result

    The result data.

    Returns
    bool

    True if cannot download data, otherwise false.

    DownloadDataAsync(BytesContainer& result)

    Creates GPU async task that will gather buffer data from the GPU.

    Declaration
    public Task* DownloadDataAsync(BytesContainer& result)
    Parameters
    BytesContainer result

    The result data.

    Returns
    Task

    Download data task (not started yet).

    GetData(BytesContainer& output)

    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
    public bool GetData(BytesContainer& output)
    Parameters
    BytesContainer output

    The output data container.

    Returns
    bool

    True if failed, otherwise false.

    GetDescription()

    Gets buffer description structure.

    Declaration
    public GPUBufferDescription GetDescription() const
    Returns
    GPUBufferDescription

    GetElementsCount()

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

    Declaration
    public uint32 GetElementsCount() const
    Returns
    uint32

    GetFlags()

    Gets buffer flags.

    Declaration
    public GPUBufferFlags GetFlags() const
    Returns
    GPUBufferFlags

    GetFormat()

    Gets buffer data format (if used).

    Declaration
    public PixelFormat GetFormat() const
    Returns
    PixelFormat

    GetResourceType()

    Gets the GPU resource type.

    Declaration
    public virtual GPUResourceType GetResourceType() const final override
    Returns
    GPUResourceType

    Overrides
    GPUResource::GetResourceType()

    GetSize()

    Gets buffer size in bytes.

    Declaration
    public uint32 GetSize() const
    Returns
    uint32

    GetStride()

    Gets buffer stride in bytes.

    Declaration
    public uint32 GetStride() const
    Returns
    uint32

    GetVertexLayout()

    Gets vertex elements layout used by vertex buffers only.

    Declaration
    public GPUVertexLayout* GetVertexLayout() const
    Returns
    GPUVertexLayout

    Init(const GPUBufferDescription& desc)

    Creates new buffer.

    Declaration
    public bool Init(const GPUBufferDescription& desc)
    Parameters
    GPUBufferDescription desc

    The buffer description.

    Returns
    bool

    True if cannot create buffer, otherwise false.

    IsAllocated()

    Gets a value indicating whether this buffer has been allocated.

    Declaration
    public bool IsAllocated() const
    Returns
    bool

    IsDynamic()

    Checks if buffer is a dynamic buffer.

    Declaration
    public bool IsDynamic() const
    Returns
    bool

    IsShaderResource()

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

    Declaration
    public bool IsShaderResource() const
    Returns
    bool

    IsStaging()

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

    Declaration
    public bool IsStaging() const
    Returns
    bool

    IsUnorderedAccess()

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

    Declaration
    public bool IsUnorderedAccess() const
    Returns
    bool

    Map(GPUResourceMapMode mode)

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

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

    Declaration
    public virtual void* Map(GPUResourceMapMode mode) = 0
    Parameters
    GPUResourceMapMode mode

    The map operation mode.

    Returns
    void

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

    OnInit()

    Declaration
    protected virtual bool OnInit() = 0
    Returns
    bool

    OnReleaseGPU()

    Releases GPU resource data (implementation).

    Declaration
    protected virtual void OnReleaseGPU() override
    Overrides
    GPUResource::OnReleaseGPU()

    Resize(uint32 newSize)

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

    Declaration
    public bool Resize(uint32 newSize)
    Parameters
    uint32 newSize

    The new size (in bytes).

    Returns
    bool

    True if cannot resize buffer, otherwise false.

    SetData(const void* data, uint32 size)

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

    Declaration
    public void SetData(const void* data, uint32 size)
    Parameters
    void data

    The source data to upload.

    uint32 size

    The size of data (in bytes).

    ToStagingReadback()

    Creates new staging readback buffer with the same dimensions and properties as a source buffer (but without a data transferred; warning: caller must delete object).

    Declaration
    public GPUBuffer* ToStagingReadback() const
    Returns
    GPUBuffer

    Staging readback buffer.

    ToStagingUpload()

    Creates new staging upload buffer with the same dimensions and properties as a source buffer (but without a data transferred; warning: caller must delete object).

    Declaration
    public GPUBuffer* ToStagingUpload() const
    Returns
    GPUBuffer

    Staging upload buffer.

    ToString()

    Gets the string representation of this object.

    Declaration
    public virtual String ToString() const override
    Returns
    String

    Overrides
    Object::ToString()

    Unmap()

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

    Declaration
    public virtual void Unmap() = 0

    View()

    Gets the view for the whole buffer.

    Declaration
    public virtual GPUBufferView* View() const = 0
    Returns
    GPUBufferView

    See Also

    GPUResource
    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat