Vulkan Memory Allocator
Classes | Macros | Typedefs | Enumerations | Functions
General

Classes

struct  VmaDeviceMemoryCallbacks
 Set of callbacks that the library will call for vkAllocateMemory and vkFreeMemory. More...
 
struct  VmaVulkanFunctions
 Pointers to some Vulkan functions - a subset used by the library. More...
 
struct  VmaAllocatorCreateInfo
 Description of a Allocator to be created. More...
 
struct  VmaStatInfo
 Calculated statistics of memory usage in entire allocator. More...
 
struct  VmaStats
 General statistics from current state of Allocator. More...
 

Macros

#define VMA_STATS_STRING_ENABLED   1
 

Typedefs

typedef void(VKAPI_PTR * PFN_vmaAllocateDeviceMemoryFunction) (VmaAllocator allocator, uint32_t memoryType, VkDeviceMemory memory, VkDeviceSize size)
 Callback function called after successful vkAllocateMemory. More...
 
typedef void(VKAPI_PTR * PFN_vmaFreeDeviceMemoryFunction) (VmaAllocator allocator, uint32_t memoryType, VkDeviceMemory memory, VkDeviceSize size)
 Callback function called before vkFreeMemory. More...
 
typedef struct VmaDeviceMemoryCallbacks VmaDeviceMemoryCallbacks
 Set of callbacks that the library will call for vkAllocateMemory and vkFreeMemory. More...
 
typedef enum VmaAllocatorCreateFlagBits VmaAllocatorCreateFlagBits
 Flags for created VmaAllocator. More...
 
typedef VkFlags VmaAllocatorCreateFlags
 
typedef struct VmaVulkanFunctions VmaVulkanFunctions
 Pointers to some Vulkan functions - a subset used by the library. More...
 
typedef struct VmaAllocatorCreateInfo VmaAllocatorCreateInfo
 Description of a Allocator to be created. More...
 
typedef struct VmaStatInfo VmaStatInfo
 Calculated statistics of memory usage in entire allocator. More...
 
typedef struct VmaStats VmaStats
 General statistics from current state of Allocator. More...
 

Enumerations

enum  VmaAllocatorCreateFlagBits { VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT = 0x00000001, VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT = 0x00000002, VMA_ALLOCATOR_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF }
 Flags for created VmaAllocator. More...
 

Functions

VkResult vmaCreateAllocator (const VmaAllocatorCreateInfo *pCreateInfo, VmaAllocator *pAllocator)
 Creates Allocator object. More...
 
void vmaDestroyAllocator (VmaAllocator allocator)
 Destroys allocator object. More...
 
void vmaGetPhysicalDeviceProperties (VmaAllocator allocator, const VkPhysicalDeviceProperties **ppPhysicalDeviceProperties)
 
void vmaGetMemoryProperties (VmaAllocator allocator, const VkPhysicalDeviceMemoryProperties **ppPhysicalDeviceMemoryProperties)
 
void vmaGetMemoryTypeProperties (VmaAllocator allocator, uint32_t memoryTypeIndex, VkMemoryPropertyFlags *pFlags)
 Given Memory Type Index, returns Property Flags of this memory type. More...
 
void vmaSetCurrentFrameIndex (VmaAllocator allocator, uint32_t frameIndex)
 Sets index of the current frame. More...
 
void vmaCalculateStats (VmaAllocator allocator, VmaStats *pStats)
 Retrieves statistics from current state of the Allocator. More...
 
void vmaBuildStatsString (VmaAllocator allocator, char **ppStatsString, VkBool32 detailedMap)
 Builds and returns statistics as string in JSON format. More...
 
void vmaFreeStatsString (VmaAllocator allocator, char *pStatsString)
 

Detailed Description

Macro Definition Documentation

◆ VMA_STATS_STRING_ENABLED

#define VMA_STATS_STRING_ENABLED   1

Typedef Documentation

◆ PFN_vmaAllocateDeviceMemoryFunction

typedef void(VKAPI_PTR * PFN_vmaAllocateDeviceMemoryFunction) (VmaAllocator allocator, uint32_t memoryType, VkDeviceMemory memory, VkDeviceSize size)

Callback function called after successful vkAllocateMemory.

◆ PFN_vmaFreeDeviceMemoryFunction

typedef void(VKAPI_PTR * PFN_vmaFreeDeviceMemoryFunction) (VmaAllocator allocator, uint32_t memoryType, VkDeviceMemory memory, VkDeviceSize size)

Callback function called before vkFreeMemory.

◆ VmaAllocatorCreateFlagBits

Flags for created VmaAllocator.

◆ VmaAllocatorCreateFlags

typedef VkFlags VmaAllocatorCreateFlags

◆ VmaAllocatorCreateInfo

Description of a Allocator to be created.

◆ VmaDeviceMemoryCallbacks

Set of callbacks that the library will call for vkAllocateMemory and vkFreeMemory.

Provided for informative purpose, e.g. to gather statistics about number of allocations or total amount of memory allocated in Vulkan.

Used in VmaAllocatorCreateInfo::pDeviceMemoryCallbacks.

◆ VmaStatInfo

typedef struct VmaStatInfo VmaStatInfo

Calculated statistics of memory usage in entire allocator.

◆ VmaStats

typedef struct VmaStats VmaStats

General statistics from current state of Allocator.

◆ VmaVulkanFunctions

Pointers to some Vulkan functions - a subset used by the library.

Used in VmaAllocatorCreateInfo::pVulkanFunctions.

Enumeration Type Documentation

◆ VmaAllocatorCreateFlagBits

Flags for created VmaAllocator.

Enumerator
VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT 

Allocator and all objects created from it will not be synchronized internally, so you must guarantee they are used from only one thread at a time or synchronized externally by you.

Using this flag may increase performance because internal mutexes are not used.

VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT 

Enables usage of VK_KHR_dedicated_allocation extension.

Using this extenion will automatically allocate dedicated blocks of memory for some buffers and images instead of suballocating place for them out of bigger memory blocks (as if you explicitly used VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT flag) when it is recommended by the driver. It may improve performance on some GPUs.

You may set this flag only if you found out that following device extensions are supported, you enabled them while creating Vulkan device passed as VmaAllocatorCreateInfo::device, and you want them to be used internally by this library:

  • VK_KHR_get_memory_requirements2
  • VK_KHR_dedicated_allocation

If this flag is enabled, you must also provide VmaAllocatorCreateInfo::pVulkanFunctions and fill at least members: VmaVulkanFunctions::vkGetBufferMemoryRequirements2KHR, VmaVulkanFunctions::vkGetImageMemoryRequirements2KHR, because they are never imported statically.

When this flag is set, you can experience following warnings reported by Vulkan validation layer. You can ignore them.

vkBindBufferMemory(): Binding memory to buffer 0x2d but vkGetBufferMemoryRequirements() has not been called on that buffer.

VMA_ALLOCATOR_CREATE_FLAG_BITS_MAX_ENUM 

Function Documentation

◆ vmaBuildStatsString()

void vmaBuildStatsString ( VmaAllocator  allocator,
char **  ppStatsString,
VkBool32  detailedMap 
)

Builds and returns statistics as string in JSON format.

Parameters
[out]ppStatsStringMust be freed using vmaFreeStatsString() function.

◆ vmaCalculateStats()

void vmaCalculateStats ( VmaAllocator  allocator,
VmaStats pStats 
)

Retrieves statistics from current state of the Allocator.

◆ vmaCreateAllocator()

VkResult vmaCreateAllocator ( const VmaAllocatorCreateInfo pCreateInfo,
VmaAllocator *  pAllocator 
)

Creates Allocator object.

◆ vmaDestroyAllocator()

void vmaDestroyAllocator ( VmaAllocator  allocator)

Destroys allocator object.

◆ vmaFreeStatsString()

void vmaFreeStatsString ( VmaAllocator  allocator,
char *  pStatsString 
)

◆ vmaGetMemoryProperties()

void vmaGetMemoryProperties ( VmaAllocator  allocator,
const VkPhysicalDeviceMemoryProperties **  ppPhysicalDeviceMemoryProperties 
)

PhysicalDeviceMemoryProperties are fetched from physicalDevice by the allocator. You can access it here, without fetching it again on your own.

◆ vmaGetMemoryTypeProperties()

void vmaGetMemoryTypeProperties ( VmaAllocator  allocator,
uint32_t  memoryTypeIndex,
VkMemoryPropertyFlags *  pFlags 
)

Given Memory Type Index, returns Property Flags of this memory type.

This is just a convenience function. Same information can be obtained using vmaGetMemoryProperties().

◆ vmaGetPhysicalDeviceProperties()

void vmaGetPhysicalDeviceProperties ( VmaAllocator  allocator,
const VkPhysicalDeviceProperties **  ppPhysicalDeviceProperties 
)

PhysicalDeviceProperties are fetched from physicalDevice by the allocator. You can access it here, without fetching it again on your own.

◆ vmaSetCurrentFrameIndex()

void vmaSetCurrentFrameIndex ( VmaAllocator  allocator,
uint32_t  frameIndex 
)

Sets index of the current frame.

This function must be used if you make allocations with VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT and VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT flags to inform the allocator when a new frame begins. Allocations queried using vmaGetAllocationInfo() cannot become lost in the current frame.