XII Release 0.1.0
Loading...
Searching...
No Matches
xiiVulkanMemoryAllocator Class Reference

Vulkan memory allocator wrapper. More...

#include <MemoryAllocatorVulkan.h>

Public Member Functions

vk::Result Initialize (xiiGALDeviceVulkan *pDeviceVulkan, xiiUInt32 uiPreferredBlockSize=0U)
 Constructs the memory allocator with Vulkan instance, physical device, and logical device.
 
void DeInitialize ()
 Cleans up internal resources.
 
vk::Result CreateBuffer (const vk::BufferCreateInfo &vkBufferCreateInfo, const xiiVulkanAllocationCreateInfo &allocationCreateInfo, vk::Buffer &out_buffer, xiiVulkanAllocation &out_allocation, xiiVulkanAllocationInfo *pAllocationInfo=nullptr) const
 Creates a Vulkan buffer and allocates memory for it.
 
void DestroyBuffer (vk::Buffer &vkBuffer, xiiVulkanAllocation &allocation) const
 Destroys a Vulkan buffer and frees its associated memory.
 
vk::Result CreateImage (const vk::ImageCreateInfo &vkImageCreateInfo, const xiiVulkanAllocationCreateInfo &allocationCreateInfo, vk::Image &out_image, xiiVulkanAllocation &out_allocation, xiiVulkanAllocationInfo *pAllocationInfo=nullptr) const
 Creates a Vulkan image and allocates memory for it.
 
void DestroyImage (vk::Image &vkImage, xiiVulkanAllocation &allocation) const
 Destroys a Vulkan image and frees its associated memory.
 
xiiVulkanAllocationInfo GetAllocationInfo (xiiVulkanAllocation allocation) const
 Retrieves detailed information about a memory allocation.
 
vk::MemoryPropertyFlags GetMemoryPropertyFlags (xiiVulkanAllocation allocation) const
 Returns the memory property flags for a given allocation.
 
void SetAllocationUserData (xiiVulkanAllocation allocation, const char *pUserData) const
 Sets user-defined metadata for a memory allocation.
 
vk::Result MapMemory (xiiVulkanAllocation allocation, void **pData) const
 Maps a memory allocation to a CPU-accessible pointer.
 
void UnmapMemory (xiiVulkanAllocation allocation) const
 Unmaps a previously mapped memory allocation.
 
vk::Result FlushAllocation (xiiVulkanAllocation allocation, vk::DeviceSize offset=0U, vk::DeviceSize size=vk::WholeSize) const
 Flushes a memory allocation to ensure GPU visibility.
 
vk::Result InvalidateAllocation (xiiVulkanAllocation allocation, vk::DeviceSize offset=0U, vk::DeviceSize size=vk::WholeSize) const
 Invalidates a memory allocation to ensure CPU visibility.
 
xiiVulkanMemoryStatistics GetStatistics () const
 Returns current memory usage statistics.
 

Detailed Description

Vulkan memory allocator wrapper.

Provides high-level allocation and resource management for Vulkan buffers and images. Internally wraps Vulkan Memory Allocator (VMA) or custom logic to simplify memory handling.

Member Function Documentation

◆ CreateBuffer()

vk::Result xiiVulkanMemoryAllocator::CreateBuffer ( const vk::BufferCreateInfo & vkBufferCreateInfo,
const xiiVulkanAllocationCreateInfo & allocationCreateInfo,
vk::Buffer & out_buffer,
xiiVulkanAllocation & out_allocation,
xiiVulkanAllocationInfo * pAllocationInfo = nullptr ) const

Creates a Vulkan buffer and allocates memory for it.

Parameters
vkBufferCreateInfo- Buffer creation parameters.
allocationCreateInfo- Allocation configuration.
out_buffer- Output buffer handle.
out_allocation- Output allocation handle.
pAllocationInfo- Optional pointer to receive detailed allocation info.

◆ CreateImage()

vk::Result xiiVulkanMemoryAllocator::CreateImage ( const vk::ImageCreateInfo & vkImageCreateInfo,
const xiiVulkanAllocationCreateInfo & allocationCreateInfo,
vk::Image & out_image,
xiiVulkanAllocation & out_allocation,
xiiVulkanAllocationInfo * pAllocationInfo = nullptr ) const

Creates a Vulkan image and allocates memory for it.

Parameters
vkImageCreateInfo- Image creation parameters.
allocationCreateInfo- Allocation configuration.
out_image- Output image handle.
out_allocation- Output allocation handle.
pAllocationInfo- Optional pointer to receive detailed allocation info.

◆ DestroyBuffer()

void xiiVulkanMemoryAllocator::DestroyBuffer ( vk::Buffer & vkBuffer,
xiiVulkanAllocation & allocation ) const

Destroys a Vulkan buffer and frees its associated memory.

Parameters
vkBuffer- Buffer to destroy.
allocation- Allocation handle to free.

◆ DestroyImage()

void xiiVulkanMemoryAllocator::DestroyImage ( vk::Image & vkImage,
xiiVulkanAllocation & allocation ) const

Destroys a Vulkan image and frees its associated memory.

Parameters
vkImage- Image to destroy.
allocation- Allocation handle to free.

◆ FlushAllocation()

vk::Result xiiVulkanMemoryAllocator::FlushAllocation ( xiiVulkanAllocation allocation,
vk::DeviceSize offset = 0U,
vk::DeviceSize size = vk::WholeSize ) const

Flushes a memory allocation to ensure GPU visibility.

Parameters
allocation- Allocation handle.
offset- Byte offset to flush from.
size- Number of bytes to flush.
Returns
Vulkan result code.

◆ GetAllocationInfo()

xiiVulkanAllocationInfo xiiVulkanMemoryAllocator::GetAllocationInfo ( xiiVulkanAllocation allocation) const

Retrieves detailed information about a memory allocation.

Parameters
allocation- Allocation handle.
Returns
Allocation metadata including offset, size, and mapped pointer.

◆ GetMemoryPropertyFlags()

vk::MemoryPropertyFlags xiiVulkanMemoryAllocator::GetMemoryPropertyFlags ( xiiVulkanAllocation allocation) const

Returns the memory property flags for a given allocation.

Parameters
allocation- Allocation handle.
Returns
Vulkan memory property flags (e.g., host-visible, coherent).

◆ GetStatistics()

xiiVulkanMemoryStatistics xiiVulkanMemoryAllocator::GetStatistics ( ) const

Returns current memory usage statistics.

Returns
Struct containing block and allocation counts and sizes.

◆ Initialize()

vk::Result xiiVulkanMemoryAllocator::Initialize ( xiiGALDeviceVulkan * pDeviceVulkan,
xiiUInt32 uiPreferredBlockSize = 0U )

Constructs the memory allocator with Vulkan instance, physical device, and logical device.

Parameters
pDeviceVulkan- The Vulkan device implementation.
uiPreferredBlockSize- Optional preferred block size for allocations.

◆ InvalidateAllocation()

vk::Result xiiVulkanMemoryAllocator::InvalidateAllocation ( xiiVulkanAllocation allocation,
vk::DeviceSize offset = 0U,
vk::DeviceSize size = vk::WholeSize ) const

Invalidates a memory allocation to ensure CPU visibility.

Parameters
allocation- Allocation handle.
offset- Byte offset to invalidate from.
size- Number of bytes to invalidate.
Returns
Vulkan result code.

◆ MapMemory()

vk::Result xiiVulkanMemoryAllocator::MapMemory ( xiiVulkanAllocation allocation,
void ** pData ) const

Maps a memory allocation to a CPU-accessible pointer.

Parameters
allocation- Allocation handle.
pData- Output pointer to mapped memory.
Returns
Vulkan result code.

◆ SetAllocationUserData()

void xiiVulkanMemoryAllocator::SetAllocationUserData ( xiiVulkanAllocation allocation,
const char * pUserData ) const

Sets user-defined metadata for a memory allocation.

Parameters
allocation- Allocation handle.
pUserDataPointer to user data string.

◆ UnmapMemory()

void xiiVulkanMemoryAllocator::UnmapMemory ( xiiVulkanAllocation allocation) const

Unmaps a previously mapped memory allocation.

Parameters
allocation- Allocation handle.

The documentation for this class was generated from the following files: