Helper class for organizing CPU -> GPU data synchronisation. In flight data is stored on host side, and copied to GPU right before being used.
More...
#include <foray_dualbuffer.hpp>
|
void | Create (core::Context *context, const core::ManagedBuffer::CreateInfo &devicebufferCreateInfo, uint32_t stageBufferCount=INFLIGHT_FRAME_COUNT) |
| Creates the dualbuffer setup.
|
|
virtual void | StageFullBuffer (uint32_t frameIndex, const void *data) |
| Updates the entire staging buffer.
|
|
virtual void | StageSection (uint32_t frameIndex, const void *data, size_t destOffset, size_t size) |
| Updates a section of a staging buffer.
|
|
virtual void | CmdCopyToDevice (uint32_t frameIndex, VkCommandBuffer cmdBuffer) |
| Writes commands required to copy the changes recorded in the indexed staging buffer to the device buffer.
|
|
virtual void | CmdPrepareForRead (VkCommandBuffer cmdBuffer, VkPipelineStageFlags2 dstStageMask, VkAccessFlags2 dstAccessMask) const |
| Prepares the device buffer for read access with a pipeline barrier (must be called before read access happens to the buffer)
|
|
virtual VkBufferMemoryBarrier2 | MakeBarrierPrepareForRead (VkPipelineStageFlags2 dstStageMask, VkAccessFlags2 dstAccessMask) const |
| Returns a barrier which prepares the device buffer for read access.
|
|
bool | Exists () const |
|
std::string | GetName () const |
|
DualBuffer & | SetName (std::string_view name) |
|
VkDescriptorBufferInfo | GetVkDescriptorInfo () const |
|
VkBuffer | GetDeviceVkBuffer () const |
|
void | Destroy () |
|
virtual | ~DualBuffer () |
|
| NoMoveDefaults ()=default |
|
| NoMoveDefaults (const NoMoveDefaults &other)=delete |
|
| NoMoveDefaults (NoMoveDefaults &&other)=default |
|
NoMoveDefaults & | operator= (const NoMoveDefaults &other)=delete |
|
|
std::vector< void * > | mStagingBufferMaps |
| Memory locations the permanently mapped staging buffers are mapped to.
|
|
std::vector< std::unique_ptr< core::ManagedBuffer > > | mStagingBuffers |
| Permanently mapped host-local staging buffers (one per frame in flight)
|
|
std::vector< std::vector< VkBufferCopy > > | mBufferCopies |
| Record of all buffer copies submitted. Added to when writing to staging buffers, cleared when building the commandbuffer.
|
|
core::ManagedBuffer | mDeviceBuffer |
| The buffer used by the device.
|
|
Helper class for organizing CPU -> GPU data synchronisation. In flight data is stored on host side, and copied to GPU right before being used.
Temporarily stores CPU-calculated states in staging buffers (1x per frame in flight) The GPU can retrieve the CPU-side data as needed via a copy command
Uploading Data
- Stage sections or full buffer
- Record CmdCopyToDevice
Reading data
- Record CmdPrepareForRead
- Access the buffer as you wish
◆ ~DualBuffer()
virtual foray::util::DualBuffer::~DualBuffer |
( |
| ) |
|
|
inlinevirtual |
◆ CmdCopyToDevice()
virtual void foray::util::DualBuffer::CmdCopyToDevice |
( |
uint32_t |
frameIndex, |
|
|
VkCommandBuffer |
cmdBuffer |
|
) |
| |
|
virtual |
Writes commands required to copy the changes recorded in the indexed staging buffer to the device buffer.
◆ CmdPrepareForRead()
virtual void foray::util::DualBuffer::CmdPrepareForRead |
( |
VkCommandBuffer |
cmdBuffer, |
|
|
VkPipelineStageFlags2 |
dstStageMask, |
|
|
VkAccessFlags2 |
dstAccessMask |
|
) |
| const |
|
virtual |
Prepares the device buffer for read access with a pipeline barrier (must be called before read access happens to the buffer)
◆ Create()
Creates the dualbuffer setup.
- Parameters
-
devicebufferCreateInfo | Used to initate the drawside buffer. Same size is used for staging buffers |
◆ Destroy()
void foray::util::DualBuffer::Destroy |
( |
| ) |
|
◆ Exists()
bool foray::util::DualBuffer::Exists |
( |
| ) |
const |
|
inline |
◆ GetDeviceVkBuffer()
VkBuffer foray::util::DualBuffer::GetDeviceVkBuffer |
( |
| ) |
const |
|
inline |
◆ GetName()
std::string foray::util::DualBuffer::GetName |
( |
| ) |
const |
|
inline |
◆ GetVkDescriptorInfo()
VkDescriptorBufferInfo foray::util::DualBuffer::GetVkDescriptorInfo |
( |
| ) |
const |
|
inline |
◆ MakeBarrierPrepareForRead()
virtual VkBufferMemoryBarrier2 foray::util::DualBuffer::MakeBarrierPrepareForRead |
( |
VkPipelineStageFlags2 |
dstStageMask, |
|
|
VkAccessFlags2 |
dstAccessMask |
|
) |
| const |
|
virtual |
Returns a barrier which prepares the device buffer for read access.
◆ SetName()
DualBuffer & foray::util::DualBuffer::SetName |
( |
std::string_view |
name | ) |
|
◆ StageFullBuffer()
virtual void foray::util::DualBuffer::StageFullBuffer |
( |
uint32_t |
frameIndex, |
|
|
const void * |
data |
|
) |
| |
|
virtual |
Updates the entire staging buffer.
◆ StageSection()
virtual void foray::util::DualBuffer::StageSection |
( |
uint32_t |
frameIndex, |
|
|
const void * |
data, |
|
|
size_t |
destOffset, |
|
|
size_t |
size |
|
) |
| |
|
virtual |
Updates a section of a staging buffer.
◆ mBufferCopies
std::vector<std::vector<VkBufferCopy> > foray::util::DualBuffer::mBufferCopies |
|
protected |
Record of all buffer copies submitted. Added to when writing to staging buffers, cleared when building the commandbuffer.
◆ mDeviceBuffer
The buffer used by the device.
◆ mStagingBufferMaps
std::vector<void*> foray::util::DualBuffer::mStagingBufferMaps |
|
protected |
Memory locations the permanently mapped staging buffers are mapped to.
◆ mStagingBuffers
Permanently mapped host-local staging buffers (one per frame in flight)
The documentation for this class was generated from the following file: