NAP
Public Member Functions | Public Attributes | List of all members
GPUBufferNumeric Class Reference

#include <gpubuffer.h>

Public Member Functions

 GPUBufferNumeric (Core &core, VkFormat format, uint32 elementSize)
 
 GPUBufferNumeric (Core &core, VkFormat format, uint32 elementSize, EMemoryUsage usage)
 
virtual uint getCount () const override
 
virtual uint32 getElementSize () const override
 
virtual size_t getSize () const override
 
virtual VkFormat getFormat () const
 
virtual void setCount (uint32 count)
 
virtual bool setData (const void *data, size_t elementCount, size_t reservedElementCount, utility::ErrorState &errorState)
 
- Public Member Functions inherited from GPUBuffer
 GPUBuffer (Core &core)
 
 GPUBuffer (Core &core, EMemoryUsage usage)
 
virtual ~GPUBuffer ()
 
virtual VkBuffer getBuffer () const
 
virtual const BufferDatagetBufferData () const
 
virtual bool init (utility::ErrorState &errorState) override
 
virtual VkBufferUsageFlags getBufferUsageFlags () const
 
void ensureUsage (VkBufferUsageFlags usage)
 
virtual bool isInitialized () const =0
 
void asyncGetData (std::function< void(const void *, size_t)> copyFunction)
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

uint32 mCount = 0
 Property: 'Count' The number of elements to initialize/allocate the buffer with. More...
 
- Public Attributes inherited from GPUBuffer
nap::Signal bufferChanged
 
EMemoryUsage mMemoryUsage = EMemoryUsage::Static
 Property 'Usage' How the buffer is used: initialized once (Static), updated frequently from CPU to GPU (DynamicWrite) or read from GPU to CPU (DynamicRead). More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 
- Protected Member Functions inherited from GPUBuffer
bool allocateInternal (size_t size, utility::ErrorState &errorState)
 
bool setDataInternal (const void *data, size_t size, size_t reservedSize, utility::ErrorState &errorState)
 
void requestClear ()
 
- Protected Attributes inherited from GPUBuffer
RenderServicemRenderService = nullptr
 Handle to the render service. More...
 
std::vector< BufferDatamRenderBuffers
 Render accessible buffers. More...
 
std::vector< BufferDatamStagingBuffers
 Staging buffers, used when uploading or downloading data. More...
 
uint32 mSize = 0
 Current used buffer size in bytes. More...
 
int mCurrentRenderBufferIndex = 0
 Current render buffer index. More...
 
int mCurrentStagingBufferIndex = 0
 Current staging buffer index. More...
 
std::vector< int > mDownloadStagingBufferIndices
 Staging buffer indices associated with a frameindex. More...
 

Description

Base interface for all types of one dimensional GPU buffers. Supported values for child classes such as GPUBufferNumeric<T> must be primitives that can be mapped to VkFormat. This is enforced by the requirement to implement getFormat().

Inheritance diagram for GPUBufferNumeric:
[legend]
Collaboration diagram for GPUBufferNumeric:
[legend]

Constructor & Destructor Documentation

◆ GPUBufferNumeric() [1/2]

GPUBufferNumeric ( Core core,
VkFormat  format,
uint32  elementSize 
)
Parameters
corecore reference
formatVulkan memory format
elementSizeof a single element in bytes

◆ GPUBufferNumeric() [2/2]

GPUBufferNumeric ( Core core,
VkFormat  format,
uint32  elementSize,
EMemoryUsage  usage 
)
Parameters
corecore reference
formatVulkan memory format
elementSizeof a single element in bytes
usageCPU-GPU usage

Member Function Documentation

◆ getCount()

virtual uint getCount ( ) const
overridevirtual
Returns
the number of buffer values

Implements GPUBuffer.

◆ getElementSize()

virtual uint32 getElementSize ( ) const
overridevirtual
Returns
the size in bytes of a single vertex element

Implements GPUBuffer.

◆ getFormat()

virtual VkFormat getFormat ( ) const
virtual
Returns
the buffer format

◆ getSize()

virtual size_t getSize ( ) const
overridevirtual
Returns
the size of the buffer in bytes

Implements GPUBuffer.

◆ setCount()

virtual void setCount ( uint32  count)
virtual

Sets the number of elements this buffer will contain

Parameters
countnew number of elements

◆ setData()

virtual bool setData ( const void *  data,
size_t  elementCount,
size_t  reservedElementCount,
utility::ErrorState errorState 
)
virtual

Uploads data to the GPU based on the settings provided. This function automatically allocates GPU memory if required.

Parameters
datapointer to the block of data that needs to be uploaded.
elementCountthe number of elements
reservedElementCountthe number of elements to reserve
errorStatecontains the error if upload operation failed
Returns
if upload succeeded

Member Data Documentation

◆ mCount

uint32 mCount = 0

Property: 'Count' The number of elements to initialize/allocate the buffer with.