SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Sleak::RenderEngine::VulkanBuffer Class Reference

VMA-backed Vulkan buffer with staging uploads, batched copies, and a size-bucketed recycling pool. More...

#include <VulkanBuffer.hpp>

Inheritance diagram for Sleak::RenderEngine::VulkanBuffer:

Classes

struct  AsyncFlushResult
 Result of an async batched flush: the recorded command buffer plus staging resources to free later. More...
struct  PendingStagingCleanup
 A staging buffer awaiting release once its async copy has completed. More...

Public Member Functions

 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.
Public Member Functions inherited from Sleak::RenderEngine::BufferBase
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.
Public Member Functions inherited from Sleak::ResourceBase
virtual ~ResourceBase ()=default

Static Public Member Functions

static void AdvanceDeletionFrame ()
static void DestroyAllocator ()
static void DumpPerFrameAllocStats ()
static void FlushAllDeferredDeletions ()
static void FlushPendingCopies ()
static AsyncFlushResult FlushPendingCopiesAsync (VkSemaphore signalSemaphore)
static VmaAllocator GetAllocator ()
static VkDeviceSize GetDeviceLocalAllocatedBytes ()
static VkDeviceSize GetDeviceLocalHeapSize ()
static VkDeviceSize GetTotalAllocatedBytes ()
static void InitAllocator (VkInstance instance, VkPhysicalDevice physicalDevice, VkDevice device)
static void ProcessDeferredDeletions (uint32_t maxFramesInFlight)
static void SetBatchingEnabled (bool enabled)
static void SetPhysicalDevice (VkPhysicalDevice device)
static void UntrackAllocation (VkDeviceSize size)
static void UntrackAllocation (VkDeviceSize size, uint32_t memTypeIdx)

Additional Inherited Members

Protected Attributes inherited from Sleak::RenderEngine::BufferBase
bool bIsMapped = false
void * Data = nullptr
const void * m_cpuShadowCopy = nullptr
size_t m_cpuShadowCopySize = 0
char m_cpuShadowStorage [128] = {}
uint32_t m_vertexFormat = 0
size_t Size = 0
int Slot = 0
BufferType Type
Protected Attributes inherited from Sleak::ResourceBase
bool bIsInitialized
std::string Name

Detailed Description

VMA-backed Vulkan buffer with staging uploads, batched copies, and a size-bucketed recycling pool.

Definition at line 13 of file VulkanBuffer.hpp.

Constructor & Destructor Documentation

◆ VulkanBuffer()

Sleak::RenderEngine::VulkanBuffer::VulkanBuffer ( VkDevice device,
VkPhysicalDevice physicalDevice,
uint32_t size,
BufferType type,
VkCommandPool commandPool,
VkQueue graphicsQueue )

Definition at line 94 of file VulkanBuffer.cpp.

◆ ~VulkanBuffer()

Sleak::RenderEngine::VulkanBuffer::~VulkanBuffer ( )
override

Definition at line 105 of file VulkanBuffer.cpp.

Member Function Documentation

◆ AdvanceDeletionFrame()

void Sleak::RenderEngine::VulkanBuffer::AdvanceDeletionFrame ( )
inlinestatic

Definition at line 163 of file VulkanBuffer.hpp.

◆ Cleanup()

void Sleak::RenderEngine::VulkanBuffer::Cleanup ( )
overridevirtual

Implements Sleak::ResourceBase.

Definition at line 308 of file VulkanBuffer.cpp.

◆ DestroyAllocator()

void Sleak::RenderEngine::VulkanBuffer::DestroyAllocator ( )
static

Definition at line 33 of file VulkanBuffer.cpp.

◆ DumpPerFrameAllocStats()

void Sleak::RenderEngine::VulkanBuffer::DumpPerFrameAllocStats ( )
static

Definition at line 803 of file VulkanBuffer.cpp.

◆ FlushAllDeferredDeletions()

void Sleak::RenderEngine::VulkanBuffer::FlushAllDeferredDeletions ( )
static

Definition at line 779 of file VulkanBuffer.cpp.

◆ FlushPendingCopies()

void Sleak::RenderEngine::VulkanBuffer::FlushPendingCopies ( )
static

Definition at line 546 of file VulkanBuffer.cpp.

◆ FlushPendingCopiesAsync()

VulkanBuffer::AsyncFlushResult Sleak::RenderEngine::VulkanBuffer::FlushPendingCopiesAsync ( VkSemaphore signalSemaphore)
static

Definition at line 582 of file VulkanBuffer.cpp.

◆ GetAllocator()

VmaAllocator Sleak::RenderEngine::VulkanBuffer::GetAllocator ( )
inlinestatic

Definition at line 40 of file VulkanBuffer.hpp.

◆ GetData()

void * Sleak::RenderEngine::VulkanBuffer::GetData ( )
overridevirtual

Implements Sleak::RenderEngine::BufferBase.

Definition at line 370 of file VulkanBuffer.cpp.

◆ GetDeviceLocalAllocatedBytes()

VkDeviceSize Sleak::RenderEngine::VulkanBuffer::GetDeviceLocalAllocatedBytes ( )
static

Definition at line 835 of file VulkanBuffer.cpp.

◆ GetDeviceLocalHeapSize()

VkDeviceSize Sleak::RenderEngine::VulkanBuffer::GetDeviceLocalHeapSize ( )
static

Definition at line 805 of file VulkanBuffer.cpp.

◆ GetTotalAllocatedBytes()

VkDeviceSize Sleak::RenderEngine::VulkanBuffer::GetTotalAllocatedBytes ( )
static

Definition at line 799 of file VulkanBuffer.cpp.

◆ GetVkBuffer()

VkBuffer Sleak::RenderEngine::VulkanBuffer::GetVkBuffer ( ) const
inline

Definition at line 33 of file VulkanBuffer.hpp.

◆ InitAllocator()

void Sleak::RenderEngine::VulkanBuffer::InitAllocator ( VkInstance instance,
VkPhysicalDevice physicalDevice,
VkDevice device )
static

Definition at line 18 of file VulkanBuffer.cpp.

◆ Initialize()

bool Sleak::RenderEngine::VulkanBuffer::Initialize ( void * data)
overridevirtual

Allocates the buffer (recycling a pooled one if a match exists) and uploads initial data, if any.

Implements Sleak::ResourceBase.

Definition at line 109 of file VulkanBuffer.cpp.

◆ Map()

bool Sleak::RenderEngine::VulkanBuffer::Map ( )
overridevirtual

Maps host-visible memory for direct CPU writes.

Implements Sleak::RenderEngine::BufferBase.

Definition at line 345 of file VulkanBuffer.cpp.

◆ ProcessDeferredDeletions()

void Sleak::RenderEngine::VulkanBuffer::ProcessDeferredDeletions ( uint32_t maxFramesInFlight)
static

Definition at line 630 of file VulkanBuffer.cpp.

◆ SetBatchingEnabled()

void Sleak::RenderEngine::VulkanBuffer::SetBatchingEnabled ( bool enabled)
inlinestatic

Definition at line 66 of file VulkanBuffer.hpp.

◆ SetPhysicalDevice()

void Sleak::RenderEngine::VulkanBuffer::SetPhysicalDevice ( VkPhysicalDevice device)
static

Definition at line 821 of file VulkanBuffer.cpp.

◆ Unmap()

void Sleak::RenderEngine::VulkanBuffer::Unmap ( )
overridevirtual

Implements Sleak::RenderEngine::BufferBase.

Definition at line 358 of file VulkanBuffer.cpp.

◆ UntrackAllocation() [1/2]

void Sleak::RenderEngine::VulkanBuffer::UntrackAllocation ( VkDeviceSize size)
inlinestatic

Definition at line 170 of file VulkanBuffer.hpp.

◆ UntrackAllocation() [2/2]

void Sleak::RenderEngine::VulkanBuffer::UntrackAllocation ( VkDeviceSize size,
uint32_t memTypeIdx )
inlinestatic

Definition at line 171 of file VulkanBuffer.hpp.

◆ Update() [1/2]

void Sleak::RenderEngine::VulkanBuffer::Update ( )
overridevirtual

Implements Sleak::RenderEngine::BufferBase.

Definition at line 267 of file VulkanBuffer.cpp.

◆ Update() [2/2]

void Sleak::RenderEngine::VulkanBuffer::Update ( void * data,
size_t size )
overridevirtual

Overwrites buffer contents, staging through a temporary buffer for device-local memory.

Implements Sleak::RenderEngine::BufferBase.

Definition at line 272 of file VulkanBuffer.cpp.