<trclass="memdesc:"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Parameters of VmaAllocation objects, that can be retrieved using function <aclass="el"href="group__layer2.html#ga86dd08aba8633bfa4ad0df2e76481d8b"title="Returns current information about specified allocation. ">vmaGetAllocationInfo()</a>. <ahref="struct_vma_allocation_info.html#details">More...</a><br/></td></tr>
<trclass="memdesc:"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Optional configuration parameters to be passed to function <aclass="el"href="group__layer2.html#ga6aced90fcc7b39882b6654a740a0b9bb"title="Compacts memory by moving allocations. ">vmaDefragment()</a>. <ahref="struct_vma_defragmentation_info.html#details">More...</a><br/></td></tr>
<trclass="memdesc:"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Statistics returned by function <aclass="el"href="group__layer2.html#ga6aced90fcc7b39882b6654a740a0b9bb"title="Compacts memory by moving allocations. ">vmaDefragment()</a>. <ahref="struct_vma_defragmentation_stats.html#details">More...</a><br/></td></tr>
<trclass="memdesc:ga795e6ff02a21d5486c0565f403dd9255"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Parameters of VmaAllocation objects, that can be retrieved using function <aclass="el"href="group__layer2.html#ga86dd08aba8633bfa4ad0df2e76481d8b"title="Returns current information about specified allocation. ">vmaGetAllocationInfo()</a>. <ahref="#ga795e6ff02a21d5486c0565f403dd9255">More...</a><br/></td></tr>
<trclass="memdesc:gae67f8573a0cf20f16f0a1eecbca566a0"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Optional configuration parameters to be passed to function <aclass="el"href="group__layer2.html#ga6aced90fcc7b39882b6654a740a0b9bb"title="Compacts memory by moving allocations. ">vmaDefragment()</a>. <ahref="#gae67f8573a0cf20f16f0a1eecbca566a0">More...</a><br/></td></tr>
<trclass="memdesc:gab0f9b06441c840fee560de4a2967f8c9"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Statistics returned by function <aclass="el"href="group__layer2.html#ga6aced90fcc7b39882b6654a740a0b9bb"title="Compacts memory by moving allocations. ">vmaDefragment()</a>. <ahref="#gab0f9b06441c840fee560de4a2967f8c9">More...</a><br/></td></tr>
<trclass="memdesc:ga801f98c24eb928642742bb1e5615e86e"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Function similar to <aclass="el"href="group__layer2.html#ga3536b4da2a2744dc3f3f138be555af02">vmaAllocateMemoryForBuffer()</a>. <ahref="#ga801f98c24eb928642742bb1e5615e86e">More...</a><br/></td></tr>
<trclass="memdesc:ga11f0fbc034fa81a4efedd73d61ce7568"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Frees memory previously allocated using <aclass="el"href="group__layer2.html#ga1a7d45920877a53e9a8fbefd6a536119"title="General purpose memory allocation. ">vmaAllocateMemory()</a>, <aclass="el"href="group__layer2.html#ga3536b4da2a2744dc3f3f138be555af02">vmaAllocateMemoryForBuffer()</a>, or <aclass="el"href="group__layer2.html#ga801f98c24eb928642742bb1e5615e86e"title="Function similar to vmaAllocateMemoryForBuffer(). ">vmaAllocateMemoryForImage()</a>. <ahref="#ga11f0fbc034fa81a4efedd73d61ce7568">More...</a><br/></td></tr>
<trclass="memdesc:ga86dd08aba8633bfa4ad0df2e76481d8b"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns current information about specified allocation. <ahref="#ga86dd08aba8633bfa4ad0df2e76481d8b">More...</a><br/></td></tr>
<trclass="memdesc:gaf9147d31ffc11d62fc187bde283ed14f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets pUserData in given allocation to new value. <ahref="#gaf9147d31ffc11d62fc187bde283ed14f">More...</a><br/></td></tr>
<trclass="memdesc:ga26b87244491c1fe77f11fe9ab5779c27"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Unmaps persistently mapped memory of types that is HOST_COHERENT and DEVICE_LOCAL. <ahref="#ga26b87244491c1fe77f11fe9ab5779c27">More...</a><br/></td></tr>
<trclass="memdesc:ga03366170bb8e186605518d2f5d65b85a"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Maps back persistently mapped memory of types that is HOST_COHERENT and DEVICE_LOCAL. <ahref="#ga03366170bb8e186605518d2f5d65b85a">More...</a><br/></td></tr>
<p>Parameters of VmaAllocation objects, that can be retrieved using function <aclass="el"href="group__layer2.html#ga86dd08aba8633bfa4ad0df2e76481d8b"title="Returns current information about specified allocation. ">vmaGetAllocationInfo()</a>. </p>
<p>Optional configuration parameters to be passed to function <aclass="el"href="group__layer2.html#ga6aced90fcc7b39882b6654a740a0b9bb"title="Compacts memory by moving allocations. ">vmaDefragment()</a>. </p>
<p>Statistics returned by function <aclass="el"href="group__layer2.html#ga6aced90fcc7b39882b6654a740a0b9bb"title="Compacts memory by moving allocations. ">vmaDefragment()</a>. </p>
<tr><tdclass="paramdir">[out]</td><tdclass="paramname">pAllocationInfo</td><td>Optional. Information about allocated memory. It can be later fetched using function <aclass="el"href="group__layer2.html#ga86dd08aba8633bfa4ad0df2e76481d8b"title="Returns current information about specified allocation. ">vmaGetAllocationInfo()</a>.</td></tr>
<p>You should free the memory using <aclass="el"href="group__layer2.html#ga11f0fbc034fa81a4efedd73d61ce7568"title="Frees memory previously allocated using vmaAllocateMemory(), vmaAllocateMemoryForBuffer(), or vmaAllocateMemoryForImage(). ">vmaFreeMemory()</a>.</p>
<p>It is recommended to use <aclass="el"href="group__layer2.html#ga3536b4da2a2744dc3f3f138be555af02">vmaAllocateMemoryForBuffer()</a>, <aclass="el"href="group__layer2.html#ga801f98c24eb928642742bb1e5615e86e"title="Function similar to vmaAllocateMemoryForBuffer(). ">vmaAllocateMemoryForImage()</a>, <aclass="el"href="group__layer3.html#ga2f711e32e95cf9bf8dff4917230c2e9b">vmaCreateBuffer()</a>, <aclass="el"href="group__layer3.html#ga9e34bc318ff4b25d1958e79b9db3f1aa"title="Function similar to vmaCreateBuffer(). ">vmaCreateImage()</a> instead whenever possible. </p>
<tr><tdclass="paramdir">[out]</td><tdclass="paramname">pAllocationInfo</td><td>Optional. Information about allocated memory. It can be later fetched using function <aclass="el"href="group__layer2.html#ga86dd08aba8633bfa4ad0df2e76481d8b"title="Returns current information about specified allocation. ">vmaGetAllocationInfo()</a>.</td></tr>
<p>You should free the memory using <aclass="el"href="group__layer2.html#ga11f0fbc034fa81a4efedd73d61ce7568"title="Frees memory previously allocated using vmaAllocateMemory(), vmaAllocateMemoryForBuffer(), or vmaAllocateMemoryForImage(). ">vmaFreeMemory()</a>. </p>
<tr><tdclass="paramdir"></td><tdclass="paramname">pAllocations</td><td>Array of allocations that can be moved during this compation. </td></tr>
<tr><tdclass="paramdir"></td><tdclass="paramname">allocationCount</td><td>Number of elements in pAllocations and pAllocationsChanged arrays. </td></tr>
<tr><tdclass="paramdir">[out]</td><tdclass="paramname">pAllocationsChanged</td><td>Array of boolean values that will indicate whether matching allocation in pAllocations array has been moved. This parameter is optional. Pass null if you don't need this information. </td></tr>
<tr><tdclass="paramdir"></td><tdclass="paramname">pDefragmentationInfo</td><td>Configuration parameters. Optional - pass null to use default values. </td></tr>
<tr><tdclass="paramdir">[out]</td><tdclass="paramname">pDefragmentationStats</td><td>Statistics returned by the function. Optional - pass null if you don't need this information. </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>VK_SUCCESS if completed, VK_INCOMPLETE if succeeded but didn't make all possible optimizations because limits specified in pDefragmentationInfo have been reached, negative error code in case of error.</dd></dl>
<p>This function works by moving allocations to different places (different VkDeviceMemory objects and/or different offsets) in order to optimize memory usage. Only allocations that are in pAllocations array can be moved. All other allocations are considered nonmovable in this call. Basic rules:</p>
<ul>
<li>Only allocations made in memory types that have VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT flag can be compacted. You may pass other allocations but it makes no sense - these will never be moved.</li>
<li>You may pass allocations made with VMA_MEMORY_REQUIREMENT_OWN_MEMORY_BIT but it makes no sense - they will never be moved.</li>
<li>Both allocations made with or without VMA_MEMORY_REQUIREMENT_PERSISTENT_MAP_BIT flag can be compacted. If not persistently mapped, memory will be mapped temporarily inside this function if needed, so it shouldn't be mapped by you for the time of this call.</li>
<li>You must not pass same VmaAllocation object multiple times in pAllocations array.</li>
</ul>
<p>The function also frees empty VkDeviceMemory blocks.</p>
<p>After allocation has been moved, its <aclass="el"href="struct_vma_allocation_info.html#ae0bfb7dfdf79a76ffefc9a94677a2f67"title="Handle to Vulkan memory object. ">VmaAllocationInfo::deviceMemory</a> and/or <aclass="el"href="struct_vma_allocation_info.html#a4a3c732388dbdc7a23f9365b00825268"title="Offset into deviceMemory object to the beginning of this allocation, in bytes. (deviceMemory, offset) pair is unique to this allocation. ">VmaAllocationInfo::offset</a> changes. You must query them again using <aclass="el"href="group__layer2.html#ga86dd08aba8633bfa4ad0df2e76481d8b"title="Returns current information about specified allocation. ">vmaGetAllocationInfo()</a> if you need them.</p>
<p>If an allocation has been moved, data in memory is copied to new place automatically, but if it was bound to a buffer or an image, you must destroy that object yourself, create new one and bind it to the new memory pointed by the allocation. You must use vkDestroyBuffer(), vkDestroyImage(), vkCreateBuffer(), vkCreateImage() for that purpose and NOT <aclass="el"href="group__layer3.html#ga0d9f4e4ba5bf9aab1f1c746387753d77">vmaDestroyBuffer()</a>, <aclass="el"href="group__layer3.html#gae50d2cb3b4a3bfd4dd40987234e50e7e">vmaDestroyImage()</a>, <aclass="el"href="group__layer3.html#ga2f711e32e95cf9bf8dff4917230c2e9b">vmaCreateBuffer()</a>, <aclass="el"href="group__layer3.html#ga9e34bc318ff4b25d1958e79b9db3f1aa"title="Function similar to vmaCreateBuffer(). ">vmaCreateImage()</a>! Example:</p>
</pre><p>This function may be time-consuming, so you shouldn't call it too often (like every frame or after every resource creation/destruction), but rater you can call it on special occasions (like when reloading a game level, when you just destroyed a lot of objects). </p>
<p>Frees memory previously allocated using <aclass="el"href="group__layer2.html#ga1a7d45920877a53e9a8fbefd6a536119"title="General purpose memory allocation. ">vmaAllocateMemory()</a>, <aclass="el"href="group__layer2.html#ga3536b4da2a2744dc3f3f138be555af02">vmaAllocateMemoryForBuffer()</a>, or <aclass="el"href="group__layer2.html#ga801f98c24eb928642742bb1e5615e86e"title="Function similar to vmaAllocateMemoryForBuffer(). ">vmaAllocateMemoryForImage()</a>. </p>
<p>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 <aclass="el"href="group__layer2.html#gad5bd1243512d099706de88168992f069">vmaMapMemory()</a> / <aclass="el"href="group__layer2.html#ga9bc268595cb33f6ec4d519cfce81ff45">vmaUnmapMemory()</a> is recommended.</p>
<p>Do not use it on memory allocated with VMA_MEMORY_REQUIREMENT_PERSISTENT_MAP_BIT as multiple maps to same VkDeviceMemory is illegal. </p>
<p>Maps back persistently mapped memory of types that is HOST_COHERENT and DEVICE_LOCAL. </p>
<p>See <aclass="el"href="group__layer2.html#ga26b87244491c1fe77f11fe9ab5779c27"title="Unmaps persistently mapped memory of types that is HOST_COHERENT and DEVICE_LOCAL. ">vmaUnmapPersistentlyMappedMemory()</a>.</p>
<p>After this call <aclass="el"href="struct_vma_allocation_info.html#a5eeffbe2d2f30f53370ff14aefbadbe2"title="Pointer to the beginning of this allocation as mapped data. Null if this alloaction is not persistent...">VmaAllocationInfo::pMappedData</a> of some allocation may have value different than before calling <aclass="el"href="group__layer2.html#ga26b87244491c1fe77f11fe9ab5779c27"title="Unmaps persistently mapped memory of types that is HOST_COHERENT and DEVICE_LOCAL. ">vmaUnmapPersistentlyMappedMemory()</a>. </p>
<p>This is optional performance optimization. On Windows you should call it before every call to vkQueueSubmit and vkQueuePresent. After which you can remap the allocations again using <aclass="el"href="group__layer2.html#ga03366170bb8e186605518d2f5d65b85a"title="Maps back persistently mapped memory of types that is HOST_COHERENT and DEVICE_LOCAL. ">vmaMapPersistentlyMappedMemory()</a>. This is because of the internal behavior of WDDM. Example:</p>
</pre><p>After this call <aclass="el"href="struct_vma_allocation_info.html#a5eeffbe2d2f30f53370ff14aefbadbe2"title="Pointer to the beginning of this allocation as mapped data. Null if this alloaction is not persistent...">VmaAllocationInfo::pMappedData</a> of some allocations may become null.</p>
<p>This call is reference-counted. Memory is mapped again after you call <aclass="el"href="group__layer2.html#ga03366170bb8e186605518d2f5d65b85a"title="Maps back persistently mapped memory of types that is HOST_COHERENT and DEVICE_LOCAL. ">vmaMapPersistentlyMappedMemory()</a> same number of times that you called <aclass="el"href="group__layer2.html#ga26b87244491c1fe77f11fe9ab5779c27"title="Unmaps persistently mapped memory of types that is HOST_COHERENT and DEVICE_LOCAL. ">vmaUnmapPersistentlyMappedMemory()</a>. </p>