Thread safety
- The library has no global state, so separate VmaAllocator objects can be used independently. There should be no need to create multiple such objects though - one per
VkDevice
is enough.
- By default, all calls to functions that take VmaAllocator as first parameter are safe to call from multiple threads simultaneously because they are synchronized internally when needed.
- When the allocator is created with VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT flag, calls to functions that take such VmaAllocator object must be synchronized externally.
- Access to a VmaAllocation object must be externally synchronized. For example, you must not call vmaGetAllocationInfo() and vmaMapMemory() from different threads at the same time if you pass the same VmaAllocation object to these functions.
Allocation algorithm
The library uses following algorithm for allocation, in order:
- Try to find free range of memory in existing blocks.
- If failed, try to create a new block of
VkDeviceMemory
, with preferred block size.
- If failed, try to create such block with size/2, size/4, size/8.
- If failed and VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT flag was specified, try to find space in existing blocks, possilby making some other allocations lost.
- If failed, try to allocate separate
VkDeviceMemory
for this allocation, just like when you use VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT.
- If failed, choose other memory type that meets the requirements specified in VmaAllocationCreateInfo and go to point 1.
- If failed, return
VK_ERROR_OUT_OF_DEVICE_MEMORY
.
Features not supported
Features deliberately excluded from the scope of this library:
- Data transfer - issuing commands that transfer data between buffers or images, any usage of
VkCommandList
or VkCommandQueue
and related synchronization is responsibility of the user.
- Allocations for imported/exported external memory. They tend to require explicit memory type index and dedicated allocation anyway, so they don't interact with main features of this library. Such special purpose allocations should be made manually, using
vkCreateBuffer()
and vkAllocateMemory()
.
- Support for any programming languages other than C/C++. Bindings to other languages are welcomed as external projects.