VMA-backed Vulkan buffer with staging uploads, batched copies, and a size-bucketed recycling pool.
More...
#include <VulkanBuffer.hpp>
|
| | VulkanBuffer (VkDevice device, VkPhysicalDevice physicalDevice, uint32_t size, BufferType type, VkCommandPool commandPool, VkQueue graphicsQueue) |
| | ~VulkanBuffer () override |
| void | Cleanup () override |
| void * | GetData () override |
| VkBuffer | GetVkBuffer () const |
| bool | Initialize (void *data) override |
| | Allocates the buffer (recycling a pooled one if a match exists) and uploads initial data, if any.
|
| bool | Map () override |
| | Maps host-visible memory for direct CPU writes.
|
| void | Unmap () override |
| void | Update () override |
| void | Update (void *data, size_t size) override |
| | Overwrites buffer contents, staging through a temporary buffer for device-local memory.
|
| const void * | GetCPUShadowCopy () const |
| size_t | GetCPUShadowCopySize () const |
| size_t | GetSize () |
| int | GetSlot () const |
| BufferType | GetType () |
| uint32_t | GetVertexFormat () const |
| | Registered custom vertex layout of this buffer; 0 means the engine default Vertex.
|
| void | SetSlot (int slot) |
| void | SetVertexFormat (uint32_t handle) |
| | Tags the buffer with a VertexFormatRegistry handle so backends pick the matching pipeline.
|
| void | StoreCPUShadowCopy (const void *data, size_t size) |
| | Copies up to 128 bytes into the inline shadow-copy storage, clamping oversized input.
|
| virtual | ~ResourceBase ()=default |
VMA-backed Vulkan buffer with staging uploads, batched copies, and a size-bucketed recycling pool.
Definition at line 13 of file VulkanBuffer.hpp.
◆ VulkanBuffer()
| Sleak::RenderEngine::VulkanBuffer::VulkanBuffer |
( |
VkDevice | device, |
|
|
VkPhysicalDevice | physicalDevice, |
|
|
uint32_t | size, |
|
|
BufferType | type, |
|
|
VkCommandPool | commandPool, |
|
|
VkQueue | graphicsQueue ) |
◆ ~VulkanBuffer()
| Sleak::RenderEngine::VulkanBuffer::~VulkanBuffer |
( |
| ) |
|
|
override |
◆ AdvanceDeletionFrame()
| void Sleak::RenderEngine::VulkanBuffer::AdvanceDeletionFrame |
( |
| ) |
|
|
inlinestatic |
◆ Cleanup()
| void Sleak::RenderEngine::VulkanBuffer::Cleanup |
( |
| ) |
|
|
overridevirtual |
Hands the GPU buffer to deferred deletion, which keeps it alive until every frame and upload batch that may reference it has completed.
Implements Sleak::ResourceBase.
Definition at line 342 of file VulkanBuffer.cpp.
◆ DestroyAllocator()
| void Sleak::RenderEngine::VulkanBuffer::DestroyAllocator |
( |
| ) |
|
|
static |
Destroys the staging pool and the allocator once every buffer is freed.
Definition at line 63 of file VulkanBuffer.cpp.
◆ DiscardPendingCopies()
| void Sleak::RenderEngine::VulkanBuffer::DiscardPendingCopies |
( |
| ) |
|
|
static |
Frees an upload batch that was recorded but never submitted, along with its staging buffers. Only valid while the device is idle.
Definition at line 578 of file VulkanBuffer.cpp.
◆ DumpPerFrameAllocStats()
| void Sleak::RenderEngine::VulkanBuffer::DumpPerFrameAllocStats |
( |
| ) |
|
|
static |
◆ FlushAllDeferredDeletions()
| void Sleak::RenderEngine::VulkanBuffer::FlushAllDeferredDeletions |
( |
| ) |
|
|
static |
◆ FlushPendingCopiesAsync()
◆ GetAllocator()
| VmaAllocator Sleak::RenderEngine::VulkanBuffer::GetAllocator |
( |
| ) |
|
|
inlinestatic |
◆ GetData()
| void * Sleak::RenderEngine::VulkanBuffer::GetData |
( |
| ) |
|
|
overridevirtual |
◆ GetDeviceLocalAllocatedBytes()
| VkDeviceSize Sleak::RenderEngine::VulkanBuffer::GetDeviceLocalAllocatedBytes |
( |
| ) |
|
|
static |
◆ GetDeviceLocalHeapSize()
| VkDeviceSize Sleak::RenderEngine::VulkanBuffer::GetDeviceLocalHeapSize |
( |
| ) |
|
|
static |
◆ GetTotalAllocatedBytes()
| VkDeviceSize Sleak::RenderEngine::VulkanBuffer::GetTotalAllocatedBytes |
( |
| ) |
|
|
static |
◆ GetVkBuffer()
| VkBuffer Sleak::RenderEngine::VulkanBuffer::GetVkBuffer |
( |
| ) |
const |
|
inline |
◆ InitAllocator()
| void Sleak::RenderEngine::VulkanBuffer::InitAllocator |
( |
VkInstance | instance, |
|
|
VkPhysicalDevice | physicalDevice, |
|
|
VkDevice | device ) |
|
static |
Creates the VMA allocator plus a staging pool whose blocks stay resident for the allocator's lifetime.
Definition at line 25 of file VulkanBuffer.cpp.
◆ Initialize()
| bool Sleak::RenderEngine::VulkanBuffer::Initialize |
( |
void * | data | ) |
|
|
overridevirtual |
◆ Map()
| bool Sleak::RenderEngine::VulkanBuffer::Map |
( |
| ) |
|
|
overridevirtual |
◆ ProcessDeferredDeletions()
| void Sleak::RenderEngine::VulkanBuffer::ProcessDeferredDeletions |
( |
uint32_t | maxFramesInFlight | ) |
|
|
static |
◆ SetBatchingEnabled()
| void Sleak::RenderEngine::VulkanBuffer::SetBatchingEnabled |
( |
bool | enabled | ) |
|
|
inlinestatic |
◆ SetPhysicalDevice()
| void Sleak::RenderEngine::VulkanBuffer::SetPhysicalDevice |
( |
VkPhysicalDevice | device | ) |
|
|
static |
◆ Unmap()
| void Sleak::RenderEngine::VulkanBuffer::Unmap |
( |
| ) |
|
|
overridevirtual |
◆ UntrackAllocation() [1/2]
| void Sleak::RenderEngine::VulkanBuffer::UntrackAllocation |
( |
VkDeviceSize | size | ) |
|
|
inlinestatic |
◆ UntrackAllocation() [2/2]
| void Sleak::RenderEngine::VulkanBuffer::UntrackAllocation |
( |
VkDeviceSize | size, |
|
|
uint32_t | memTypeIdx ) |
|
inlinestatic |
◆ Update() [1/2]
| void Sleak::RenderEngine::VulkanBuffer::Update |
( |
| ) |
|
|
overridevirtual |
◆ Update() [2/2]
| void Sleak::RenderEngine::VulkanBuffer::Update |
( |
void * | data, |
|
|
size_t | size ) |
|
overridevirtual |