Vulkan Memory Allocator
Functions
Layer 2 Allocating Memory

Functions

VkResult vmaAllocateMemory (VmaAllocator allocator, const VkMemoryRequirements *pVkMemoryRequirements, const VmaMemoryRequirements *pVmaMemoryRequirements, VkMappedMemoryRange *pMemory, uint32_t *pMemoryTypeIndex)
 General purpose memory allocation. More...
 
VkResult vmaAllocateMemoryForBuffer (VmaAllocator allocator, VkBuffer buffer, const VmaMemoryRequirements *pMemoryRequirements, VkMappedMemoryRange *pMemory, uint32_t *pMemoryTypeIndex)
 
VkResult vmaAllocateMemoryForImage (VmaAllocator allocator, VkImage image, const VmaMemoryRequirements *pMemoryRequirements, VkMappedMemoryRange *pMemory, uint32_t *pMemoryTypeIndex)
 Function similar to vmaAllocateMemoryForBuffer(). More...
 
void vmaFreeMemory (VmaAllocator allocator, const VkMappedMemoryRange *pMemory)
 Frees memory previously allocated using vmaAllocateMemoryForBuffer() or vmaAllocateMemoryForImage(). More...
 
VkResult vmaMapMemory (VmaAllocator allocator, const VkMappedMemoryRange *pMemory, void **ppData)
 
void vmaUnmapMemory (VmaAllocator allocator, const VkMappedMemoryRange *pMemory)
 

Detailed Description

Function Documentation

◆ vmaAllocateMemory()

VkResult vmaAllocateMemory ( VmaAllocator  allocator,
const VkMemoryRequirements *  pVkMemoryRequirements,
const VmaMemoryRequirements pVmaMemoryRequirements,
VkMappedMemoryRange *  pMemory,
uint32_t *  pMemoryTypeIndex 
)

General purpose memory allocation.

Parameters
[out]pMemoryAllocated memory.
[out]pMemoryTypeIndexOptional. Index of memory type that has been chosen for this allocation.

You should free the memory using vmaFreeMemory().

All allocated memory is also automatically freed in vmaDestroyAllocator().

It is recommended to use vmaAllocateMemoryForBuffer(), vmaAllocateMemoryForImage(), vmaCreateBuffer(), vmaCreateImage() instead whenever possible.

◆ vmaAllocateMemoryForBuffer()

VkResult vmaAllocateMemoryForBuffer ( VmaAllocator  allocator,
VkBuffer  buffer,
const VmaMemoryRequirements pMemoryRequirements,
VkMappedMemoryRange *  pMemory,
uint32_t *  pMemoryTypeIndex 
)
Parameters
[out]pMemoryTypeIndexOptional. Pass null if you don't need this information.

You should free the memory using vmaFreeMemory().

All allocated memory is also automatically freed in vmaDestroyAllocator().

◆ vmaAllocateMemoryForImage()

VkResult vmaAllocateMemoryForImage ( VmaAllocator  allocator,
VkImage  image,
const VmaMemoryRequirements pMemoryRequirements,
VkMappedMemoryRange *  pMemory,
uint32_t *  pMemoryTypeIndex 
)

Function similar to vmaAllocateMemoryForBuffer().

◆ vmaFreeMemory()

void vmaFreeMemory ( VmaAllocator  allocator,
const VkMappedMemoryRange *  pMemory 
)

Frees memory previously allocated using vmaAllocateMemoryForBuffer() or vmaAllocateMemoryForImage().

◆ vmaMapMemory()

VkResult vmaMapMemory ( VmaAllocator  allocator,
const VkMappedMemoryRange *  pMemory,
void **  ppData 
)

Feel free to use vkMapMemory on these memory blocks on you own if you want, but just for convenience and to make sure correct offset and size is always specified, usage of vmaMapMemory() / vmaUnmapMemory() is recommended.

◆ vmaUnmapMemory()

void vmaUnmapMemory ( VmaAllocator  allocator,
const VkMappedMemoryRange *  pMemory 
)