<divclass="textblock"><p>The library automatically creates and manages default memory pool for each memory type available on the device. A pool contains a number of <code>VkDeviceMemory</code> blocks. You can create custom pool and allocate memory out of it. It can be useful if you want to:</p>
<ul>
<li>Keep certain kind of allocations separate from others.</li>
<li>Enforce particular size of Vulkan memory blocks.</li>
<li>Limit maximum amount of Vulkan memory allocated for that pool.</li>
</ul>
<p>To use custom memory pools:</p>
<oltype="1">
<li>Fill <aclass="el"href="struct_vma_pool_create_info.html"title="Describes parameter of created VmaPool. ">VmaPoolCreateInfo</a> structure.</li>
<li>Call <aclass="el"href="vk__mem__alloc_8h.html#a5c8770ded7c59c8caac6de0c2cb00b50"title="Allocates Vulkan device memory and creates VmaPool object. ">vmaCreatePool()</a> to obtain <code>VmaPool</code> handle.</li>
<li>When making an allocation, set <aclass="el"href="struct_vma_allocation_create_info.html#a6272c0555cfd1fe28bff1afeb6190150"title="Pool that this allocation should be created in. ">VmaAllocationCreateInfo::pool</a> to this handle. You don't need to specify any other parameters of this structure, like usage.</li>
<divclass="fragment"><divclass="line"><spanclass="comment">// Create a pool that could have at most 2 blocks, 128 MiB each.</span></div><divclass="line"><aclass="code"href="struct_vma_pool_create_info.html">VmaPoolCreateInfo</a> poolCreateInfo = {};</div><divclass="line">poolCreateInfo.<aclass="code"href="struct_vma_pool_create_info.html#a596fa76b685d3f1f688f84a709a5b319">memoryTypeIndex</a> = ...</div><divclass="line">poolCreateInfo.blockSize = 128ull * 1024 * 1024;</div><divclass="line">poolCreateInfo.<aclass="code"href="struct_vma_pool_create_info.html#ae41142f2834fcdc82baa4883c187b75c">maxBlockCount</a> = 2;</div><divclass="line"></div><divclass="line">VmaPool pool;</div><divclass="line"><aclass="code"href="vk__mem__alloc_8h.html#a5c8770ded7c59c8caac6de0c2cb00b50">vmaCreatePool</a>(allocator, &poolCreateInfo, &pool);</div><divclass="line"></div><divclass="line"><spanclass="comment">// Allocate a buffer out of it.</span></div><divclass="line">VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };</div><divclass="line">bufCreateInfo.size = 1024;</div><divclass="line">bufCreateInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;</div><divclass="line"></div><divclass="line"><aclass="code"href="struct_vma_allocation_create_info.html">VmaAllocationCreateInfo</a> allocCreateInfo = {};</div><divclass="line">allocCreateInfo.<aclass="code"href="struct_vma_allocation_create_info.html#a6272c0555cfd1fe28bff1afeb6190150">pool</a> = pool;</div><divclass="line"></div><divclass="line">VkBuffer buf;</div><divclass="line">VmaAllocation alloc;</div><divclass="line"><aclass="code"href="struct_vma_allocation_info.html">VmaAllocationInfo</a> allocInfo;</div><divclass="line"><aclass="code"href="vk__mem__alloc_8h.html#ac72ee55598617e8eecca384e746bab51">vmaCreateBuffer</a>(allocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, &allocInfo);</div></div><!-- fragment --><p>You have to free all allocations made from this pool before destroying it.</p>