<p>Vulkan Memory Allocator comes in form of a "stb-style" single header file. You don't need to build it as a separate library project. You can add this file directly to your project and submit it to code repository next to your other source files.</p>
<p>"Single header" doesn't mean that everything is contained in C/C++ declarations, like it tends to be in case of inline functions or C++ templates. It means that implementation is bundled with interface in a single file and needs to be extracted using preprocessor macro. If you don't do it properly, you will get linker errors.</p>
<p>This library includes header <code><vulkan/vulkan.h></code>, which in turn includes <code><windows.h></code> on Windows. If you need some specific macros defined before including these headers (like <code>WIN32_LEAN_AND_MEAN</code> or <code>WINVER</code> for Windows, <code>VK_USE_PLATFORM_WIN32_KHR</code> for Vulkan), you must define them before every <code>#include</code> of this library.</p>
<dlclass="section note"><dt>Note</dt><dd>This library is written in C++, but has C-compatible interface. Thus you can include and use <aclass="el"href="vk__mem__alloc_8h.html">vk_mem_alloc.h</a> in C or C++ code, but full implementation with <code>VMA_IMPLEMENTATION</code> macro must be compiled as C++, NOT as C.</dd></dl>
<li>Fill <aclass="el"href="struct_vma_allocator_create_info.html"title="Description of a Allocator to be created.">VmaAllocatorCreateInfo</a> structure and create <aclass="el"href="struct_vma_allocator.html"title="Represents main object of this library initialized.">VmaAllocator</a> object by calling <aclass="el"href="group__group__init.html#ga200692051ddb34240248234f5f4c17bb"title="Creates VmaAllocator object.">vmaCreateAllocator()</a>.</li>
<p>Only members <code>physicalDevice</code>, <code>device</code>, <code>instance</code> are required. However, you should inform the library which Vulkan version do you use by setting <aclass="el"href="struct_vma_allocator_create_info.html#ae0ffc55139b54520a6bb704b29ffc285"title="Optional. The highest version of Vulkan that the application is designed to use.">VmaAllocatorCreateInfo::vulkanApiVersion</a> and which extensions did you enable by setting <aclass="el"href="struct_vma_allocator_create_info.html#a392ea2ecbaff93f91a7c49f735ad4346"title="Flags for created allocator. Use VmaAllocatorCreateFlagBits enum.">VmaAllocatorCreateInfo::flags</a> (like <aclass="el"href="group__group__init.html#gga4f87c9100d154a65a4ad495f7763cf7ca5f1b28b0414319d1687e1f2b30ab0089">VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT</a> for VK_KHR_buffer_device_address). Otherwise, VMA would use only features of Vulkan 1.0 core with no extensions.</p>
<p>You may need to configure importing Vulkan functions. There are 3 ways to do this:</p>
<oltype="1">
<li><b>If you link with Vulkan static library</b> (e.g. "vulkan-1.lib" on Windows):<ul>
<li>You don't need to do anything.</li>
<li>VMA will use these, as macro <code>VMA_STATIC_VULKAN_FUNCTIONS</code> is defined to 1 by default.</li>
</ul>
</li>
<li><b>If you want VMA to fetch pointers to Vulkan functions dynamically</b> using <code>vkGetInstanceProcAddr</code>, <code>vkGetDeviceProcAddr</code> (this is the option presented in the example below):<ul>
<li>Define <code>VMA_STATIC_VULKAN_FUNCTIONS</code> to 0, <code>VMA_DYNAMIC_VULKAN_FUNCTIONS</code> to 1.</li>
<li>Provide pointers to these two functions via <aclass="el"href="struct_vma_vulkan_functions.html#a3eafa102f5f8915f093f40675636b849"title="Required when using VMA_DYNAMIC_VULKAN_FUNCTIONS.">VmaVulkanFunctions::vkGetInstanceProcAddr</a>, <aclass="el"href="struct_vma_vulkan_functions.html#ac383ab9af127e5e136622fa4ebea9e57"title="Required when using VMA_DYNAMIC_VULKAN_FUNCTIONS.">VmaVulkanFunctions::vkGetDeviceProcAddr</a>.</li>
<li>The library will fetch pointers to all other functions it needs internally.</li>
</ul>
</li>
<li><b>If you fetch pointers to all Vulkan functions in a custom way</b>, e.g. using some loader like <ahref="https://github.com/zeux/volk">Volk</a>:<ul>
<li>Define <code>VMA_STATIC_VULKAN_FUNCTIONS</code> and <code>VMA_DYNAMIC_VULKAN_FUNCTIONS</code> to 0.</li>
<li>Pass these pointers via structure <aclass="el"href="struct_vma_vulkan_functions.html"title="Pointers to some Vulkan functions - a subset used by the library.">VmaVulkanFunctions</a>.</li>
<divclass="ttc"id="astruct_vma_allocator_create_info_html"><divclass="ttname"><ahref="struct_vma_allocator_create_info.html">VmaAllocatorCreateInfo</a></div><divclass="ttdoc">Description of a Allocator to be created.</div><divclass="ttdef"><b>Definition:</b> vk_mem_alloc.h:1001</div></div>
<divclass="ttc"id="astruct_vma_allocator_create_info_html_a3dc197be3227da7338b1643f70db36bd"><divclass="ttname"><ahref="struct_vma_allocator_create_info.html#a3dc197be3227da7338b1643f70db36bd">VmaAllocatorCreateInfo::pVulkanFunctions</a></div><divclass="ttdeci">const VmaVulkanFunctions * pVulkanFunctions</div><divclass="ttdoc">Pointers to Vulkan functions. Can be null.</div><divclass="ttdef"><b>Definition:</b> vk_mem_alloc.h:1049</div></div>
<divclass="ttc"id="astruct_vma_allocator_create_info_html_a70dd42e29b1df1d1b9b61532ae0b370b"><divclass="ttname"><ahref="struct_vma_allocator_create_info.html#a70dd42e29b1df1d1b9b61532ae0b370b">VmaAllocatorCreateInfo::instance</a></div><divclass="ttdeci">VkInstance instance</div><divclass="ttdoc">Handle to Vulkan instance object.</div><divclass="ttdef"><b>Definition:</b> vk_mem_alloc.h:1054</div></div>
<divclass="ttc"id="astruct_vma_allocator_create_info_html_ae0ffc55139b54520a6bb704b29ffc285"><divclass="ttname"><ahref="struct_vma_allocator_create_info.html#ae0ffc55139b54520a6bb704b29ffc285">VmaAllocatorCreateInfo::vulkanApiVersion</a></div><divclass="ttdeci">uint32_t vulkanApiVersion</div><divclass="ttdoc">Optional. The highest version of Vulkan that the application is designed to use.</div><divclass="ttdef"><b>Definition:</b> vk_mem_alloc.h:1063</div></div>
<divclass="ttc"id="astruct_vma_allocator_html"><divclass="ttname"><ahref="struct_vma_allocator.html">VmaAllocator</a></div><divclass="ttdoc">Represents main object of this library initialized.</div></div>
<divclass="ttc"id="astruct_vma_vulkan_functions_html"><divclass="ttname"><ahref="struct_vma_vulkan_functions.html">VmaVulkanFunctions</a></div><divclass="ttdoc">Pointers to some Vulkan functions - a subset used by the library.</div><divclass="ttdef"><b>Definition:</b> vk_mem_alloc.h:954</div></div>
<divclass="ttc"id="astruct_vma_vulkan_functions_html_a3eafa102f5f8915f093f40675636b849"><divclass="ttname"><ahref="struct_vma_vulkan_functions.html#a3eafa102f5f8915f093f40675636b849">VmaVulkanFunctions::vkGetInstanceProcAddr</a></div><divclass="ttdeci">PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr</div><divclass="ttdoc">Required when using VMA_DYNAMIC_VULKAN_FUNCTIONS.</div><divclass="ttdef"><b>Definition:</b> vk_mem_alloc.h:956</div></div>
<divclass="ttc"id="astruct_vma_vulkan_functions_html_ac383ab9af127e5e136622fa4ebea9e57"><divclass="ttname"><ahref="struct_vma_vulkan_functions.html#ac383ab9af127e5e136622fa4ebea9e57">VmaVulkanFunctions::vkGetDeviceProcAddr</a></div><divclass="ttdeci">PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr</div><divclass="ttdoc">Required when using VMA_DYNAMIC_VULKAN_FUNCTIONS.</div><divclass="ttdef"><b>Definition:</b> vk_mem_alloc.h:958</div></div>
<li>Call <aclass="el"href="group__group__alloc.html#gac72ee55598617e8eecca384e746bab51">vmaCreateBuffer()</a> / <aclass="el"href="group__group__alloc.html#ga02a94f25679275851a53e82eacbcfc73"title="Function similar to vmaCreateBuffer().">vmaCreateImage()</a> to get <code>VkBuffer</code>/<code>VkImage</code> with memory already allocated and bound to it, plus <aclass="el"href="struct_vma_allocation.html"title="Represents single memory allocation.">VmaAllocation</a> objects that represents its underlying memory.</li>
<divclass="ttc"id="astruct_vma_allocation_html"><divclass="ttname"><ahref="struct_vma_allocation.html">VmaAllocation</a></div><divclass="ttdoc">Represents single memory allocation.</div></div>