Loading...
Searching...
No Matches
HgiBuffer Class Referenceabstract

Represents a graphics platform independent GPU buffer resource (base class). More...

#include <buffer.h>

+ Inheritance diagram for HgiBuffer:

Public Member Functions

HGI_API HgiBufferDesc const & GetDescriptor () const
 The descriptor describes the object.
 
virtual HGI_API size_t GetByteSizeOfResource () const =0
 Returns the byte size of the GPU buffer.
 
virtual HGI_API uint64_t GetRawResource () const =0
 This function returns the handle to the Hgi backend's gpu resource, cast to a uint64_t.
 
virtual HGI_API void * GetCPUStagingAddress ()=0
 Returns the 'staging area' in which new buffer data is copied before it is flushed to GPU.
 

Protected Member Functions

HGI_API HgiBuffer (HgiBufferDesc const &desc)
 

Protected Attributes

HgiBufferDesc _descriptor
 

Detailed Description

Represents a graphics platform independent GPU buffer resource (base class).

Buffers should be created via Hgi::CreateBuffer. The fill the buffer with data you supply initialData in the descriptor. To update the data inside the buffer later on, use blitCmds.

Definition at line 98 of file buffer.h.

Member Function Documentation

◆ GetByteSizeOfResource()

virtual HGI_API size_t GetByteSizeOfResource ( ) const
pure virtual

Returns the byte size of the GPU buffer.

This can be helpful if the application wishes to tally up memory usage.

Implemented in HgiGLBuffer.

◆ GetCPUStagingAddress()

virtual HGI_API void * GetCPUStagingAddress ( )
pure virtual

Returns the 'staging area' in which new buffer data is copied before it is flushed to GPU.

Some implementations (e.g. Metal) may have build in support for queueing up CPU->GPU copies. Those implementations can return the CPU pointer to the buffer's content directly. The caller should not assume that the data from the CPU staging area is automatically flushed to the GPU. Instead, after copying is finished, the caller should use BlitCmds CopyBufferCpuToGpu to ensure the transfer from the staging area to the GPU is scheduled.

Implemented in HgiGLBuffer.

◆ GetDescriptor()

HGI_API HgiBufferDesc const & GetDescriptor ( ) const

The descriptor describes the object.

◆ GetRawResource()

virtual HGI_API uint64_t GetRawResource ( ) const
pure virtual

This function returns the handle to the Hgi backend's gpu resource, cast to a uint64_t.

Clients should avoid using this function and instead use Hgi base classes so that client code works with any Hgi platform. For transitioning code to Hgi, it can however we useful to directly access a platform's internal resource handles. There is no safety provided in using this. If you by accident pass a HgiMetal resource into an OpenGL call, bad things may happen. In OpenGL this returns the GLuint resource name. In Metal this returns the id<MTLBuffer> as uint64_t. In Vulkan this returns the VkBuffer as uint64_t. In DX12 this returns the ID3D12Resource pointer as uint64_t.

Implemented in HgiGLBuffer.

Member Data Documentation

◆ _descriptor

HgiBufferDesc _descriptor
protected

Definition at line 143 of file buffer.h.


The documentation for this class was generated from the following file: