Vulkan Memory Allocator
|
A memory pool contains a number of VkDeviceMemory
blocks. The library automatically creates and manages default pool for each memory type available on the device. Default memory pool automatically grows in size. Size of allocated blocks is also variable and managed automatically.
You can create custom pool and allocate memory out of it. It can be useful if you want to:
To use custom memory pools:
VmaPool
handle.Example:
You have to free all allocations made from this pool before destroying it.
When creating a pool, you must explicitly specify memory type index. To find the one suitable for your buffers or images, you can use helper functions vmaFindMemoryTypeIndexForBufferInfo(), vmaFindMemoryTypeIndexForImageInfo(). You need to provide structures with example parameters of buffers or images that you are going to create in that pool.
When creating buffers/images allocated in that pool, provide following parameters:
VkBufferCreateInfo
: Prefer to pass same parameters as above. Otherwise you risk creating resources in a memory type that is not suitable for them, which may result in undefined behavior. Using different VK_BUFFER_USAGE_
flags may work, but you shouldn't create images in a pool intended for buffers or the other way around.pool
member. Other members are ignored anyway.