#include <gpubuffer.h>
Public Member Functions | |
VertexBuffer (Core &core) | |
VertexBuffer (Core &core, EMemoryUsage usage, bool storage) | |
virtual bool | init (utility::ErrorState &errorState) override |
![]() | |
TypedGPUBufferNumeric (Core &core) | |
TypedGPUBufferNumeric (Core &core, EMemoryUsage usage, bool storage) | |
bool | setData (const std::vector< T > &data, utility::ErrorState &errorState) |
virtual bool | isInitialized () const override |
![]() | |
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) |
![]() | |
GPUBuffer (Core &core) | |
GPUBuffer (Core &core, EMemoryUsage usage) | |
virtual | ~GPUBuffer () |
virtual VkBuffer | getBuffer () const |
virtual const BufferData & | getBufferData () const |
virtual VkBufferUsageFlags | getBufferUsageFlags () const |
void | ensureUsage (VkBufferUsageFlags usage) |
void | asyncGetData (std::function< void(const void *, size_t)> copyFunction) |
![]() | |
Resource () | |
![]() | |
Object () | |
virtual | ~Object () |
virtual void | onDestroy () |
Object (Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&)=delete | |
Object & | operator= (Object &&)=delete |
Additional Inherited Members | |
![]() | |
static bool | isIDProperty (rtti::Instance &object, const rtti::Property &property) |
![]() | |
bool | mClear = false |
Property: 'Clear' If no fill policy is set, performs an initial clear-to-zero transfer operation on the device buffer on init(). More... | |
ResourcePtr< FillPolicy< T > > | mFillPolicy = nullptr |
Property: 'FillPolicy' Optional fill policy to fill the buffer with on initialization. More... | |
![]() | |
uint32 | mCount = 0 |
Property: 'Count' The number of elements to initialize/allocate the buffer with. More... | |
![]() | |
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... | |
![]() | |
std::string | mID |
Property: 'mID' unique name of the object. Used as an identifier by the system. More... | |
![]() | |
bool | allocateInternal (size_t size, utility::ErrorState &errorState) |
bool | setDataInternal (const void *data, size_t size, size_t reservedSize, utility::ErrorState &errorState) |
void | requestClear () |
![]() | |
RenderService * | mRenderService = nullptr |
Handle to the render service. More... | |
std::vector< BufferData > | mRenderBuffers |
Render accessible buffers. More... | |
std::vector< BufferData > | mStagingBuffers |
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... | |
Vertex GPU buffers.
Allocates all required host (staging) and device buffers based on the specified properties. If a 'FillPolicy' is available, the buffer will also be uploaded to immediately. Alternatively, 'Clear' sets all of the buffer values to zero on init(). 'FillPolicy' and 'Clear' are mutually exclusive and the former has priority over the latter.
In addition to nap::GPUBufferNumeric, this class distinguishes vertex buffers from general purpose numeric buffers. Internally, some flags are stored that help the driver identify and optimize buffers that have a specific purpose in a rendering operation. They also play a role in synchronization of compute and graphics operations.
This buffer (when 'storage' is set to 'true' on construction) can be bound to a descriptor in a shader. This allows the buffer be read and set inside a shader program.
Supported types are primitive types that can be mapped to VkFormat.
T | primitive value data type |
VertexBuffer | ( | Core & | core | ) |
Every vertex buffer needs to have access to the render engine.
core | reference to core |
VertexBuffer | ( | Core & | core, |
EMemoryUsage | usage, | ||
bool | storage | ||
) |
Every vertex buffer needs to have access to the render engine. The given 'usage' controls if a buffer can be updated more than once, and in which memory space it is placed. The given 'storage' controls if the buffer can be bound to a shader using a descriptor, allowing it be read / set inside a shader.
core | reference to core |
usage | how the buffer is used at runtime. |
storage | if the buffer is allowed to be bound to a shader as a storage buffer using a descriptor |
|
overridevirtual |
Initialize this buffer. This will allocate all required staging and device buffers based on the buffer properties. If a fill policy is available, the buffer will also be uploaded to immediately.
errorState | contains the error if initialization fails |
Reimplemented from TypedGPUBufferNumeric< T >.