HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VE_MemoryAllocator Class Reference

#include <VE_Memory.h>

+ Inheritance diagram for VE_MemoryAllocator:

Public Member Functions

const
VkPhysicalDeviceMemoryProperties
physicalDeviceMemoryProperties () const
 
UT_Array< VmaBudget > heapInfos () const
 
void printMemoryInfo () const
 
void printMemoryInfo (std::ostream *out=nullptr) const
 
void getMemoryUsage (exint *out_device_vma_alloc_size, exint *out_device_vk_alloc_size, exint *out_device_total_size, exint *out_shared_vma_alloc_size, exint *out_shared_vk_alloc_size, exint *out_shared_total_size) const
 
VE_Result< VE_MemoryallocateImage (VE_MemType type, const VkImageCreateInfo &img_info, VkImage &vk_img)
 
VE_Result< VE_MemoryallocateBuffer (VE_MemType type, const VkBufferCreateInfo &buf_info, VkBuffer &vk_buf)
 
VE_Result< VE_MemoryallocateMemory (VE_MemType type, const VkMemoryRequirements &info)
 
 VE_MemoryAllocator ()=default
 
 ~VE_MemoryAllocator ()
 
 UT_NON_COPYABLE (VE_MemoryAllocator)
 
 VE_MemoryAllocator (VE_MemoryAllocator &&other) noexcept
 
VE_MemoryAllocatoroperator= (VE_MemoryAllocator &&other) noexcept
 

Static Public Member Functions

static VE_Result
< VE_MemoryAllocator
create (VkInstance, VkPhysicalDevice, VkDevice, uint32_t req_ver, VmaAllocationCreateFlags flags)
 
static VE_Result
< VE_MemoryAllocator
create (const VE_Instance &, VkPhysicalDevice, VkDevice, VmaAllocationCreateFlags flags)
 
static
VkExternalMemoryHandleTypeFlags 
getExternMemHandleType ()
 

Detailed Description

General purpose allocator for vulkan backed memory blocks that tries to balance convenience, safety, and performance.

The main convenience offered is that memory blocks allocated from this object will free themselves when they go out of scope. The caller does not need to explicity free them. This makes this class well suited for allocating lots of resources that would be difficult to keep track of manually.

However, the memory blocks do this by maintaining references to the underlying VmaAllocator object handle, which is owned by and cleaned up by this class. Therefore, care must be taken to ensure this object's life time extends beyond its allocated blocks. If the memory blocks and this allocator are kept as members of a larger structure, ensure proper member ordering so that the blocks are destroyed before the allocator.

Thread safety: This allocator contains no locks and attempts no cross thread synchronization. If you need memory allocations in different threads, you should give those threads their own allocator.

Definition at line 201 of file VE_Memory.h.

Constructor & Destructor Documentation

VE_MemoryAllocator::VE_MemoryAllocator ( )
default
VE_MemoryAllocator::~VE_MemoryAllocator ( )
VE_MemoryAllocator::VE_MemoryAllocator ( VE_MemoryAllocator &&  other)
inlinenoexcept

Definition at line 255 of file VE_Memory.h.

Member Function Documentation

VE_Result<VE_Memory> VE_MemoryAllocator::allocateBuffer ( VE_MemType  type,
const VkBufferCreateInfo buf_info,
VkBuffer &  vk_buf 
)
VE_Result<VE_Memory> VE_MemoryAllocator::allocateImage ( VE_MemType  type,
const VkImageCreateInfo img_info,
VkImage &  vk_img 
)
VE_Result<VE_Memory> VE_MemoryAllocator::allocateMemory ( VE_MemType  type,
const VkMemoryRequirements info 
)
static VE_Result<VE_MemoryAllocator> VE_MemoryAllocator::create ( VkInstance  ,
VkPhysicalDevice  ,
VkDevice  ,
uint32_t  req_ver,
VmaAllocationCreateFlags  flags 
)
static
static VE_Result<VE_MemoryAllocator> VE_MemoryAllocator::create ( const VE_Instance ,
VkPhysicalDevice  ,
VkDevice  ,
VmaAllocationCreateFlags  flags 
)
static
static VkExternalMemoryHandleTypeFlags VE_MemoryAllocator::getExternMemHandleType ( )
static
void VE_MemoryAllocator::getMemoryUsage ( exint out_device_vma_alloc_size,
exint out_device_vk_alloc_size,
exint out_device_total_size,
exint out_shared_vma_alloc_size,
exint out_shared_vk_alloc_size,
exint out_shared_total_size 
) const
UT_Array<VmaBudget> VE_MemoryAllocator::heapInfos ( ) const
VE_MemoryAllocator& VE_MemoryAllocator::operator= ( VE_MemoryAllocator &&  other)
inlinenoexcept

Definition at line 260 of file VE_Memory.h.

const VkPhysicalDeviceMemoryProperties& VE_MemoryAllocator::physicalDeviceMemoryProperties ( ) const
inline

Definition at line 218 of file VE_Memory.h.

void VE_MemoryAllocator::printMemoryInfo ( ) const
void VE_MemoryAllocator::printMemoryInfo ( std::ostream *  out = nullptr) const
VE_MemoryAllocator::UT_NON_COPYABLE ( VE_MemoryAllocator  )

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