#include <VulkanStagedBuffer.h>
|
| | StagedBuffer () |
| void | create (Engine::Core::ApplicationContext *context, VkDeviceSize size, VkBufferUsageFlags usage, bool persistentMapping=false) |
| | Creates the staged buffer with device and staging buffers.
|
| void | destroy () |
| StagedBufferSyncObjects | upload (const Engine::Core::ApplicationContext *context, const void *data, VkDeviceSize size) |
| StagedBufferSyncObjects | uploadPartial (const Engine::Core::ApplicationContext *context, const void *data, VkDeviceSize size, VkDeviceSize offset) |
| | Upload data to a specific offset in the buffer (for incremental updates)
|
| void | advanceStagingBuffer () |
| | Advance to next staging buffer for double-buffering. Call this at the start of each frame to ensure we don't overwrite staging data that a previous frame's transfer is still reading.
|
| bool | ensureSize (VkDeviceSize requiredSize, VkBufferUsageFlags usage) |
| | Ensures the buffer is at least the required size. If resizing is needed, the old buffers are moved to pending deletion rather than destroyed immediately.
|
| void | processPendingDeletions () |
| | Destroys all buffers that were pending deletion. Call this after all frames that might reference old buffers have completed.
|
| bool | hasPendingDeletions () const |
| | Checks if there are buffers pending deletion.
|
| const Vulkan::Buffer & | getBuffer () const |
| Vulkan::Buffer & | getBufferRef () |
| const Vulkan::Buffer & | getStagingBuffer () const |
| Vulkan::Buffer & | getStagingBufferRef () |
| VkDeviceSize | getSize () const |
| | Gets the current size of the device buffer.
|
| void | setDebugName (const std::string &name, std::optional< uint32_t > index=std::nullopt) |
|
| static constexpr uint32_t | STAGING_BUFFER_COUNT = 2 |
| | Number of staging buffers for multi-buffering (matches frames in flight)
|
Definition at line 21 of file VulkanStagedBuffer.h.
◆ StagedBuffer()
| Vulkan::StagedBuffer::StagedBuffer |
( |
| ) |
|
◆ advanceStagingBuffer()
| void Vulkan::StagedBuffer::advanceStagingBuffer |
( |
| ) |
|
|
inline |
◆ create()
Creates the staged buffer with device and staging buffers.
- Parameters
-
| context | Application context |
| size | Initial size in bytes |
| usage | Vulkan buffer usage flags |
| persistentMapping | If true, staging buffer stays mapped for faster uploads. Use for frequently updated buffers. Default is false for backwards compatibility. |
◆ destroy()
| void Vulkan::StagedBuffer::destroy |
( |
| ) |
|
◆ ensureSize()
| bool Vulkan::StagedBuffer::ensureSize |
( |
VkDeviceSize | requiredSize, |
|
|
VkBufferUsageFlags | usage ) |
Ensures the buffer is at least the required size. If resizing is needed, the old buffers are moved to pending deletion rather than destroyed immediately.
- Parameters
-
| requiredSize | Minimum required size in bytes |
| usage | Vulkan buffer usage flags |
- Returns
- true if the buffer was recreated (descriptor sets need updating)
◆ getBuffer()
◆ getBufferRef()
◆ getSize()
| VkDeviceSize Vulkan::StagedBuffer::getSize |
( |
| ) |
const |
|
nodiscard |
Gets the current size of the device buffer.
- Returns
- Buffer size in bytes, or 0 if not created
◆ getStagingBuffer()
| const Vulkan::Buffer & Vulkan::StagedBuffer::getStagingBuffer |
( |
| ) |
const |
|
inlinenodiscard |
◆ getStagingBufferRef()
◆ hasPendingDeletions()
| bool Vulkan::StagedBuffer::hasPendingDeletions |
( |
| ) |
const |
|
inlinenodiscard |
◆ processPendingDeletions()
| void Vulkan::StagedBuffer::processPendingDeletions |
( |
| ) |
|
Destroys all buffers that were pending deletion. Call this after all frames that might reference old buffers have completed.
◆ setDebugName()
| void Vulkan::StagedBuffer::setDebugName |
( |
const std::string & | name, |
|
|
std::optional< uint32_t > | index = std::nullopt ) |
◆ upload()
◆ uploadPartial()
Upload data to a specific offset in the buffer (for incremental updates)
- Parameters
-
| context | Application context |
| data | Pointer to data to upload |
| size | Size of data in bytes |
| offset | Offset into the device buffer where data should be written |
- Returns
- Sync objects for the transfer
◆ buffer
| std::optional<Buffer> Vulkan::StagedBuffer::buffer |
|
private |
◆ context_
◆ currentStagingIndex_
| uint32_t Vulkan::StagedBuffer::currentStagingIndex_ = 0 |
|
private |
◆ debugName_
| std::string Vulkan::StagedBuffer::debugName_ |
|
private |
◆ DELETION_DELAY_FRAMES
| uint32_t Vulkan::StagedBuffer::DELETION_DELAY_FRAMES = 6 |
|
staticconstexprprivate |
Number of frames to keep old buffers alive Must be > MAX_FRAMES_IN_FLIGHT to ensure GPU work completes before deletion. Using 6 to account for: 2 frames in flight + transfer/graphics queue depth + safety margin.
Definition at line 114 of file VulkanStagedBuffer.h.
◆ pendingDeletions
◆ STAGING_BUFFER_COUNT
| uint32_t Vulkan::StagedBuffer::STAGING_BUFFER_COUNT = 2 |
|
staticconstexpr |
◆ stagingBuffers_
◆ usePersistentMapping_
| bool Vulkan::StagedBuffer::usePersistentMapping_ = false |
|
private |
The documentation for this class was generated from the following file: