Publish version 2.3.0 final

Updated version number. Regenerated Release binaries and Doxygen documentation.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7d69f97..87ad08d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,4 @@
-# 2.3.0-alpha.1 (2019-11-25)

+# 2.3.0 (2019-12-04)

 

 Major release after a year of development in "master" branch and feature branches. Notable new features: supporting Vulkan 1.1, supporting query for memory budget.

 

diff --git a/bin/VmaReplay_Release_vs2019.exe b/bin/VmaReplay_Release_vs2019.exe
index afb2137..59552c5 100644
--- a/bin/VmaReplay_Release_vs2019.exe
+++ b/bin/VmaReplay_Release_vs2019.exe
Binary files differ
diff --git a/bin/VulkanSample_Release_vs2019.exe b/bin/VulkanSample_Release_vs2019.exe
index 31fe0d3..4940505 100644
--- a/bin/VulkanSample_Release_vs2019.exe
+++ b/bin/VulkanSample_Release_vs2019.exe
Binary files differ
diff --git a/docs/html/index.html b/docs/html/index.html
index 0ff700a..bbfb810 100644
--- a/docs/html/index.html
+++ b/docs/html/index.html
@@ -65,7 +65,7 @@
 <div class="title">Vulkan Memory Allocator </div>  </div>
 </div><!--header-->
 <div class="contents">
-<div class="textblock"><p><b>Version 2.3.0-alpha.1</b> (2019-11-25)</p>
+<div class="textblock"><p><b>Version 2.3.0</b> (2019-12-04)</p>
 <p>Copyright (c) 2017-2019 Advanced Micro Devices, Inc. All rights reserved. <br  />
 License: MIT</p>
 <p>Documentation of all members: <a class="el" href="vk__mem__alloc_8h.html">vk_mem_alloc.h</a></p>
diff --git a/docs/html/vk__mem__alloc_8h_source.html b/docs/html/vk__mem__alloc_8h_source.html
index 4c50d1c..ec5240e 100644
--- a/docs/html/vk__mem__alloc_8h_source.html
+++ b/docs/html/vk__mem__alloc_8h_source.html
@@ -3455,7 +3455,7 @@
 <div class="line"><a name="l06278"></a><span class="lineno"> 6278</span>&#160; </div>
 <div class="line"><a name="l06279"></a><span class="lineno"> 6279</span>&#160;    <span class="keywordtype">void</span> GetPoolStats(<a class="code" href="struct_vma_pool_stats.html">VmaPoolStats</a>* pStats);</div>
 <div class="line"><a name="l06280"></a><span class="lineno"> 6280</span>&#160; </div>
-<div class="line"><a name="l06281"></a><span class="lineno"> 6281</span>&#160;    <span class="keywordtype">bool</span> IsEmpty()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_Blocks.empty(); }</div>
+<div class="line"><a name="l06281"></a><span class="lineno"> 6281</span>&#160;    <span class="keywordtype">bool</span> IsEmpty();</div>
 <div class="line"><a name="l06282"></a><span class="lineno"> 6282</span>&#160;    <span class="keywordtype">bool</span> IsCorruptionDetectionEnabled() <span class="keyword">const</span>;</div>
 <div class="line"><a name="l06283"></a><span class="lineno"> 6283</span>&#160; </div>
 <div class="line"><a name="l06284"></a><span class="lineno"> 6284</span>&#160;    VkResult Allocate(</div>
@@ -8994,5927 +8994,5933 @@
 <div class="line"><a name="l11827"></a><span class="lineno">11827</span>&#160;    }</div>
 <div class="line"><a name="l11828"></a><span class="lineno">11828</span>&#160;}</div>
 <div class="line"><a name="l11829"></a><span class="lineno">11829</span>&#160; </div>
-<div class="line"><a name="l11830"></a><span class="lineno">11830</span>&#160;<span class="keywordtype">bool</span> VmaBlockVector::IsCorruptionDetectionEnabled()<span class="keyword"> const</span></div>
-<div class="line"><a name="l11831"></a><span class="lineno">11831</span>&#160;<span class="keyword"></span>{</div>
-<div class="line"><a name="l11832"></a><span class="lineno">11832</span>&#160;    <span class="keyword">const</span> uint32_t requiredMemFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;</div>
-<div class="line"><a name="l11833"></a><span class="lineno">11833</span>&#160;    <span class="keywordflow">return</span> (VMA_DEBUG_DETECT_CORRUPTION != 0) &amp;&amp;</div>
-<div class="line"><a name="l11834"></a><span class="lineno">11834</span>&#160;        (VMA_DEBUG_MARGIN &gt; 0) &amp;&amp;</div>
-<div class="line"><a name="l11835"></a><span class="lineno">11835</span>&#160;        (m_Algorithm == 0 || m_Algorithm == <a class="code" href="vk__mem__alloc_8h.html#a9a7c45f9c863695d98c83fa5ac940fe7a13c8a444197c67866be9cb05599fc726">VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT</a>) &amp;&amp;</div>
-<div class="line"><a name="l11836"></a><span class="lineno">11836</span>&#160;        (m_hAllocator-&gt;m_MemProps.memoryTypes[m_MemoryTypeIndex].propertyFlags &amp; requiredMemFlags) == requiredMemFlags;</div>
-<div class="line"><a name="l11837"></a><span class="lineno">11837</span>&#160;}</div>
-<div class="line"><a name="l11838"></a><span class="lineno">11838</span>&#160; </div>
-<div class="line"><a name="l11839"></a><span class="lineno">11839</span>&#160;<span class="keyword">static</span> <span class="keyword">const</span> uint32_t VMA_ALLOCATION_TRY_COUNT = 32;</div>
-<div class="line"><a name="l11840"></a><span class="lineno">11840</span>&#160; </div>
-<div class="line"><a name="l11841"></a><span class="lineno">11841</span>&#160;VkResult VmaBlockVector::Allocate(</div>
-<div class="line"><a name="l11842"></a><span class="lineno">11842</span>&#160;    uint32_t currentFrameIndex,</div>
-<div class="line"><a name="l11843"></a><span class="lineno">11843</span>&#160;    VkDeviceSize size,</div>
-<div class="line"><a name="l11844"></a><span class="lineno">11844</span>&#160;    VkDeviceSize alignment,</div>
-<div class="line"><a name="l11845"></a><span class="lineno">11845</span>&#160;    <span class="keyword">const</span> <a class="code" href="struct_vma_allocation_create_info.html">VmaAllocationCreateInfo</a>&amp; createInfo,</div>
-<div class="line"><a name="l11846"></a><span class="lineno">11846</span>&#160;    VmaSuballocationType suballocType,</div>
-<div class="line"><a name="l11847"></a><span class="lineno">11847</span>&#160;    <span class="keywordtype">size_t</span> allocationCount,</div>
-<div class="line"><a name="l11848"></a><span class="lineno">11848</span>&#160;    <a class="code" href="struct_vma_allocation.html">VmaAllocation</a>* pAllocations)</div>
-<div class="line"><a name="l11849"></a><span class="lineno">11849</span>&#160;{</div>
-<div class="line"><a name="l11850"></a><span class="lineno">11850</span>&#160;    <span class="keywordtype">size_t</span> allocIndex;</div>
-<div class="line"><a name="l11851"></a><span class="lineno">11851</span>&#160;    VkResult res = VK_SUCCESS;</div>
-<div class="line"><a name="l11852"></a><span class="lineno">11852</span>&#160; </div>
-<div class="line"><a name="l11853"></a><span class="lineno">11853</span>&#160;    <span class="keywordflow">if</span>(IsCorruptionDetectionEnabled())</div>
-<div class="line"><a name="l11854"></a><span class="lineno">11854</span>&#160;    {</div>
-<div class="line"><a name="l11855"></a><span class="lineno">11855</span>&#160;        size = VmaAlignUp&lt;VkDeviceSize&gt;(size, <span class="keyword">sizeof</span>(VMA_CORRUPTION_DETECTION_MAGIC_VALUE));</div>
-<div class="line"><a name="l11856"></a><span class="lineno">11856</span>&#160;        alignment = VmaAlignUp&lt;VkDeviceSize&gt;(alignment, <span class="keyword">sizeof</span>(VMA_CORRUPTION_DETECTION_MAGIC_VALUE));</div>
-<div class="line"><a name="l11857"></a><span class="lineno">11857</span>&#160;    }</div>
+<div class="line"><a name="l11830"></a><span class="lineno">11830</span>&#160;<span class="keywordtype">bool</span> VmaBlockVector::IsEmpty()</div>
+<div class="line"><a name="l11831"></a><span class="lineno">11831</span>&#160;{</div>
+<div class="line"><a name="l11832"></a><span class="lineno">11832</span>&#160;    VmaMutexLockRead lock(m_Mutex, m_hAllocator-&gt;m_UseMutex);</div>
+<div class="line"><a name="l11833"></a><span class="lineno">11833</span>&#160;    <span class="keywordflow">return</span> m_Blocks.empty();</div>
+<div class="line"><a name="l11834"></a><span class="lineno">11834</span>&#160;}</div>
+<div class="line"><a name="l11835"></a><span class="lineno">11835</span>&#160; </div>
+<div class="line"><a name="l11836"></a><span class="lineno">11836</span>&#160;<span class="keywordtype">bool</span> VmaBlockVector::IsCorruptionDetectionEnabled()<span class="keyword"> const</span></div>
+<div class="line"><a name="l11837"></a><span class="lineno">11837</span>&#160;<span class="keyword"></span>{</div>
+<div class="line"><a name="l11838"></a><span class="lineno">11838</span>&#160;    <span class="keyword">const</span> uint32_t requiredMemFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;</div>
+<div class="line"><a name="l11839"></a><span class="lineno">11839</span>&#160;    <span class="keywordflow">return</span> (VMA_DEBUG_DETECT_CORRUPTION != 0) &amp;&amp;</div>
+<div class="line"><a name="l11840"></a><span class="lineno">11840</span>&#160;        (VMA_DEBUG_MARGIN &gt; 0) &amp;&amp;</div>
+<div class="line"><a name="l11841"></a><span class="lineno">11841</span>&#160;        (m_Algorithm == 0 || m_Algorithm == <a class="code" href="vk__mem__alloc_8h.html#a9a7c45f9c863695d98c83fa5ac940fe7a13c8a444197c67866be9cb05599fc726">VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT</a>) &amp;&amp;</div>
+<div class="line"><a name="l11842"></a><span class="lineno">11842</span>&#160;        (m_hAllocator-&gt;m_MemProps.memoryTypes[m_MemoryTypeIndex].propertyFlags &amp; requiredMemFlags) == requiredMemFlags;</div>
+<div class="line"><a name="l11843"></a><span class="lineno">11843</span>&#160;}</div>
+<div class="line"><a name="l11844"></a><span class="lineno">11844</span>&#160; </div>
+<div class="line"><a name="l11845"></a><span class="lineno">11845</span>&#160;<span class="keyword">static</span> <span class="keyword">const</span> uint32_t VMA_ALLOCATION_TRY_COUNT = 32;</div>
+<div class="line"><a name="l11846"></a><span class="lineno">11846</span>&#160; </div>
+<div class="line"><a name="l11847"></a><span class="lineno">11847</span>&#160;VkResult VmaBlockVector::Allocate(</div>
+<div class="line"><a name="l11848"></a><span class="lineno">11848</span>&#160;    uint32_t currentFrameIndex,</div>
+<div class="line"><a name="l11849"></a><span class="lineno">11849</span>&#160;    VkDeviceSize size,</div>
+<div class="line"><a name="l11850"></a><span class="lineno">11850</span>&#160;    VkDeviceSize alignment,</div>
+<div class="line"><a name="l11851"></a><span class="lineno">11851</span>&#160;    <span class="keyword">const</span> <a class="code" href="struct_vma_allocation_create_info.html">VmaAllocationCreateInfo</a>&amp; createInfo,</div>
+<div class="line"><a name="l11852"></a><span class="lineno">11852</span>&#160;    VmaSuballocationType suballocType,</div>
+<div class="line"><a name="l11853"></a><span class="lineno">11853</span>&#160;    <span class="keywordtype">size_t</span> allocationCount,</div>
+<div class="line"><a name="l11854"></a><span class="lineno">11854</span>&#160;    <a class="code" href="struct_vma_allocation.html">VmaAllocation</a>* pAllocations)</div>
+<div class="line"><a name="l11855"></a><span class="lineno">11855</span>&#160;{</div>
+<div class="line"><a name="l11856"></a><span class="lineno">11856</span>&#160;    <span class="keywordtype">size_t</span> allocIndex;</div>
+<div class="line"><a name="l11857"></a><span class="lineno">11857</span>&#160;    VkResult res = VK_SUCCESS;</div>
 <div class="line"><a name="l11858"></a><span class="lineno">11858</span>&#160; </div>
-<div class="line"><a name="l11859"></a><span class="lineno">11859</span>&#160;    {</div>
-<div class="line"><a name="l11860"></a><span class="lineno">11860</span>&#160;        VmaMutexLockWrite lock(m_Mutex, m_hAllocator-&gt;m_UseMutex);</div>
-<div class="line"><a name="l11861"></a><span class="lineno">11861</span>&#160;        <span class="keywordflow">for</span>(allocIndex = 0; allocIndex &lt; allocationCount; ++allocIndex)</div>
-<div class="line"><a name="l11862"></a><span class="lineno">11862</span>&#160;        {</div>
-<div class="line"><a name="l11863"></a><span class="lineno">11863</span>&#160;            res = AllocatePage(</div>
-<div class="line"><a name="l11864"></a><span class="lineno">11864</span>&#160;                currentFrameIndex,</div>
-<div class="line"><a name="l11865"></a><span class="lineno">11865</span>&#160;                size,</div>
-<div class="line"><a name="l11866"></a><span class="lineno">11866</span>&#160;                alignment,</div>
-<div class="line"><a name="l11867"></a><span class="lineno">11867</span>&#160;                createInfo,</div>
-<div class="line"><a name="l11868"></a><span class="lineno">11868</span>&#160;                suballocType,</div>
-<div class="line"><a name="l11869"></a><span class="lineno">11869</span>&#160;                pAllocations + allocIndex);</div>
-<div class="line"><a name="l11870"></a><span class="lineno">11870</span>&#160;            <span class="keywordflow">if</span>(res != VK_SUCCESS)</div>
-<div class="line"><a name="l11871"></a><span class="lineno">11871</span>&#160;            {</div>
-<div class="line"><a name="l11872"></a><span class="lineno">11872</span>&#160;                <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l11873"></a><span class="lineno">11873</span>&#160;            }</div>
-<div class="line"><a name="l11874"></a><span class="lineno">11874</span>&#160;        }</div>
-<div class="line"><a name="l11875"></a><span class="lineno">11875</span>&#160;    }</div>
-<div class="line"><a name="l11876"></a><span class="lineno">11876</span>&#160; </div>
-<div class="line"><a name="l11877"></a><span class="lineno">11877</span>&#160;    <span class="keywordflow">if</span>(res != VK_SUCCESS)</div>
-<div class="line"><a name="l11878"></a><span class="lineno">11878</span>&#160;    {</div>
-<div class="line"><a name="l11879"></a><span class="lineno">11879</span>&#160;        <span class="comment">// Free all already created allocations.</span></div>
-<div class="line"><a name="l11880"></a><span class="lineno">11880</span>&#160;        <span class="keywordflow">while</span>(allocIndex--)</div>
-<div class="line"><a name="l11881"></a><span class="lineno">11881</span>&#160;        {</div>
-<div class="line"><a name="l11882"></a><span class="lineno">11882</span>&#160;            Free(pAllocations[allocIndex]);</div>
-<div class="line"><a name="l11883"></a><span class="lineno">11883</span>&#160;        }</div>
-<div class="line"><a name="l11884"></a><span class="lineno">11884</span>&#160;        memset(pAllocations, 0, <span class="keyword">sizeof</span>(<a class="code" href="struct_vma_allocation.html">VmaAllocation</a>) * allocationCount);</div>
-<div class="line"><a name="l11885"></a><span class="lineno">11885</span>&#160;    }</div>
-<div class="line"><a name="l11886"></a><span class="lineno">11886</span>&#160; </div>
-<div class="line"><a name="l11887"></a><span class="lineno">11887</span>&#160;    <span class="keywordflow">return</span> res;</div>
-<div class="line"><a name="l11888"></a><span class="lineno">11888</span>&#160;}</div>
-<div class="line"><a name="l11889"></a><span class="lineno">11889</span>&#160; </div>
-<div class="line"><a name="l11890"></a><span class="lineno">11890</span>&#160;VkResult VmaBlockVector::AllocatePage(</div>
-<div class="line"><a name="l11891"></a><span class="lineno">11891</span>&#160;    uint32_t currentFrameIndex,</div>
-<div class="line"><a name="l11892"></a><span class="lineno">11892</span>&#160;    VkDeviceSize size,</div>
-<div class="line"><a name="l11893"></a><span class="lineno">11893</span>&#160;    VkDeviceSize alignment,</div>
-<div class="line"><a name="l11894"></a><span class="lineno">11894</span>&#160;    <span class="keyword">const</span> <a class="code" href="struct_vma_allocation_create_info.html">VmaAllocationCreateInfo</a>&amp; createInfo,</div>
-<div class="line"><a name="l11895"></a><span class="lineno">11895</span>&#160;    VmaSuballocationType suballocType,</div>
-<div class="line"><a name="l11896"></a><span class="lineno">11896</span>&#160;    <a class="code" href="struct_vma_allocation.html">VmaAllocation</a>* pAllocation)</div>
-<div class="line"><a name="l11897"></a><span class="lineno">11897</span>&#160;{</div>
-<div class="line"><a name="l11898"></a><span class="lineno">11898</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> isUpperAddress = (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a42ba3a2d2c7117953210b7c3ef8da0df">VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT</a>) != 0;</div>
-<div class="line"><a name="l11899"></a><span class="lineno">11899</span>&#160;    <span class="keywordtype">bool</span> canMakeOtherLost = (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a68686d0ce9beb0d4d1b9f2b8b1389a7e">VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT</a>) != 0;</div>
-<div class="line"><a name="l11900"></a><span class="lineno">11900</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> mapped = (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a11da372cc3a82931c5e5d6146cd9dd1f">VMA_ALLOCATION_CREATE_MAPPED_BIT</a>) != 0;</div>
-<div class="line"><a name="l11901"></a><span class="lineno">11901</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> isUserDataString = (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597aa6f24f821cd6a7c5e4a443f7bf59c520">VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT</a>) != 0;</div>
-<div class="line"><a name="l11902"></a><span class="lineno">11902</span>&#160;    </div>
-<div class="line"><a name="l11903"></a><span class="lineno">11903</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> withinBudget = (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597ab8b1764f3e9022368e440c057783b92d">VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT</a>) != 0;</div>
-<div class="line"><a name="l11904"></a><span class="lineno">11904</span>&#160;    VkDeviceSize freeMemory;</div>
-<div class="line"><a name="l11905"></a><span class="lineno">11905</span>&#160;    {</div>
-<div class="line"><a name="l11906"></a><span class="lineno">11906</span>&#160;        <span class="keyword">const</span> uint32_t heapIndex = m_hAllocator-&gt;MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex);</div>
-<div class="line"><a name="l11907"></a><span class="lineno">11907</span>&#160;        <a class="code" href="struct_vma_budget.html">VmaBudget</a> heapBudget = {};</div>
-<div class="line"><a name="l11908"></a><span class="lineno">11908</span>&#160;        m_hAllocator-&gt;GetBudget(&amp;heapBudget, heapIndex, 1);</div>
-<div class="line"><a name="l11909"></a><span class="lineno">11909</span>&#160;        freeMemory = (heapBudget.<a class="code" href="struct_vma_budget.html#a84dd1ecca8b0110259eb206dbadb11f6">usage</a> &lt; heapBudget.<a class="code" href="struct_vma_budget.html#ab82e1d1754c2d210d0bdf90220bc6cdd">budget</a>) ? (heapBudget.<a class="code" href="struct_vma_budget.html#ab82e1d1754c2d210d0bdf90220bc6cdd">budget</a> - heapBudget.<a class="code" href="struct_vma_budget.html#a84dd1ecca8b0110259eb206dbadb11f6">usage</a>) : 0;</div>
-<div class="line"><a name="l11910"></a><span class="lineno">11910</span>&#160;    }</div>
-<div class="line"><a name="l11911"></a><span class="lineno">11911</span>&#160;    </div>
-<div class="line"><a name="l11912"></a><span class="lineno">11912</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> canFallbackToDedicated = !IsCustomPool();</div>
-<div class="line"><a name="l11913"></a><span class="lineno">11913</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> canCreateNewBlock =</div>
-<div class="line"><a name="l11914"></a><span class="lineno">11914</span>&#160;        ((createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a89759603401014eb325eb22a3839f2ff">VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT</a>) == 0) &amp;&amp;</div>
-<div class="line"><a name="l11915"></a><span class="lineno">11915</span>&#160;        (m_Blocks.size() &lt; m_MaxBlockCount) &amp;&amp;</div>
-<div class="line"><a name="l11916"></a><span class="lineno">11916</span>&#160;        (freeMemory &gt;= size || !canFallbackToDedicated);</div>
-<div class="line"><a name="l11917"></a><span class="lineno">11917</span>&#160;    uint32_t strategy = createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a8e16845d81ae3d27c47106d4770d5c7e">VMA_ALLOCATION_CREATE_STRATEGY_MASK</a>;</div>
-<div class="line"><a name="l11918"></a><span class="lineno">11918</span>&#160; </div>
-<div class="line"><a name="l11919"></a><span class="lineno">11919</span>&#160;    <span class="comment">// If linearAlgorithm is used, canMakeOtherLost is available only when used as ring buffer.</span></div>
-<div class="line"><a name="l11920"></a><span class="lineno">11920</span>&#160;    <span class="comment">// Which in turn is available only when maxBlockCount = 1.</span></div>
-<div class="line"><a name="l11921"></a><span class="lineno">11921</span>&#160;    <span class="keywordflow">if</span>(m_Algorithm == <a class="code" href="vk__mem__alloc_8h.html#a9a7c45f9c863695d98c83fa5ac940fe7a13c8a444197c67866be9cb05599fc726">VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT</a> &amp;&amp; m_MaxBlockCount &gt; 1)</div>
-<div class="line"><a name="l11922"></a><span class="lineno">11922</span>&#160;    {</div>
-<div class="line"><a name="l11923"></a><span class="lineno">11923</span>&#160;        canMakeOtherLost = <span class="keyword">false</span>;</div>
-<div class="line"><a name="l11924"></a><span class="lineno">11924</span>&#160;    }</div>
-<div class="line"><a name="l11925"></a><span class="lineno">11925</span>&#160; </div>
-<div class="line"><a name="l11926"></a><span class="lineno">11926</span>&#160;    <span class="comment">// Upper address can only be used with linear allocator and within single memory block.</span></div>
-<div class="line"><a name="l11927"></a><span class="lineno">11927</span>&#160;    <span class="keywordflow">if</span>(isUpperAddress &amp;&amp;</div>
-<div class="line"><a name="l11928"></a><span class="lineno">11928</span>&#160;        (m_Algorithm != <a class="code" href="vk__mem__alloc_8h.html#a9a7c45f9c863695d98c83fa5ac940fe7a13c8a444197c67866be9cb05599fc726">VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT</a> || m_MaxBlockCount &gt; 1))</div>
-<div class="line"><a name="l11929"></a><span class="lineno">11929</span>&#160;    {</div>
-<div class="line"><a name="l11930"></a><span class="lineno">11930</span>&#160;        <span class="keywordflow">return</span> VK_ERROR_FEATURE_NOT_PRESENT;</div>
-<div class="line"><a name="l11931"></a><span class="lineno">11931</span>&#160;    }</div>
-<div class="line"><a name="l11932"></a><span class="lineno">11932</span>&#160; </div>
-<div class="line"><a name="l11933"></a><span class="lineno">11933</span>&#160;    <span class="comment">// Validate strategy.</span></div>
-<div class="line"><a name="l11934"></a><span class="lineno">11934</span>&#160;    <span class="keywordflow">switch</span>(strategy)</div>
+<div class="line"><a name="l11859"></a><span class="lineno">11859</span>&#160;    <span class="keywordflow">if</span>(IsCorruptionDetectionEnabled())</div>
+<div class="line"><a name="l11860"></a><span class="lineno">11860</span>&#160;    {</div>
+<div class="line"><a name="l11861"></a><span class="lineno">11861</span>&#160;        size = VmaAlignUp&lt;VkDeviceSize&gt;(size, <span class="keyword">sizeof</span>(VMA_CORRUPTION_DETECTION_MAGIC_VALUE));</div>
+<div class="line"><a name="l11862"></a><span class="lineno">11862</span>&#160;        alignment = VmaAlignUp&lt;VkDeviceSize&gt;(alignment, <span class="keyword">sizeof</span>(VMA_CORRUPTION_DETECTION_MAGIC_VALUE));</div>
+<div class="line"><a name="l11863"></a><span class="lineno">11863</span>&#160;    }</div>
+<div class="line"><a name="l11864"></a><span class="lineno">11864</span>&#160; </div>
+<div class="line"><a name="l11865"></a><span class="lineno">11865</span>&#160;    {</div>
+<div class="line"><a name="l11866"></a><span class="lineno">11866</span>&#160;        VmaMutexLockWrite lock(m_Mutex, m_hAllocator-&gt;m_UseMutex);</div>
+<div class="line"><a name="l11867"></a><span class="lineno">11867</span>&#160;        <span class="keywordflow">for</span>(allocIndex = 0; allocIndex &lt; allocationCount; ++allocIndex)</div>
+<div class="line"><a name="l11868"></a><span class="lineno">11868</span>&#160;        {</div>
+<div class="line"><a name="l11869"></a><span class="lineno">11869</span>&#160;            res = AllocatePage(</div>
+<div class="line"><a name="l11870"></a><span class="lineno">11870</span>&#160;                currentFrameIndex,</div>
+<div class="line"><a name="l11871"></a><span class="lineno">11871</span>&#160;                size,</div>
+<div class="line"><a name="l11872"></a><span class="lineno">11872</span>&#160;                alignment,</div>
+<div class="line"><a name="l11873"></a><span class="lineno">11873</span>&#160;                createInfo,</div>
+<div class="line"><a name="l11874"></a><span class="lineno">11874</span>&#160;                suballocType,</div>
+<div class="line"><a name="l11875"></a><span class="lineno">11875</span>&#160;                pAllocations + allocIndex);</div>
+<div class="line"><a name="l11876"></a><span class="lineno">11876</span>&#160;            <span class="keywordflow">if</span>(res != VK_SUCCESS)</div>
+<div class="line"><a name="l11877"></a><span class="lineno">11877</span>&#160;            {</div>
+<div class="line"><a name="l11878"></a><span class="lineno">11878</span>&#160;                <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l11879"></a><span class="lineno">11879</span>&#160;            }</div>
+<div class="line"><a name="l11880"></a><span class="lineno">11880</span>&#160;        }</div>
+<div class="line"><a name="l11881"></a><span class="lineno">11881</span>&#160;    }</div>
+<div class="line"><a name="l11882"></a><span class="lineno">11882</span>&#160; </div>
+<div class="line"><a name="l11883"></a><span class="lineno">11883</span>&#160;    <span class="keywordflow">if</span>(res != VK_SUCCESS)</div>
+<div class="line"><a name="l11884"></a><span class="lineno">11884</span>&#160;    {</div>
+<div class="line"><a name="l11885"></a><span class="lineno">11885</span>&#160;        <span class="comment">// Free all already created allocations.</span></div>
+<div class="line"><a name="l11886"></a><span class="lineno">11886</span>&#160;        <span class="keywordflow">while</span>(allocIndex--)</div>
+<div class="line"><a name="l11887"></a><span class="lineno">11887</span>&#160;        {</div>
+<div class="line"><a name="l11888"></a><span class="lineno">11888</span>&#160;            Free(pAllocations[allocIndex]);</div>
+<div class="line"><a name="l11889"></a><span class="lineno">11889</span>&#160;        }</div>
+<div class="line"><a name="l11890"></a><span class="lineno">11890</span>&#160;        memset(pAllocations, 0, <span class="keyword">sizeof</span>(<a class="code" href="struct_vma_allocation.html">VmaAllocation</a>) * allocationCount);</div>
+<div class="line"><a name="l11891"></a><span class="lineno">11891</span>&#160;    }</div>
+<div class="line"><a name="l11892"></a><span class="lineno">11892</span>&#160; </div>
+<div class="line"><a name="l11893"></a><span class="lineno">11893</span>&#160;    <span class="keywordflow">return</span> res;</div>
+<div class="line"><a name="l11894"></a><span class="lineno">11894</span>&#160;}</div>
+<div class="line"><a name="l11895"></a><span class="lineno">11895</span>&#160; </div>
+<div class="line"><a name="l11896"></a><span class="lineno">11896</span>&#160;VkResult VmaBlockVector::AllocatePage(</div>
+<div class="line"><a name="l11897"></a><span class="lineno">11897</span>&#160;    uint32_t currentFrameIndex,</div>
+<div class="line"><a name="l11898"></a><span class="lineno">11898</span>&#160;    VkDeviceSize size,</div>
+<div class="line"><a name="l11899"></a><span class="lineno">11899</span>&#160;    VkDeviceSize alignment,</div>
+<div class="line"><a name="l11900"></a><span class="lineno">11900</span>&#160;    <span class="keyword">const</span> <a class="code" href="struct_vma_allocation_create_info.html">VmaAllocationCreateInfo</a>&amp; createInfo,</div>
+<div class="line"><a name="l11901"></a><span class="lineno">11901</span>&#160;    VmaSuballocationType suballocType,</div>
+<div class="line"><a name="l11902"></a><span class="lineno">11902</span>&#160;    <a class="code" href="struct_vma_allocation.html">VmaAllocation</a>* pAllocation)</div>
+<div class="line"><a name="l11903"></a><span class="lineno">11903</span>&#160;{</div>
+<div class="line"><a name="l11904"></a><span class="lineno">11904</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> isUpperAddress = (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a42ba3a2d2c7117953210b7c3ef8da0df">VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT</a>) != 0;</div>
+<div class="line"><a name="l11905"></a><span class="lineno">11905</span>&#160;    <span class="keywordtype">bool</span> canMakeOtherLost = (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a68686d0ce9beb0d4d1b9f2b8b1389a7e">VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT</a>) != 0;</div>
+<div class="line"><a name="l11906"></a><span class="lineno">11906</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> mapped = (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a11da372cc3a82931c5e5d6146cd9dd1f">VMA_ALLOCATION_CREATE_MAPPED_BIT</a>) != 0;</div>
+<div class="line"><a name="l11907"></a><span class="lineno">11907</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> isUserDataString = (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597aa6f24f821cd6a7c5e4a443f7bf59c520">VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT</a>) != 0;</div>
+<div class="line"><a name="l11908"></a><span class="lineno">11908</span>&#160;    </div>
+<div class="line"><a name="l11909"></a><span class="lineno">11909</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> withinBudget = (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597ab8b1764f3e9022368e440c057783b92d">VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT</a>) != 0;</div>
+<div class="line"><a name="l11910"></a><span class="lineno">11910</span>&#160;    VkDeviceSize freeMemory;</div>
+<div class="line"><a name="l11911"></a><span class="lineno">11911</span>&#160;    {</div>
+<div class="line"><a name="l11912"></a><span class="lineno">11912</span>&#160;        <span class="keyword">const</span> uint32_t heapIndex = m_hAllocator-&gt;MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex);</div>
+<div class="line"><a name="l11913"></a><span class="lineno">11913</span>&#160;        <a class="code" href="struct_vma_budget.html">VmaBudget</a> heapBudget = {};</div>
+<div class="line"><a name="l11914"></a><span class="lineno">11914</span>&#160;        m_hAllocator-&gt;GetBudget(&amp;heapBudget, heapIndex, 1);</div>
+<div class="line"><a name="l11915"></a><span class="lineno">11915</span>&#160;        freeMemory = (heapBudget.<a class="code" href="struct_vma_budget.html#a84dd1ecca8b0110259eb206dbadb11f6">usage</a> &lt; heapBudget.<a class="code" href="struct_vma_budget.html#ab82e1d1754c2d210d0bdf90220bc6cdd">budget</a>) ? (heapBudget.<a class="code" href="struct_vma_budget.html#ab82e1d1754c2d210d0bdf90220bc6cdd">budget</a> - heapBudget.<a class="code" href="struct_vma_budget.html#a84dd1ecca8b0110259eb206dbadb11f6">usage</a>) : 0;</div>
+<div class="line"><a name="l11916"></a><span class="lineno">11916</span>&#160;    }</div>
+<div class="line"><a name="l11917"></a><span class="lineno">11917</span>&#160;    </div>
+<div class="line"><a name="l11918"></a><span class="lineno">11918</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> canFallbackToDedicated = !IsCustomPool();</div>
+<div class="line"><a name="l11919"></a><span class="lineno">11919</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> canCreateNewBlock =</div>
+<div class="line"><a name="l11920"></a><span class="lineno">11920</span>&#160;        ((createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a89759603401014eb325eb22a3839f2ff">VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT</a>) == 0) &amp;&amp;</div>
+<div class="line"><a name="l11921"></a><span class="lineno">11921</span>&#160;        (m_Blocks.size() &lt; m_MaxBlockCount) &amp;&amp;</div>
+<div class="line"><a name="l11922"></a><span class="lineno">11922</span>&#160;        (freeMemory &gt;= size || !canFallbackToDedicated);</div>
+<div class="line"><a name="l11923"></a><span class="lineno">11923</span>&#160;    uint32_t strategy = createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a8e16845d81ae3d27c47106d4770d5c7e">VMA_ALLOCATION_CREATE_STRATEGY_MASK</a>;</div>
+<div class="line"><a name="l11924"></a><span class="lineno">11924</span>&#160; </div>
+<div class="line"><a name="l11925"></a><span class="lineno">11925</span>&#160;    <span class="comment">// If linearAlgorithm is used, canMakeOtherLost is available only when used as ring buffer.</span></div>
+<div class="line"><a name="l11926"></a><span class="lineno">11926</span>&#160;    <span class="comment">// Which in turn is available only when maxBlockCount = 1.</span></div>
+<div class="line"><a name="l11927"></a><span class="lineno">11927</span>&#160;    <span class="keywordflow">if</span>(m_Algorithm == <a class="code" href="vk__mem__alloc_8h.html#a9a7c45f9c863695d98c83fa5ac940fe7a13c8a444197c67866be9cb05599fc726">VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT</a> &amp;&amp; m_MaxBlockCount &gt; 1)</div>
+<div class="line"><a name="l11928"></a><span class="lineno">11928</span>&#160;    {</div>
+<div class="line"><a name="l11929"></a><span class="lineno">11929</span>&#160;        canMakeOtherLost = <span class="keyword">false</span>;</div>
+<div class="line"><a name="l11930"></a><span class="lineno">11930</span>&#160;    }</div>
+<div class="line"><a name="l11931"></a><span class="lineno">11931</span>&#160; </div>
+<div class="line"><a name="l11932"></a><span class="lineno">11932</span>&#160;    <span class="comment">// Upper address can only be used with linear allocator and within single memory block.</span></div>
+<div class="line"><a name="l11933"></a><span class="lineno">11933</span>&#160;    <span class="keywordflow">if</span>(isUpperAddress &amp;&amp;</div>
+<div class="line"><a name="l11934"></a><span class="lineno">11934</span>&#160;        (m_Algorithm != <a class="code" href="vk__mem__alloc_8h.html#a9a7c45f9c863695d98c83fa5ac940fe7a13c8a444197c67866be9cb05599fc726">VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT</a> || m_MaxBlockCount &gt; 1))</div>
 <div class="line"><a name="l11935"></a><span class="lineno">11935</span>&#160;    {</div>
-<div class="line"><a name="l11936"></a><span class="lineno">11936</span>&#160;    <span class="keywordflow">case</span> 0:</div>
-<div class="line"><a name="l11937"></a><span class="lineno">11937</span>&#160;        strategy = <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a839826775c62319466441f86496f036d">VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT</a>;</div>
-<div class="line"><a name="l11938"></a><span class="lineno">11938</span>&#160;        <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l11939"></a><span class="lineno">11939</span>&#160;    <span class="keywordflow">case</span> <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a839826775c62319466441f86496f036d">VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT</a>:</div>
-<div class="line"><a name="l11940"></a><span class="lineno">11940</span>&#160;    <span class="keywordflow">case</span> <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597ad242a04f802e25fef0b880afe8bb0a62">VMA_ALLOCATION_CREATE_STRATEGY_WORST_FIT_BIT</a>:</div>
-<div class="line"><a name="l11941"></a><span class="lineno">11941</span>&#160;    <span class="keywordflow">case</span> <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a33eb2052674f3ad92386c714a65fb777">VMA_ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT</a>:</div>
-<div class="line"><a name="l11942"></a><span class="lineno">11942</span>&#160;        <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l11943"></a><span class="lineno">11943</span>&#160;    <span class="keywordflow">default</span>:</div>
-<div class="line"><a name="l11944"></a><span class="lineno">11944</span>&#160;        <span class="keywordflow">return</span> VK_ERROR_FEATURE_NOT_PRESENT;</div>
-<div class="line"><a name="l11945"></a><span class="lineno">11945</span>&#160;    }</div>
-<div class="line"><a name="l11946"></a><span class="lineno">11946</span>&#160; </div>
-<div class="line"><a name="l11947"></a><span class="lineno">11947</span>&#160;    <span class="comment">// Early reject: requested allocation size is larger that maximum block size for this block vector.</span></div>
-<div class="line"><a name="l11948"></a><span class="lineno">11948</span>&#160;    <span class="keywordflow">if</span>(size + 2 * VMA_DEBUG_MARGIN &gt; m_PreferredBlockSize)</div>
-<div class="line"><a name="l11949"></a><span class="lineno">11949</span>&#160;    {</div>
-<div class="line"><a name="l11950"></a><span class="lineno">11950</span>&#160;        <span class="keywordflow">return</span> VK_ERROR_OUT_OF_DEVICE_MEMORY;</div>
+<div class="line"><a name="l11936"></a><span class="lineno">11936</span>&#160;        <span class="keywordflow">return</span> VK_ERROR_FEATURE_NOT_PRESENT;</div>
+<div class="line"><a name="l11937"></a><span class="lineno">11937</span>&#160;    }</div>
+<div class="line"><a name="l11938"></a><span class="lineno">11938</span>&#160; </div>
+<div class="line"><a name="l11939"></a><span class="lineno">11939</span>&#160;    <span class="comment">// Validate strategy.</span></div>
+<div class="line"><a name="l11940"></a><span class="lineno">11940</span>&#160;    <span class="keywordflow">switch</span>(strategy)</div>
+<div class="line"><a name="l11941"></a><span class="lineno">11941</span>&#160;    {</div>
+<div class="line"><a name="l11942"></a><span class="lineno">11942</span>&#160;    <span class="keywordflow">case</span> 0:</div>
+<div class="line"><a name="l11943"></a><span class="lineno">11943</span>&#160;        strategy = <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a839826775c62319466441f86496f036d">VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT</a>;</div>
+<div class="line"><a name="l11944"></a><span class="lineno">11944</span>&#160;        <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l11945"></a><span class="lineno">11945</span>&#160;    <span class="keywordflow">case</span> <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a839826775c62319466441f86496f036d">VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT</a>:</div>
+<div class="line"><a name="l11946"></a><span class="lineno">11946</span>&#160;    <span class="keywordflow">case</span> <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597ad242a04f802e25fef0b880afe8bb0a62">VMA_ALLOCATION_CREATE_STRATEGY_WORST_FIT_BIT</a>:</div>
+<div class="line"><a name="l11947"></a><span class="lineno">11947</span>&#160;    <span class="keywordflow">case</span> <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a33eb2052674f3ad92386c714a65fb777">VMA_ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT</a>:</div>
+<div class="line"><a name="l11948"></a><span class="lineno">11948</span>&#160;        <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l11949"></a><span class="lineno">11949</span>&#160;    <span class="keywordflow">default</span>:</div>
+<div class="line"><a name="l11950"></a><span class="lineno">11950</span>&#160;        <span class="keywordflow">return</span> VK_ERROR_FEATURE_NOT_PRESENT;</div>
 <div class="line"><a name="l11951"></a><span class="lineno">11951</span>&#160;    }</div>
 <div class="line"><a name="l11952"></a><span class="lineno">11952</span>&#160; </div>
-<div class="line"><a name="l11953"></a><span class="lineno">11953</span>&#160;    <span class="comment">/*</span></div>
-<div class="line"><a name="l11954"></a><span class="lineno">11954</span>&#160;<span class="comment">    Under certain condition, this whole section can be skipped for optimization, so</span></div>
-<div class="line"><a name="l11955"></a><span class="lineno">11955</span>&#160;<span class="comment">    we move on directly to trying to allocate with canMakeOtherLost. That&#39;s the case</span></div>
-<div class="line"><a name="l11956"></a><span class="lineno">11956</span>&#160;<span class="comment">    e.g. for custom pools with linear algorithm.</span></div>
-<div class="line"><a name="l11957"></a><span class="lineno">11957</span>&#160;<span class="comment">    */</span></div>
-<div class="line"><a name="l11958"></a><span class="lineno">11958</span>&#160;    <span class="keywordflow">if</span>(!canMakeOtherLost || canCreateNewBlock)</div>
-<div class="line"><a name="l11959"></a><span class="lineno">11959</span>&#160;    {</div>
-<div class="line"><a name="l11960"></a><span class="lineno">11960</span>&#160;        <span class="comment">// 1. Search existing allocations. Try to allocate without making other allocations lost.</span></div>
-<div class="line"><a name="l11961"></a><span class="lineno">11961</span>&#160;        <a class="code" href="vk__mem__alloc_8h.html#a5225e5e11f8376f6a31a1791f3d6e817">VmaAllocationCreateFlags</a> allocFlagsCopy = createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a>;</div>
-<div class="line"><a name="l11962"></a><span class="lineno">11962</span>&#160;        allocFlagsCopy &amp;= ~<a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a68686d0ce9beb0d4d1b9f2b8b1389a7e">VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT</a>;</div>
-<div class="line"><a name="l11963"></a><span class="lineno">11963</span>&#160; </div>
-<div class="line"><a name="l11964"></a><span class="lineno">11964</span>&#160;        <span class="keywordflow">if</span>(m_Algorithm == <a class="code" href="vk__mem__alloc_8h.html#a9a7c45f9c863695d98c83fa5ac940fe7a13c8a444197c67866be9cb05599fc726">VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT</a>)</div>
-<div class="line"><a name="l11965"></a><span class="lineno">11965</span>&#160;        {</div>
-<div class="line"><a name="l11966"></a><span class="lineno">11966</span>&#160;            <span class="comment">// Use only last block.</span></div>
-<div class="line"><a name="l11967"></a><span class="lineno">11967</span>&#160;            <span class="keywordflow">if</span>(!m_Blocks.empty())</div>
-<div class="line"><a name="l11968"></a><span class="lineno">11968</span>&#160;            {</div>
-<div class="line"><a name="l11969"></a><span class="lineno">11969</span>&#160;                VmaDeviceMemoryBlock* <span class="keyword">const</span> pCurrBlock = m_Blocks.back();</div>
-<div class="line"><a name="l11970"></a><span class="lineno">11970</span>&#160;                VMA_ASSERT(pCurrBlock);</div>
-<div class="line"><a name="l11971"></a><span class="lineno">11971</span>&#160;                VkResult res = AllocateFromBlock(</div>
-<div class="line"><a name="l11972"></a><span class="lineno">11972</span>&#160;                    pCurrBlock,</div>
-<div class="line"><a name="l11973"></a><span class="lineno">11973</span>&#160;                    currentFrameIndex,</div>
-<div class="line"><a name="l11974"></a><span class="lineno">11974</span>&#160;                    size,</div>
-<div class="line"><a name="l11975"></a><span class="lineno">11975</span>&#160;                    alignment,</div>
-<div class="line"><a name="l11976"></a><span class="lineno">11976</span>&#160;                    allocFlagsCopy,</div>
-<div class="line"><a name="l11977"></a><span class="lineno">11977</span>&#160;                    createInfo.<a class="code" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19">pUserData</a>,</div>
-<div class="line"><a name="l11978"></a><span class="lineno">11978</span>&#160;                    suballocType,</div>
-<div class="line"><a name="l11979"></a><span class="lineno">11979</span>&#160;                    strategy,</div>
-<div class="line"><a name="l11980"></a><span class="lineno">11980</span>&#160;                    pAllocation);</div>
-<div class="line"><a name="l11981"></a><span class="lineno">11981</span>&#160;                <span class="keywordflow">if</span>(res == VK_SUCCESS)</div>
-<div class="line"><a name="l11982"></a><span class="lineno">11982</span>&#160;                {</div>
-<div class="line"><a name="l11983"></a><span class="lineno">11983</span>&#160;                    VMA_DEBUG_LOG(<span class="stringliteral">&quot;    Returned from last block #%u&quot;</span>, pCurrBlock-&gt;GetId());</div>
-<div class="line"><a name="l11984"></a><span class="lineno">11984</span>&#160;                    <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l11985"></a><span class="lineno">11985</span>&#160;                }</div>
-<div class="line"><a name="l11986"></a><span class="lineno">11986</span>&#160;            }</div>
-<div class="line"><a name="l11987"></a><span class="lineno">11987</span>&#160;        }</div>
-<div class="line"><a name="l11988"></a><span class="lineno">11988</span>&#160;        <span class="keywordflow">else</span></div>
-<div class="line"><a name="l11989"></a><span class="lineno">11989</span>&#160;        {</div>
-<div class="line"><a name="l11990"></a><span class="lineno">11990</span>&#160;            <span class="keywordflow">if</span>(strategy == <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a839826775c62319466441f86496f036d">VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT</a>)</div>
-<div class="line"><a name="l11991"></a><span class="lineno">11991</span>&#160;            {</div>
-<div class="line"><a name="l11992"></a><span class="lineno">11992</span>&#160;                <span class="comment">// Forward order in m_Blocks - prefer blocks with smallest amount of free space.</span></div>
-<div class="line"><a name="l11993"></a><span class="lineno">11993</span>&#160;                <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; blockIndex &lt; m_Blocks.size(); ++blockIndex )</div>
-<div class="line"><a name="l11994"></a><span class="lineno">11994</span>&#160;                {</div>
-<div class="line"><a name="l11995"></a><span class="lineno">11995</span>&#160;                    VmaDeviceMemoryBlock* <span class="keyword">const</span> pCurrBlock = m_Blocks[blockIndex];</div>
-<div class="line"><a name="l11996"></a><span class="lineno">11996</span>&#160;                    VMA_ASSERT(pCurrBlock);</div>
-<div class="line"><a name="l11997"></a><span class="lineno">11997</span>&#160;                    VkResult res = AllocateFromBlock(</div>
-<div class="line"><a name="l11998"></a><span class="lineno">11998</span>&#160;                        pCurrBlock,</div>
-<div class="line"><a name="l11999"></a><span class="lineno">11999</span>&#160;                        currentFrameIndex,</div>
-<div class="line"><a name="l12000"></a><span class="lineno">12000</span>&#160;                        size,</div>
-<div class="line"><a name="l12001"></a><span class="lineno">12001</span>&#160;                        alignment,</div>
-<div class="line"><a name="l12002"></a><span class="lineno">12002</span>&#160;                        allocFlagsCopy,</div>
-<div class="line"><a name="l12003"></a><span class="lineno">12003</span>&#160;                        createInfo.<a class="code" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19">pUserData</a>,</div>
-<div class="line"><a name="l12004"></a><span class="lineno">12004</span>&#160;                        suballocType,</div>
-<div class="line"><a name="l12005"></a><span class="lineno">12005</span>&#160;                        strategy,</div>
-<div class="line"><a name="l12006"></a><span class="lineno">12006</span>&#160;                        pAllocation);</div>
-<div class="line"><a name="l12007"></a><span class="lineno">12007</span>&#160;                    <span class="keywordflow">if</span>(res == VK_SUCCESS)</div>
-<div class="line"><a name="l12008"></a><span class="lineno">12008</span>&#160;                    {</div>
-<div class="line"><a name="l12009"></a><span class="lineno">12009</span>&#160;                        VMA_DEBUG_LOG(<span class="stringliteral">&quot;    Returned from existing block #%u&quot;</span>, pCurrBlock-&gt;GetId());</div>
-<div class="line"><a name="l12010"></a><span class="lineno">12010</span>&#160;                        <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l12011"></a><span class="lineno">12011</span>&#160;                    }</div>
-<div class="line"><a name="l12012"></a><span class="lineno">12012</span>&#160;                }</div>
-<div class="line"><a name="l12013"></a><span class="lineno">12013</span>&#160;            }</div>
-<div class="line"><a name="l12014"></a><span class="lineno">12014</span>&#160;            <span class="keywordflow">else</span> <span class="comment">// WORST_FIT, FIRST_FIT</span></div>
-<div class="line"><a name="l12015"></a><span class="lineno">12015</span>&#160;            {</div>
-<div class="line"><a name="l12016"></a><span class="lineno">12016</span>&#160;                <span class="comment">// Backward order in m_Blocks - prefer blocks with largest amount of free space.</span></div>
-<div class="line"><a name="l12017"></a><span class="lineno">12017</span>&#160;                <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = m_Blocks.size(); blockIndex--; )</div>
-<div class="line"><a name="l12018"></a><span class="lineno">12018</span>&#160;                {</div>
-<div class="line"><a name="l12019"></a><span class="lineno">12019</span>&#160;                    VmaDeviceMemoryBlock* <span class="keyword">const</span> pCurrBlock = m_Blocks[blockIndex];</div>
-<div class="line"><a name="l12020"></a><span class="lineno">12020</span>&#160;                    VMA_ASSERT(pCurrBlock);</div>
-<div class="line"><a name="l12021"></a><span class="lineno">12021</span>&#160;                    VkResult res = AllocateFromBlock(</div>
-<div class="line"><a name="l12022"></a><span class="lineno">12022</span>&#160;                        pCurrBlock,</div>
-<div class="line"><a name="l12023"></a><span class="lineno">12023</span>&#160;                        currentFrameIndex,</div>
-<div class="line"><a name="l12024"></a><span class="lineno">12024</span>&#160;                        size,</div>
-<div class="line"><a name="l12025"></a><span class="lineno">12025</span>&#160;                        alignment,</div>
-<div class="line"><a name="l12026"></a><span class="lineno">12026</span>&#160;                        allocFlagsCopy,</div>
-<div class="line"><a name="l12027"></a><span class="lineno">12027</span>&#160;                        createInfo.<a class="code" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19">pUserData</a>,</div>
-<div class="line"><a name="l12028"></a><span class="lineno">12028</span>&#160;                        suballocType,</div>
-<div class="line"><a name="l12029"></a><span class="lineno">12029</span>&#160;                        strategy,</div>
-<div class="line"><a name="l12030"></a><span class="lineno">12030</span>&#160;                        pAllocation);</div>
-<div class="line"><a name="l12031"></a><span class="lineno">12031</span>&#160;                    <span class="keywordflow">if</span>(res == VK_SUCCESS)</div>
-<div class="line"><a name="l12032"></a><span class="lineno">12032</span>&#160;                    {</div>
-<div class="line"><a name="l12033"></a><span class="lineno">12033</span>&#160;                        VMA_DEBUG_LOG(<span class="stringliteral">&quot;    Returned from existing block #%u&quot;</span>, pCurrBlock-&gt;GetId());</div>
-<div class="line"><a name="l12034"></a><span class="lineno">12034</span>&#160;                        <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l12035"></a><span class="lineno">12035</span>&#160;                    }</div>
-<div class="line"><a name="l12036"></a><span class="lineno">12036</span>&#160;                }</div>
-<div class="line"><a name="l12037"></a><span class="lineno">12037</span>&#160;            }</div>
-<div class="line"><a name="l12038"></a><span class="lineno">12038</span>&#160;        }</div>
-<div class="line"><a name="l12039"></a><span class="lineno">12039</span>&#160; </div>
-<div class="line"><a name="l12040"></a><span class="lineno">12040</span>&#160;        <span class="comment">// 2. Try to create new block.</span></div>
-<div class="line"><a name="l12041"></a><span class="lineno">12041</span>&#160;        <span class="keywordflow">if</span>(canCreateNewBlock)</div>
-<div class="line"><a name="l12042"></a><span class="lineno">12042</span>&#160;        {</div>
-<div class="line"><a name="l12043"></a><span class="lineno">12043</span>&#160;            <span class="comment">// Calculate optimal size for new block.</span></div>
-<div class="line"><a name="l12044"></a><span class="lineno">12044</span>&#160;            VkDeviceSize newBlockSize = m_PreferredBlockSize;</div>
-<div class="line"><a name="l12045"></a><span class="lineno">12045</span>&#160;            uint32_t newBlockSizeShift = 0;</div>
-<div class="line"><a name="l12046"></a><span class="lineno">12046</span>&#160;            <span class="keyword">const</span> uint32_t NEW_BLOCK_SIZE_SHIFT_MAX = 3;</div>
-<div class="line"><a name="l12047"></a><span class="lineno">12047</span>&#160; </div>
-<div class="line"><a name="l12048"></a><span class="lineno">12048</span>&#160;            <span class="keywordflow">if</span>(!m_ExplicitBlockSize)</div>
-<div class="line"><a name="l12049"></a><span class="lineno">12049</span>&#160;            {</div>
-<div class="line"><a name="l12050"></a><span class="lineno">12050</span>&#160;                <span class="comment">// Allocate 1/8, 1/4, 1/2 as first blocks.</span></div>
-<div class="line"><a name="l12051"></a><span class="lineno">12051</span>&#160;                <span class="keyword">const</span> VkDeviceSize maxExistingBlockSize = CalcMaxBlockSize();</div>
-<div class="line"><a name="l12052"></a><span class="lineno">12052</span>&#160;                <span class="keywordflow">for</span>(uint32_t i = 0; i &lt; NEW_BLOCK_SIZE_SHIFT_MAX; ++i)</div>
-<div class="line"><a name="l12053"></a><span class="lineno">12053</span>&#160;                {</div>
-<div class="line"><a name="l12054"></a><span class="lineno">12054</span>&#160;                    <span class="keyword">const</span> VkDeviceSize smallerNewBlockSize = newBlockSize / 2;</div>
-<div class="line"><a name="l12055"></a><span class="lineno">12055</span>&#160;                    <span class="keywordflow">if</span>(smallerNewBlockSize &gt; maxExistingBlockSize &amp;&amp; smallerNewBlockSize &gt;= size * 2)</div>
-<div class="line"><a name="l12056"></a><span class="lineno">12056</span>&#160;                    {</div>
-<div class="line"><a name="l12057"></a><span class="lineno">12057</span>&#160;                        newBlockSize = smallerNewBlockSize;</div>
-<div class="line"><a name="l12058"></a><span class="lineno">12058</span>&#160;                        ++newBlockSizeShift;</div>
-<div class="line"><a name="l12059"></a><span class="lineno">12059</span>&#160;                    }</div>
-<div class="line"><a name="l12060"></a><span class="lineno">12060</span>&#160;                    <span class="keywordflow">else</span></div>
-<div class="line"><a name="l12061"></a><span class="lineno">12061</span>&#160;                    {</div>
-<div class="line"><a name="l12062"></a><span class="lineno">12062</span>&#160;                        <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l12063"></a><span class="lineno">12063</span>&#160;                    }</div>
-<div class="line"><a name="l12064"></a><span class="lineno">12064</span>&#160;                }</div>
-<div class="line"><a name="l12065"></a><span class="lineno">12065</span>&#160;            }</div>
-<div class="line"><a name="l12066"></a><span class="lineno">12066</span>&#160; </div>
-<div class="line"><a name="l12067"></a><span class="lineno">12067</span>&#160;            <span class="keywordtype">size_t</span> newBlockIndex = 0;</div>
-<div class="line"><a name="l12068"></a><span class="lineno">12068</span>&#160;            VkResult res = (newBlockSize &lt;= freeMemory || !canFallbackToDedicated) ?</div>
-<div class="line"><a name="l12069"></a><span class="lineno">12069</span>&#160;                CreateBlock(newBlockSize, &amp;newBlockIndex) : VK_ERROR_OUT_OF_DEVICE_MEMORY;</div>
-<div class="line"><a name="l12070"></a><span class="lineno">12070</span>&#160;            <span class="comment">// Allocation of this size failed? Try 1/2, 1/4, 1/8 of m_PreferredBlockSize.</span></div>
-<div class="line"><a name="l12071"></a><span class="lineno">12071</span>&#160;            <span class="keywordflow">if</span>(!m_ExplicitBlockSize)</div>
-<div class="line"><a name="l12072"></a><span class="lineno">12072</span>&#160;            {</div>
-<div class="line"><a name="l12073"></a><span class="lineno">12073</span>&#160;                <span class="keywordflow">while</span>(res &lt; 0 &amp;&amp; newBlockSizeShift &lt; NEW_BLOCK_SIZE_SHIFT_MAX)</div>
-<div class="line"><a name="l12074"></a><span class="lineno">12074</span>&#160;                {</div>
-<div class="line"><a name="l12075"></a><span class="lineno">12075</span>&#160;                    <span class="keyword">const</span> VkDeviceSize smallerNewBlockSize = newBlockSize / 2;</div>
-<div class="line"><a name="l12076"></a><span class="lineno">12076</span>&#160;                    <span class="keywordflow">if</span>(smallerNewBlockSize &gt;= size)</div>
-<div class="line"><a name="l12077"></a><span class="lineno">12077</span>&#160;                    {</div>
-<div class="line"><a name="l12078"></a><span class="lineno">12078</span>&#160;                        newBlockSize = smallerNewBlockSize;</div>
-<div class="line"><a name="l12079"></a><span class="lineno">12079</span>&#160;                        ++newBlockSizeShift;</div>
-<div class="line"><a name="l12080"></a><span class="lineno">12080</span>&#160;                        res = (newBlockSize &lt;= freeMemory || !canFallbackToDedicated) ?</div>
-<div class="line"><a name="l12081"></a><span class="lineno">12081</span>&#160;                            CreateBlock(newBlockSize, &amp;newBlockIndex) : VK_ERROR_OUT_OF_DEVICE_MEMORY;</div>
-<div class="line"><a name="l12082"></a><span class="lineno">12082</span>&#160;                    }</div>
-<div class="line"><a name="l12083"></a><span class="lineno">12083</span>&#160;                    <span class="keywordflow">else</span></div>
-<div class="line"><a name="l12084"></a><span class="lineno">12084</span>&#160;                    {</div>
-<div class="line"><a name="l12085"></a><span class="lineno">12085</span>&#160;                        <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l12086"></a><span class="lineno">12086</span>&#160;                    }</div>
-<div class="line"><a name="l12087"></a><span class="lineno">12087</span>&#160;                }</div>
-<div class="line"><a name="l12088"></a><span class="lineno">12088</span>&#160;            }</div>
-<div class="line"><a name="l12089"></a><span class="lineno">12089</span>&#160; </div>
-<div class="line"><a name="l12090"></a><span class="lineno">12090</span>&#160;            <span class="keywordflow">if</span>(res == VK_SUCCESS)</div>
-<div class="line"><a name="l12091"></a><span class="lineno">12091</span>&#160;            {</div>
-<div class="line"><a name="l12092"></a><span class="lineno">12092</span>&#160;                VmaDeviceMemoryBlock* <span class="keyword">const</span> pBlock = m_Blocks[newBlockIndex];</div>
-<div class="line"><a name="l12093"></a><span class="lineno">12093</span>&#160;                VMA_ASSERT(pBlock-&gt;m_pMetadata-&gt;GetSize() &gt;= size);</div>
-<div class="line"><a name="l12094"></a><span class="lineno">12094</span>&#160; </div>
-<div class="line"><a name="l12095"></a><span class="lineno">12095</span>&#160;                res = AllocateFromBlock(</div>
-<div class="line"><a name="l12096"></a><span class="lineno">12096</span>&#160;                    pBlock,</div>
-<div class="line"><a name="l12097"></a><span class="lineno">12097</span>&#160;                    currentFrameIndex,</div>
-<div class="line"><a name="l12098"></a><span class="lineno">12098</span>&#160;                    size,</div>
-<div class="line"><a name="l12099"></a><span class="lineno">12099</span>&#160;                    alignment,</div>
-<div class="line"><a name="l12100"></a><span class="lineno">12100</span>&#160;                    allocFlagsCopy,</div>
-<div class="line"><a name="l12101"></a><span class="lineno">12101</span>&#160;                    createInfo.<a class="code" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19">pUserData</a>,</div>
-<div class="line"><a name="l12102"></a><span class="lineno">12102</span>&#160;                    suballocType,</div>
-<div class="line"><a name="l12103"></a><span class="lineno">12103</span>&#160;                    strategy,</div>
-<div class="line"><a name="l12104"></a><span class="lineno">12104</span>&#160;                    pAllocation);</div>
-<div class="line"><a name="l12105"></a><span class="lineno">12105</span>&#160;                <span class="keywordflow">if</span>(res == VK_SUCCESS)</div>
-<div class="line"><a name="l12106"></a><span class="lineno">12106</span>&#160;                {</div>
-<div class="line"><a name="l12107"></a><span class="lineno">12107</span>&#160;                    VMA_DEBUG_LOG(<span class="stringliteral">&quot;    Created new block #%u Size=%llu&quot;</span>, pBlock-&gt;GetId(), newBlockSize);</div>
-<div class="line"><a name="l12108"></a><span class="lineno">12108</span>&#160;                    <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l12109"></a><span class="lineno">12109</span>&#160;                }</div>
-<div class="line"><a name="l12110"></a><span class="lineno">12110</span>&#160;                <span class="keywordflow">else</span></div>
-<div class="line"><a name="l12111"></a><span class="lineno">12111</span>&#160;                {</div>
-<div class="line"><a name="l12112"></a><span class="lineno">12112</span>&#160;                    <span class="comment">// Allocation from new block failed, possibly due to VMA_DEBUG_MARGIN or alignment.</span></div>
-<div class="line"><a name="l12113"></a><span class="lineno">12113</span>&#160;                    <span class="keywordflow">return</span> VK_ERROR_OUT_OF_DEVICE_MEMORY;</div>
-<div class="line"><a name="l12114"></a><span class="lineno">12114</span>&#160;                }</div>
-<div class="line"><a name="l12115"></a><span class="lineno">12115</span>&#160;            }</div>
-<div class="line"><a name="l12116"></a><span class="lineno">12116</span>&#160;        }</div>
-<div class="line"><a name="l12117"></a><span class="lineno">12117</span>&#160;    }</div>
-<div class="line"><a name="l12118"></a><span class="lineno">12118</span>&#160; </div>
-<div class="line"><a name="l12119"></a><span class="lineno">12119</span>&#160;    <span class="comment">// 3. Try to allocate from existing blocks with making other allocations lost.</span></div>
-<div class="line"><a name="l12120"></a><span class="lineno">12120</span>&#160;    <span class="keywordflow">if</span>(canMakeOtherLost)</div>
-<div class="line"><a name="l12121"></a><span class="lineno">12121</span>&#160;    {</div>
-<div class="line"><a name="l12122"></a><span class="lineno">12122</span>&#160;        uint32_t tryIndex = 0;</div>
-<div class="line"><a name="l12123"></a><span class="lineno">12123</span>&#160;        <span class="keywordflow">for</span>(; tryIndex &lt; VMA_ALLOCATION_TRY_COUNT; ++tryIndex)</div>
-<div class="line"><a name="l12124"></a><span class="lineno">12124</span>&#160;        {</div>
-<div class="line"><a name="l12125"></a><span class="lineno">12125</span>&#160;            VmaDeviceMemoryBlock* pBestRequestBlock = VMA_NULL;</div>
-<div class="line"><a name="l12126"></a><span class="lineno">12126</span>&#160;            VmaAllocationRequest bestRequest = {};</div>
-<div class="line"><a name="l12127"></a><span class="lineno">12127</span>&#160;            VkDeviceSize bestRequestCost = VK_WHOLE_SIZE;</div>
-<div class="line"><a name="l12128"></a><span class="lineno">12128</span>&#160; </div>
-<div class="line"><a name="l12129"></a><span class="lineno">12129</span>&#160;            <span class="comment">// 1. Search existing allocations.</span></div>
-<div class="line"><a name="l12130"></a><span class="lineno">12130</span>&#160;            <span class="keywordflow">if</span>(strategy == <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a839826775c62319466441f86496f036d">VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT</a>)</div>
-<div class="line"><a name="l12131"></a><span class="lineno">12131</span>&#160;            {</div>
-<div class="line"><a name="l12132"></a><span class="lineno">12132</span>&#160;                <span class="comment">// Forward order in m_Blocks - prefer blocks with smallest amount of free space.</span></div>
-<div class="line"><a name="l12133"></a><span class="lineno">12133</span>&#160;                <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; blockIndex &lt; m_Blocks.size(); ++blockIndex )</div>
-<div class="line"><a name="l12134"></a><span class="lineno">12134</span>&#160;                {</div>
-<div class="line"><a name="l12135"></a><span class="lineno">12135</span>&#160;                    VmaDeviceMemoryBlock* <span class="keyword">const</span> pCurrBlock = m_Blocks[blockIndex];</div>
-<div class="line"><a name="l12136"></a><span class="lineno">12136</span>&#160;                    VMA_ASSERT(pCurrBlock);</div>
-<div class="line"><a name="l12137"></a><span class="lineno">12137</span>&#160;                    VmaAllocationRequest currRequest = {};</div>
-<div class="line"><a name="l12138"></a><span class="lineno">12138</span>&#160;                    <span class="keywordflow">if</span>(pCurrBlock-&gt;m_pMetadata-&gt;CreateAllocationRequest(</div>
-<div class="line"><a name="l12139"></a><span class="lineno">12139</span>&#160;                        currentFrameIndex,</div>
-<div class="line"><a name="l12140"></a><span class="lineno">12140</span>&#160;                        m_FrameInUseCount,</div>
-<div class="line"><a name="l12141"></a><span class="lineno">12141</span>&#160;                        m_BufferImageGranularity,</div>
-<div class="line"><a name="l12142"></a><span class="lineno">12142</span>&#160;                        size,</div>
-<div class="line"><a name="l12143"></a><span class="lineno">12143</span>&#160;                        alignment,</div>
-<div class="line"><a name="l12144"></a><span class="lineno">12144</span>&#160;                        (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a42ba3a2d2c7117953210b7c3ef8da0df">VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT</a>) != 0,</div>
-<div class="line"><a name="l12145"></a><span class="lineno">12145</span>&#160;                        suballocType,</div>
-<div class="line"><a name="l12146"></a><span class="lineno">12146</span>&#160;                        canMakeOtherLost,</div>
-<div class="line"><a name="l12147"></a><span class="lineno">12147</span>&#160;                        strategy,</div>
-<div class="line"><a name="l12148"></a><span class="lineno">12148</span>&#160;                        &amp;currRequest))</div>
-<div class="line"><a name="l12149"></a><span class="lineno">12149</span>&#160;                    {</div>
-<div class="line"><a name="l12150"></a><span class="lineno">12150</span>&#160;                        <span class="keyword">const</span> VkDeviceSize currRequestCost = currRequest.CalcCost();</div>
-<div class="line"><a name="l12151"></a><span class="lineno">12151</span>&#160;                        <span class="keywordflow">if</span>(pBestRequestBlock == VMA_NULL ||</div>
-<div class="line"><a name="l12152"></a><span class="lineno">12152</span>&#160;                            currRequestCost &lt; bestRequestCost)</div>
-<div class="line"><a name="l12153"></a><span class="lineno">12153</span>&#160;                        {</div>
-<div class="line"><a name="l12154"></a><span class="lineno">12154</span>&#160;                            pBestRequestBlock = pCurrBlock;</div>
-<div class="line"><a name="l12155"></a><span class="lineno">12155</span>&#160;                            bestRequest = currRequest;</div>
-<div class="line"><a name="l12156"></a><span class="lineno">12156</span>&#160;                            bestRequestCost = currRequestCost;</div>
-<div class="line"><a name="l12157"></a><span class="lineno">12157</span>&#160; </div>
-<div class="line"><a name="l12158"></a><span class="lineno">12158</span>&#160;                            <span class="keywordflow">if</span>(bestRequestCost == 0)</div>
-<div class="line"><a name="l12159"></a><span class="lineno">12159</span>&#160;                            {</div>
-<div class="line"><a name="l12160"></a><span class="lineno">12160</span>&#160;                                <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l12161"></a><span class="lineno">12161</span>&#160;                            }</div>
-<div class="line"><a name="l12162"></a><span class="lineno">12162</span>&#160;                        }</div>
-<div class="line"><a name="l12163"></a><span class="lineno">12163</span>&#160;                    }</div>
-<div class="line"><a name="l12164"></a><span class="lineno">12164</span>&#160;                }</div>
-<div class="line"><a name="l12165"></a><span class="lineno">12165</span>&#160;            }</div>
-<div class="line"><a name="l12166"></a><span class="lineno">12166</span>&#160;            <span class="keywordflow">else</span> <span class="comment">// WORST_FIT, FIRST_FIT</span></div>
-<div class="line"><a name="l12167"></a><span class="lineno">12167</span>&#160;            {</div>
-<div class="line"><a name="l12168"></a><span class="lineno">12168</span>&#160;                <span class="comment">// Backward order in m_Blocks - prefer blocks with largest amount of free space.</span></div>
-<div class="line"><a name="l12169"></a><span class="lineno">12169</span>&#160;                <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = m_Blocks.size(); blockIndex--; )</div>
-<div class="line"><a name="l12170"></a><span class="lineno">12170</span>&#160;                {</div>
-<div class="line"><a name="l12171"></a><span class="lineno">12171</span>&#160;                    VmaDeviceMemoryBlock* <span class="keyword">const</span> pCurrBlock = m_Blocks[blockIndex];</div>
-<div class="line"><a name="l12172"></a><span class="lineno">12172</span>&#160;                    VMA_ASSERT(pCurrBlock);</div>
-<div class="line"><a name="l12173"></a><span class="lineno">12173</span>&#160;                    VmaAllocationRequest currRequest = {};</div>
-<div class="line"><a name="l12174"></a><span class="lineno">12174</span>&#160;                    <span class="keywordflow">if</span>(pCurrBlock-&gt;m_pMetadata-&gt;CreateAllocationRequest(</div>
-<div class="line"><a name="l12175"></a><span class="lineno">12175</span>&#160;                        currentFrameIndex,</div>
-<div class="line"><a name="l12176"></a><span class="lineno">12176</span>&#160;                        m_FrameInUseCount,</div>
-<div class="line"><a name="l12177"></a><span class="lineno">12177</span>&#160;                        m_BufferImageGranularity,</div>
-<div class="line"><a name="l12178"></a><span class="lineno">12178</span>&#160;                        size,</div>
-<div class="line"><a name="l12179"></a><span class="lineno">12179</span>&#160;                        alignment,</div>
-<div class="line"><a name="l12180"></a><span class="lineno">12180</span>&#160;                        (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a42ba3a2d2c7117953210b7c3ef8da0df">VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT</a>) != 0,</div>
-<div class="line"><a name="l12181"></a><span class="lineno">12181</span>&#160;                        suballocType,</div>
-<div class="line"><a name="l12182"></a><span class="lineno">12182</span>&#160;                        canMakeOtherLost,</div>
-<div class="line"><a name="l12183"></a><span class="lineno">12183</span>&#160;                        strategy,</div>
-<div class="line"><a name="l12184"></a><span class="lineno">12184</span>&#160;                        &amp;currRequest))</div>
-<div class="line"><a name="l12185"></a><span class="lineno">12185</span>&#160;                    {</div>
-<div class="line"><a name="l12186"></a><span class="lineno">12186</span>&#160;                        <span class="keyword">const</span> VkDeviceSize currRequestCost = currRequest.CalcCost();</div>
-<div class="line"><a name="l12187"></a><span class="lineno">12187</span>&#160;                        <span class="keywordflow">if</span>(pBestRequestBlock == VMA_NULL ||</div>
-<div class="line"><a name="l12188"></a><span class="lineno">12188</span>&#160;                            currRequestCost &lt; bestRequestCost ||</div>
-<div class="line"><a name="l12189"></a><span class="lineno">12189</span>&#160;                            strategy == <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a33eb2052674f3ad92386c714a65fb777">VMA_ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT</a>)</div>
-<div class="line"><a name="l12190"></a><span class="lineno">12190</span>&#160;                        {</div>
-<div class="line"><a name="l12191"></a><span class="lineno">12191</span>&#160;                            pBestRequestBlock = pCurrBlock;</div>
-<div class="line"><a name="l12192"></a><span class="lineno">12192</span>&#160;                            bestRequest = currRequest;</div>
-<div class="line"><a name="l12193"></a><span class="lineno">12193</span>&#160;                            bestRequestCost = currRequestCost;</div>
-<div class="line"><a name="l12194"></a><span class="lineno">12194</span>&#160; </div>
-<div class="line"><a name="l12195"></a><span class="lineno">12195</span>&#160;                            <span class="keywordflow">if</span>(bestRequestCost == 0 ||</div>
-<div class="line"><a name="l12196"></a><span class="lineno">12196</span>&#160;                                strategy == <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a33eb2052674f3ad92386c714a65fb777">VMA_ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT</a>)</div>
-<div class="line"><a name="l12197"></a><span class="lineno">12197</span>&#160;                            {</div>
-<div class="line"><a name="l12198"></a><span class="lineno">12198</span>&#160;                                <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l12199"></a><span class="lineno">12199</span>&#160;                            }</div>
-<div class="line"><a name="l12200"></a><span class="lineno">12200</span>&#160;                        }</div>
-<div class="line"><a name="l12201"></a><span class="lineno">12201</span>&#160;                    }</div>
-<div class="line"><a name="l12202"></a><span class="lineno">12202</span>&#160;                }</div>
-<div class="line"><a name="l12203"></a><span class="lineno">12203</span>&#160;            }</div>
-<div class="line"><a name="l12204"></a><span class="lineno">12204</span>&#160; </div>
-<div class="line"><a name="l12205"></a><span class="lineno">12205</span>&#160;            <span class="keywordflow">if</span>(pBestRequestBlock != VMA_NULL)</div>
-<div class="line"><a name="l12206"></a><span class="lineno">12206</span>&#160;            {</div>
-<div class="line"><a name="l12207"></a><span class="lineno">12207</span>&#160;                <span class="keywordflow">if</span>(mapped)</div>
-<div class="line"><a name="l12208"></a><span class="lineno">12208</span>&#160;                {</div>
-<div class="line"><a name="l12209"></a><span class="lineno">12209</span>&#160;                    VkResult res = pBestRequestBlock-&gt;Map(m_hAllocator, 1, VMA_NULL);</div>
-<div class="line"><a name="l12210"></a><span class="lineno">12210</span>&#160;                    <span class="keywordflow">if</span>(res != VK_SUCCESS)</div>
-<div class="line"><a name="l12211"></a><span class="lineno">12211</span>&#160;                    {</div>
-<div class="line"><a name="l12212"></a><span class="lineno">12212</span>&#160;                        <span class="keywordflow">return</span> res;</div>
-<div class="line"><a name="l12213"></a><span class="lineno">12213</span>&#160;                    }</div>
-<div class="line"><a name="l12214"></a><span class="lineno">12214</span>&#160;                }</div>
-<div class="line"><a name="l12215"></a><span class="lineno">12215</span>&#160; </div>
-<div class="line"><a name="l12216"></a><span class="lineno">12216</span>&#160;                <span class="keywordflow">if</span>(pBestRequestBlock-&gt;m_pMetadata-&gt;MakeRequestedAllocationsLost(</div>
-<div class="line"><a name="l12217"></a><span class="lineno">12217</span>&#160;                    currentFrameIndex,</div>
-<div class="line"><a name="l12218"></a><span class="lineno">12218</span>&#160;                    m_FrameInUseCount,</div>
-<div class="line"><a name="l12219"></a><span class="lineno">12219</span>&#160;                    &amp;bestRequest))</div>
-<div class="line"><a name="l12220"></a><span class="lineno">12220</span>&#160;                {</div>
-<div class="line"><a name="l12221"></a><span class="lineno">12221</span>&#160;                    <span class="comment">// Allocate from this pBlock.</span></div>
-<div class="line"><a name="l12222"></a><span class="lineno">12222</span>&#160;                    *pAllocation = m_hAllocator-&gt;m_AllocationObjectAllocator.Allocate();</div>
-<div class="line"><a name="l12223"></a><span class="lineno">12223</span>&#160;                    (*pAllocation)-&gt;Ctor(currentFrameIndex, isUserDataString);</div>
-<div class="line"><a name="l12224"></a><span class="lineno">12224</span>&#160;                    pBestRequestBlock-&gt;m_pMetadata-&gt;Alloc(bestRequest, suballocType, size, *pAllocation);</div>
-<div class="line"><a name="l12225"></a><span class="lineno">12225</span>&#160;                    UpdateHasEmptyBlock();</div>
-<div class="line"><a name="l12226"></a><span class="lineno">12226</span>&#160;                    (*pAllocation)-&gt;InitBlockAllocation(</div>
-<div class="line"><a name="l12227"></a><span class="lineno">12227</span>&#160;                        pBestRequestBlock,</div>
-<div class="line"><a name="l12228"></a><span class="lineno">12228</span>&#160;                        bestRequest.offset,</div>
-<div class="line"><a name="l12229"></a><span class="lineno">12229</span>&#160;                        alignment,</div>
-<div class="line"><a name="l12230"></a><span class="lineno">12230</span>&#160;                        size,</div>
-<div class="line"><a name="l12231"></a><span class="lineno">12231</span>&#160;                        m_MemoryTypeIndex,</div>
-<div class="line"><a name="l12232"></a><span class="lineno">12232</span>&#160;                        suballocType,</div>
-<div class="line"><a name="l12233"></a><span class="lineno">12233</span>&#160;                        mapped,</div>
-<div class="line"><a name="l12234"></a><span class="lineno">12234</span>&#160;                        (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a5f436af6c8fe8540573a6d22627a6fd2">VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT</a>) != 0);</div>
-<div class="line"><a name="l12235"></a><span class="lineno">12235</span>&#160;                    VMA_HEAVY_ASSERT(pBestRequestBlock-&gt;Validate());</div>
-<div class="line"><a name="l12236"></a><span class="lineno">12236</span>&#160;                    VMA_DEBUG_LOG(<span class="stringliteral">&quot;    Returned from existing block&quot;</span>);</div>
-<div class="line"><a name="l12237"></a><span class="lineno">12237</span>&#160;                    (*pAllocation)-&gt;SetUserData(m_hAllocator, createInfo.<a class="code" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19">pUserData</a>);</div>
-<div class="line"><a name="l12238"></a><span class="lineno">12238</span>&#160;                    m_hAllocator-&gt;m_Budget.AddAllocation(m_hAllocator-&gt;MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), size);</div>
-<div class="line"><a name="l12239"></a><span class="lineno">12239</span>&#160;                    <span class="keywordflow">if</span>(VMA_DEBUG_INITIALIZE_ALLOCATIONS)</div>
-<div class="line"><a name="l12240"></a><span class="lineno">12240</span>&#160;                    {</div>
-<div class="line"><a name="l12241"></a><span class="lineno">12241</span>&#160;                        m_hAllocator-&gt;FillAllocation(*pAllocation, VMA_ALLOCATION_FILL_PATTERN_CREATED);</div>
-<div class="line"><a name="l12242"></a><span class="lineno">12242</span>&#160;                    }</div>
-<div class="line"><a name="l12243"></a><span class="lineno">12243</span>&#160;                    <span class="keywordflow">if</span>(IsCorruptionDetectionEnabled())</div>
-<div class="line"><a name="l12244"></a><span class="lineno">12244</span>&#160;                    {</div>
-<div class="line"><a name="l12245"></a><span class="lineno">12245</span>&#160;                        VkResult res = pBestRequestBlock-&gt;WriteMagicValueAroundAllocation(m_hAllocator, bestRequest.offset, size);</div>
-<div class="line"><a name="l12246"></a><span class="lineno">12246</span>&#160;                        VMA_ASSERT(res == VK_SUCCESS &amp;&amp; <span class="stringliteral">&quot;Couldn&#39;t map block memory to write magic value.&quot;</span>);</div>
-<div class="line"><a name="l12247"></a><span class="lineno">12247</span>&#160;                    }</div>
-<div class="line"><a name="l12248"></a><span class="lineno">12248</span>&#160;                    <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l12249"></a><span class="lineno">12249</span>&#160;                }</div>
-<div class="line"><a name="l12250"></a><span class="lineno">12250</span>&#160;                <span class="comment">// else: Some allocations must have been touched while we are here. Next try.</span></div>
-<div class="line"><a name="l12251"></a><span class="lineno">12251</span>&#160;            }</div>
-<div class="line"><a name="l12252"></a><span class="lineno">12252</span>&#160;            <span class="keywordflow">else</span></div>
-<div class="line"><a name="l12253"></a><span class="lineno">12253</span>&#160;            {</div>
-<div class="line"><a name="l12254"></a><span class="lineno">12254</span>&#160;                <span class="comment">// Could not find place in any of the blocks - break outer loop.</span></div>
-<div class="line"><a name="l12255"></a><span class="lineno">12255</span>&#160;                <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l12256"></a><span class="lineno">12256</span>&#160;            }</div>
-<div class="line"><a name="l12257"></a><span class="lineno">12257</span>&#160;        }</div>
-<div class="line"><a name="l12258"></a><span class="lineno">12258</span>&#160;        <span class="comment">/* Maximum number of tries exceeded - a very unlike event when many other</span></div>
-<div class="line"><a name="l12259"></a><span class="lineno">12259</span>&#160;<span class="comment">        threads are simultaneously touching allocations making it impossible to make</span></div>
-<div class="line"><a name="l12260"></a><span class="lineno">12260</span>&#160;<span class="comment">        lost at the same time as we try to allocate. */</span></div>
-<div class="line"><a name="l12261"></a><span class="lineno">12261</span>&#160;        <span class="keywordflow">if</span>(tryIndex == VMA_ALLOCATION_TRY_COUNT)</div>
-<div class="line"><a name="l12262"></a><span class="lineno">12262</span>&#160;        {</div>
-<div class="line"><a name="l12263"></a><span class="lineno">12263</span>&#160;            <span class="keywordflow">return</span> VK_ERROR_TOO_MANY_OBJECTS;</div>
-<div class="line"><a name="l12264"></a><span class="lineno">12264</span>&#160;        }</div>
-<div class="line"><a name="l12265"></a><span class="lineno">12265</span>&#160;    }</div>
-<div class="line"><a name="l12266"></a><span class="lineno">12266</span>&#160; </div>
-<div class="line"><a name="l12267"></a><span class="lineno">12267</span>&#160;    <span class="keywordflow">return</span> VK_ERROR_OUT_OF_DEVICE_MEMORY;</div>
-<div class="line"><a name="l12268"></a><span class="lineno">12268</span>&#160;}</div>
-<div class="line"><a name="l12269"></a><span class="lineno">12269</span>&#160; </div>
-<div class="line"><a name="l12270"></a><span class="lineno">12270</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::Free(</div>
-<div class="line"><a name="l12271"></a><span class="lineno">12271</span>&#160;    <span class="keyword">const</span> <a class="code" href="struct_vma_allocation.html">VmaAllocation</a> hAllocation)</div>
-<div class="line"><a name="l12272"></a><span class="lineno">12272</span>&#160;{</div>
-<div class="line"><a name="l12273"></a><span class="lineno">12273</span>&#160;    VmaDeviceMemoryBlock* pBlockToDelete = VMA_NULL;</div>
-<div class="line"><a name="l12274"></a><span class="lineno">12274</span>&#160; </div>
-<div class="line"><a name="l12275"></a><span class="lineno">12275</span>&#160;    <span class="keywordtype">bool</span> budgetExceeded = <span class="keyword">false</span>;</div>
-<div class="line"><a name="l12276"></a><span class="lineno">12276</span>&#160;    {</div>
-<div class="line"><a name="l12277"></a><span class="lineno">12277</span>&#160;        <span class="keyword">const</span> uint32_t heapIndex = m_hAllocator-&gt;MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex);</div>
-<div class="line"><a name="l12278"></a><span class="lineno">12278</span>&#160;        <a class="code" href="struct_vma_budget.html">VmaBudget</a> heapBudget = {};</div>
-<div class="line"><a name="l12279"></a><span class="lineno">12279</span>&#160;        m_hAllocator-&gt;GetBudget(&amp;heapBudget, heapIndex, 1);</div>
-<div class="line"><a name="l12280"></a><span class="lineno">12280</span>&#160;        budgetExceeded = heapBudget.<a class="code" href="struct_vma_budget.html#a84dd1ecca8b0110259eb206dbadb11f6">usage</a> &gt;= heapBudget.<a class="code" href="struct_vma_budget.html#ab82e1d1754c2d210d0bdf90220bc6cdd">budget</a>;</div>
-<div class="line"><a name="l12281"></a><span class="lineno">12281</span>&#160;    }</div>
-<div class="line"><a name="l12282"></a><span class="lineno">12282</span>&#160; </div>
-<div class="line"><a name="l12283"></a><span class="lineno">12283</span>&#160;    <span class="comment">// Scope for lock.</span></div>
-<div class="line"><a name="l12284"></a><span class="lineno">12284</span>&#160;    {</div>
-<div class="line"><a name="l12285"></a><span class="lineno">12285</span>&#160;        VmaMutexLockWrite lock(m_Mutex, m_hAllocator-&gt;m_UseMutex);</div>
-<div class="line"><a name="l12286"></a><span class="lineno">12286</span>&#160; </div>
-<div class="line"><a name="l12287"></a><span class="lineno">12287</span>&#160;        VmaDeviceMemoryBlock* pBlock = hAllocation-&gt;GetBlock();</div>
+<div class="line"><a name="l11953"></a><span class="lineno">11953</span>&#160;    <span class="comment">// Early reject: requested allocation size is larger that maximum block size for this block vector.</span></div>
+<div class="line"><a name="l11954"></a><span class="lineno">11954</span>&#160;    <span class="keywordflow">if</span>(size + 2 * VMA_DEBUG_MARGIN &gt; m_PreferredBlockSize)</div>
+<div class="line"><a name="l11955"></a><span class="lineno">11955</span>&#160;    {</div>
+<div class="line"><a name="l11956"></a><span class="lineno">11956</span>&#160;        <span class="keywordflow">return</span> VK_ERROR_OUT_OF_DEVICE_MEMORY;</div>
+<div class="line"><a name="l11957"></a><span class="lineno">11957</span>&#160;    }</div>
+<div class="line"><a name="l11958"></a><span class="lineno">11958</span>&#160; </div>
+<div class="line"><a name="l11959"></a><span class="lineno">11959</span>&#160;    <span class="comment">/*</span></div>
+<div class="line"><a name="l11960"></a><span class="lineno">11960</span>&#160;<span class="comment">    Under certain condition, this whole section can be skipped for optimization, so</span></div>
+<div class="line"><a name="l11961"></a><span class="lineno">11961</span>&#160;<span class="comment">    we move on directly to trying to allocate with canMakeOtherLost. That&#39;s the case</span></div>
+<div class="line"><a name="l11962"></a><span class="lineno">11962</span>&#160;<span class="comment">    e.g. for custom pools with linear algorithm.</span></div>
+<div class="line"><a name="l11963"></a><span class="lineno">11963</span>&#160;<span class="comment">    */</span></div>
+<div class="line"><a name="l11964"></a><span class="lineno">11964</span>&#160;    <span class="keywordflow">if</span>(!canMakeOtherLost || canCreateNewBlock)</div>
+<div class="line"><a name="l11965"></a><span class="lineno">11965</span>&#160;    {</div>
+<div class="line"><a name="l11966"></a><span class="lineno">11966</span>&#160;        <span class="comment">// 1. Search existing allocations. Try to allocate without making other allocations lost.</span></div>
+<div class="line"><a name="l11967"></a><span class="lineno">11967</span>&#160;        <a class="code" href="vk__mem__alloc_8h.html#a5225e5e11f8376f6a31a1791f3d6e817">VmaAllocationCreateFlags</a> allocFlagsCopy = createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a>;</div>
+<div class="line"><a name="l11968"></a><span class="lineno">11968</span>&#160;        allocFlagsCopy &amp;= ~<a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a68686d0ce9beb0d4d1b9f2b8b1389a7e">VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT</a>;</div>
+<div class="line"><a name="l11969"></a><span class="lineno">11969</span>&#160; </div>
+<div class="line"><a name="l11970"></a><span class="lineno">11970</span>&#160;        <span class="keywordflow">if</span>(m_Algorithm == <a class="code" href="vk__mem__alloc_8h.html#a9a7c45f9c863695d98c83fa5ac940fe7a13c8a444197c67866be9cb05599fc726">VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT</a>)</div>
+<div class="line"><a name="l11971"></a><span class="lineno">11971</span>&#160;        {</div>
+<div class="line"><a name="l11972"></a><span class="lineno">11972</span>&#160;            <span class="comment">// Use only last block.</span></div>
+<div class="line"><a name="l11973"></a><span class="lineno">11973</span>&#160;            <span class="keywordflow">if</span>(!m_Blocks.empty())</div>
+<div class="line"><a name="l11974"></a><span class="lineno">11974</span>&#160;            {</div>
+<div class="line"><a name="l11975"></a><span class="lineno">11975</span>&#160;                VmaDeviceMemoryBlock* <span class="keyword">const</span> pCurrBlock = m_Blocks.back();</div>
+<div class="line"><a name="l11976"></a><span class="lineno">11976</span>&#160;                VMA_ASSERT(pCurrBlock);</div>
+<div class="line"><a name="l11977"></a><span class="lineno">11977</span>&#160;                VkResult res = AllocateFromBlock(</div>
+<div class="line"><a name="l11978"></a><span class="lineno">11978</span>&#160;                    pCurrBlock,</div>
+<div class="line"><a name="l11979"></a><span class="lineno">11979</span>&#160;                    currentFrameIndex,</div>
+<div class="line"><a name="l11980"></a><span class="lineno">11980</span>&#160;                    size,</div>
+<div class="line"><a name="l11981"></a><span class="lineno">11981</span>&#160;                    alignment,</div>
+<div class="line"><a name="l11982"></a><span class="lineno">11982</span>&#160;                    allocFlagsCopy,</div>
+<div class="line"><a name="l11983"></a><span class="lineno">11983</span>&#160;                    createInfo.<a class="code" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19">pUserData</a>,</div>
+<div class="line"><a name="l11984"></a><span class="lineno">11984</span>&#160;                    suballocType,</div>
+<div class="line"><a name="l11985"></a><span class="lineno">11985</span>&#160;                    strategy,</div>
+<div class="line"><a name="l11986"></a><span class="lineno">11986</span>&#160;                    pAllocation);</div>
+<div class="line"><a name="l11987"></a><span class="lineno">11987</span>&#160;                <span class="keywordflow">if</span>(res == VK_SUCCESS)</div>
+<div class="line"><a name="l11988"></a><span class="lineno">11988</span>&#160;                {</div>
+<div class="line"><a name="l11989"></a><span class="lineno">11989</span>&#160;                    VMA_DEBUG_LOG(<span class="stringliteral">&quot;    Returned from last block #%u&quot;</span>, pCurrBlock-&gt;GetId());</div>
+<div class="line"><a name="l11990"></a><span class="lineno">11990</span>&#160;                    <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l11991"></a><span class="lineno">11991</span>&#160;                }</div>
+<div class="line"><a name="l11992"></a><span class="lineno">11992</span>&#160;            }</div>
+<div class="line"><a name="l11993"></a><span class="lineno">11993</span>&#160;        }</div>
+<div class="line"><a name="l11994"></a><span class="lineno">11994</span>&#160;        <span class="keywordflow">else</span></div>
+<div class="line"><a name="l11995"></a><span class="lineno">11995</span>&#160;        {</div>
+<div class="line"><a name="l11996"></a><span class="lineno">11996</span>&#160;            <span class="keywordflow">if</span>(strategy == <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a839826775c62319466441f86496f036d">VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT</a>)</div>
+<div class="line"><a name="l11997"></a><span class="lineno">11997</span>&#160;            {</div>
+<div class="line"><a name="l11998"></a><span class="lineno">11998</span>&#160;                <span class="comment">// Forward order in m_Blocks - prefer blocks with smallest amount of free space.</span></div>
+<div class="line"><a name="l11999"></a><span class="lineno">11999</span>&#160;                <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; blockIndex &lt; m_Blocks.size(); ++blockIndex )</div>
+<div class="line"><a name="l12000"></a><span class="lineno">12000</span>&#160;                {</div>
+<div class="line"><a name="l12001"></a><span class="lineno">12001</span>&#160;                    VmaDeviceMemoryBlock* <span class="keyword">const</span> pCurrBlock = m_Blocks[blockIndex];</div>
+<div class="line"><a name="l12002"></a><span class="lineno">12002</span>&#160;                    VMA_ASSERT(pCurrBlock);</div>
+<div class="line"><a name="l12003"></a><span class="lineno">12003</span>&#160;                    VkResult res = AllocateFromBlock(</div>
+<div class="line"><a name="l12004"></a><span class="lineno">12004</span>&#160;                        pCurrBlock,</div>
+<div class="line"><a name="l12005"></a><span class="lineno">12005</span>&#160;                        currentFrameIndex,</div>
+<div class="line"><a name="l12006"></a><span class="lineno">12006</span>&#160;                        size,</div>
+<div class="line"><a name="l12007"></a><span class="lineno">12007</span>&#160;                        alignment,</div>
+<div class="line"><a name="l12008"></a><span class="lineno">12008</span>&#160;                        allocFlagsCopy,</div>
+<div class="line"><a name="l12009"></a><span class="lineno">12009</span>&#160;                        createInfo.<a class="code" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19">pUserData</a>,</div>
+<div class="line"><a name="l12010"></a><span class="lineno">12010</span>&#160;                        suballocType,</div>
+<div class="line"><a name="l12011"></a><span class="lineno">12011</span>&#160;                        strategy,</div>
+<div class="line"><a name="l12012"></a><span class="lineno">12012</span>&#160;                        pAllocation);</div>
+<div class="line"><a name="l12013"></a><span class="lineno">12013</span>&#160;                    <span class="keywordflow">if</span>(res == VK_SUCCESS)</div>
+<div class="line"><a name="l12014"></a><span class="lineno">12014</span>&#160;                    {</div>
+<div class="line"><a name="l12015"></a><span class="lineno">12015</span>&#160;                        VMA_DEBUG_LOG(<span class="stringliteral">&quot;    Returned from existing block #%u&quot;</span>, pCurrBlock-&gt;GetId());</div>
+<div class="line"><a name="l12016"></a><span class="lineno">12016</span>&#160;                        <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l12017"></a><span class="lineno">12017</span>&#160;                    }</div>
+<div class="line"><a name="l12018"></a><span class="lineno">12018</span>&#160;                }</div>
+<div class="line"><a name="l12019"></a><span class="lineno">12019</span>&#160;            }</div>
+<div class="line"><a name="l12020"></a><span class="lineno">12020</span>&#160;            <span class="keywordflow">else</span> <span class="comment">// WORST_FIT, FIRST_FIT</span></div>
+<div class="line"><a name="l12021"></a><span class="lineno">12021</span>&#160;            {</div>
+<div class="line"><a name="l12022"></a><span class="lineno">12022</span>&#160;                <span class="comment">// Backward order in m_Blocks - prefer blocks with largest amount of free space.</span></div>
+<div class="line"><a name="l12023"></a><span class="lineno">12023</span>&#160;                <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = m_Blocks.size(); blockIndex--; )</div>
+<div class="line"><a name="l12024"></a><span class="lineno">12024</span>&#160;                {</div>
+<div class="line"><a name="l12025"></a><span class="lineno">12025</span>&#160;                    VmaDeviceMemoryBlock* <span class="keyword">const</span> pCurrBlock = m_Blocks[blockIndex];</div>
+<div class="line"><a name="l12026"></a><span class="lineno">12026</span>&#160;                    VMA_ASSERT(pCurrBlock);</div>
+<div class="line"><a name="l12027"></a><span class="lineno">12027</span>&#160;                    VkResult res = AllocateFromBlock(</div>
+<div class="line"><a name="l12028"></a><span class="lineno">12028</span>&#160;                        pCurrBlock,</div>
+<div class="line"><a name="l12029"></a><span class="lineno">12029</span>&#160;                        currentFrameIndex,</div>
+<div class="line"><a name="l12030"></a><span class="lineno">12030</span>&#160;                        size,</div>
+<div class="line"><a name="l12031"></a><span class="lineno">12031</span>&#160;                        alignment,</div>
+<div class="line"><a name="l12032"></a><span class="lineno">12032</span>&#160;                        allocFlagsCopy,</div>
+<div class="line"><a name="l12033"></a><span class="lineno">12033</span>&#160;                        createInfo.<a class="code" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19">pUserData</a>,</div>
+<div class="line"><a name="l12034"></a><span class="lineno">12034</span>&#160;                        suballocType,</div>
+<div class="line"><a name="l12035"></a><span class="lineno">12035</span>&#160;                        strategy,</div>
+<div class="line"><a name="l12036"></a><span class="lineno">12036</span>&#160;                        pAllocation);</div>
+<div class="line"><a name="l12037"></a><span class="lineno">12037</span>&#160;                    <span class="keywordflow">if</span>(res == VK_SUCCESS)</div>
+<div class="line"><a name="l12038"></a><span class="lineno">12038</span>&#160;                    {</div>
+<div class="line"><a name="l12039"></a><span class="lineno">12039</span>&#160;                        VMA_DEBUG_LOG(<span class="stringliteral">&quot;    Returned from existing block #%u&quot;</span>, pCurrBlock-&gt;GetId());</div>
+<div class="line"><a name="l12040"></a><span class="lineno">12040</span>&#160;                        <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l12041"></a><span class="lineno">12041</span>&#160;                    }</div>
+<div class="line"><a name="l12042"></a><span class="lineno">12042</span>&#160;                }</div>
+<div class="line"><a name="l12043"></a><span class="lineno">12043</span>&#160;            }</div>
+<div class="line"><a name="l12044"></a><span class="lineno">12044</span>&#160;        }</div>
+<div class="line"><a name="l12045"></a><span class="lineno">12045</span>&#160; </div>
+<div class="line"><a name="l12046"></a><span class="lineno">12046</span>&#160;        <span class="comment">// 2. Try to create new block.</span></div>
+<div class="line"><a name="l12047"></a><span class="lineno">12047</span>&#160;        <span class="keywordflow">if</span>(canCreateNewBlock)</div>
+<div class="line"><a name="l12048"></a><span class="lineno">12048</span>&#160;        {</div>
+<div class="line"><a name="l12049"></a><span class="lineno">12049</span>&#160;            <span class="comment">// Calculate optimal size for new block.</span></div>
+<div class="line"><a name="l12050"></a><span class="lineno">12050</span>&#160;            VkDeviceSize newBlockSize = m_PreferredBlockSize;</div>
+<div class="line"><a name="l12051"></a><span class="lineno">12051</span>&#160;            uint32_t newBlockSizeShift = 0;</div>
+<div class="line"><a name="l12052"></a><span class="lineno">12052</span>&#160;            <span class="keyword">const</span> uint32_t NEW_BLOCK_SIZE_SHIFT_MAX = 3;</div>
+<div class="line"><a name="l12053"></a><span class="lineno">12053</span>&#160; </div>
+<div class="line"><a name="l12054"></a><span class="lineno">12054</span>&#160;            <span class="keywordflow">if</span>(!m_ExplicitBlockSize)</div>
+<div class="line"><a name="l12055"></a><span class="lineno">12055</span>&#160;            {</div>
+<div class="line"><a name="l12056"></a><span class="lineno">12056</span>&#160;                <span class="comment">// Allocate 1/8, 1/4, 1/2 as first blocks.</span></div>
+<div class="line"><a name="l12057"></a><span class="lineno">12057</span>&#160;                <span class="keyword">const</span> VkDeviceSize maxExistingBlockSize = CalcMaxBlockSize();</div>
+<div class="line"><a name="l12058"></a><span class="lineno">12058</span>&#160;                <span class="keywordflow">for</span>(uint32_t i = 0; i &lt; NEW_BLOCK_SIZE_SHIFT_MAX; ++i)</div>
+<div class="line"><a name="l12059"></a><span class="lineno">12059</span>&#160;                {</div>
+<div class="line"><a name="l12060"></a><span class="lineno">12060</span>&#160;                    <span class="keyword">const</span> VkDeviceSize smallerNewBlockSize = newBlockSize / 2;</div>
+<div class="line"><a name="l12061"></a><span class="lineno">12061</span>&#160;                    <span class="keywordflow">if</span>(smallerNewBlockSize &gt; maxExistingBlockSize &amp;&amp; smallerNewBlockSize &gt;= size * 2)</div>
+<div class="line"><a name="l12062"></a><span class="lineno">12062</span>&#160;                    {</div>
+<div class="line"><a name="l12063"></a><span class="lineno">12063</span>&#160;                        newBlockSize = smallerNewBlockSize;</div>
+<div class="line"><a name="l12064"></a><span class="lineno">12064</span>&#160;                        ++newBlockSizeShift;</div>
+<div class="line"><a name="l12065"></a><span class="lineno">12065</span>&#160;                    }</div>
+<div class="line"><a name="l12066"></a><span class="lineno">12066</span>&#160;                    <span class="keywordflow">else</span></div>
+<div class="line"><a name="l12067"></a><span class="lineno">12067</span>&#160;                    {</div>
+<div class="line"><a name="l12068"></a><span class="lineno">12068</span>&#160;                        <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l12069"></a><span class="lineno">12069</span>&#160;                    }</div>
+<div class="line"><a name="l12070"></a><span class="lineno">12070</span>&#160;                }</div>
+<div class="line"><a name="l12071"></a><span class="lineno">12071</span>&#160;            }</div>
+<div class="line"><a name="l12072"></a><span class="lineno">12072</span>&#160; </div>
+<div class="line"><a name="l12073"></a><span class="lineno">12073</span>&#160;            <span class="keywordtype">size_t</span> newBlockIndex = 0;</div>
+<div class="line"><a name="l12074"></a><span class="lineno">12074</span>&#160;            VkResult res = (newBlockSize &lt;= freeMemory || !canFallbackToDedicated) ?</div>
+<div class="line"><a name="l12075"></a><span class="lineno">12075</span>&#160;                CreateBlock(newBlockSize, &amp;newBlockIndex) : VK_ERROR_OUT_OF_DEVICE_MEMORY;</div>
+<div class="line"><a name="l12076"></a><span class="lineno">12076</span>&#160;            <span class="comment">// Allocation of this size failed? Try 1/2, 1/4, 1/8 of m_PreferredBlockSize.</span></div>
+<div class="line"><a name="l12077"></a><span class="lineno">12077</span>&#160;            <span class="keywordflow">if</span>(!m_ExplicitBlockSize)</div>
+<div class="line"><a name="l12078"></a><span class="lineno">12078</span>&#160;            {</div>
+<div class="line"><a name="l12079"></a><span class="lineno">12079</span>&#160;                <span class="keywordflow">while</span>(res &lt; 0 &amp;&amp; newBlockSizeShift &lt; NEW_BLOCK_SIZE_SHIFT_MAX)</div>
+<div class="line"><a name="l12080"></a><span class="lineno">12080</span>&#160;                {</div>
+<div class="line"><a name="l12081"></a><span class="lineno">12081</span>&#160;                    <span class="keyword">const</span> VkDeviceSize smallerNewBlockSize = newBlockSize / 2;</div>
+<div class="line"><a name="l12082"></a><span class="lineno">12082</span>&#160;                    <span class="keywordflow">if</span>(smallerNewBlockSize &gt;= size)</div>
+<div class="line"><a name="l12083"></a><span class="lineno">12083</span>&#160;                    {</div>
+<div class="line"><a name="l12084"></a><span class="lineno">12084</span>&#160;                        newBlockSize = smallerNewBlockSize;</div>
+<div class="line"><a name="l12085"></a><span class="lineno">12085</span>&#160;                        ++newBlockSizeShift;</div>
+<div class="line"><a name="l12086"></a><span class="lineno">12086</span>&#160;                        res = (newBlockSize &lt;= freeMemory || !canFallbackToDedicated) ?</div>
+<div class="line"><a name="l12087"></a><span class="lineno">12087</span>&#160;                            CreateBlock(newBlockSize, &amp;newBlockIndex) : VK_ERROR_OUT_OF_DEVICE_MEMORY;</div>
+<div class="line"><a name="l12088"></a><span class="lineno">12088</span>&#160;                    }</div>
+<div class="line"><a name="l12089"></a><span class="lineno">12089</span>&#160;                    <span class="keywordflow">else</span></div>
+<div class="line"><a name="l12090"></a><span class="lineno">12090</span>&#160;                    {</div>
+<div class="line"><a name="l12091"></a><span class="lineno">12091</span>&#160;                        <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l12092"></a><span class="lineno">12092</span>&#160;                    }</div>
+<div class="line"><a name="l12093"></a><span class="lineno">12093</span>&#160;                }</div>
+<div class="line"><a name="l12094"></a><span class="lineno">12094</span>&#160;            }</div>
+<div class="line"><a name="l12095"></a><span class="lineno">12095</span>&#160; </div>
+<div class="line"><a name="l12096"></a><span class="lineno">12096</span>&#160;            <span class="keywordflow">if</span>(res == VK_SUCCESS)</div>
+<div class="line"><a name="l12097"></a><span class="lineno">12097</span>&#160;            {</div>
+<div class="line"><a name="l12098"></a><span class="lineno">12098</span>&#160;                VmaDeviceMemoryBlock* <span class="keyword">const</span> pBlock = m_Blocks[newBlockIndex];</div>
+<div class="line"><a name="l12099"></a><span class="lineno">12099</span>&#160;                VMA_ASSERT(pBlock-&gt;m_pMetadata-&gt;GetSize() &gt;= size);</div>
+<div class="line"><a name="l12100"></a><span class="lineno">12100</span>&#160; </div>
+<div class="line"><a name="l12101"></a><span class="lineno">12101</span>&#160;                res = AllocateFromBlock(</div>
+<div class="line"><a name="l12102"></a><span class="lineno">12102</span>&#160;                    pBlock,</div>
+<div class="line"><a name="l12103"></a><span class="lineno">12103</span>&#160;                    currentFrameIndex,</div>
+<div class="line"><a name="l12104"></a><span class="lineno">12104</span>&#160;                    size,</div>
+<div class="line"><a name="l12105"></a><span class="lineno">12105</span>&#160;                    alignment,</div>
+<div class="line"><a name="l12106"></a><span class="lineno">12106</span>&#160;                    allocFlagsCopy,</div>
+<div class="line"><a name="l12107"></a><span class="lineno">12107</span>&#160;                    createInfo.<a class="code" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19">pUserData</a>,</div>
+<div class="line"><a name="l12108"></a><span class="lineno">12108</span>&#160;                    suballocType,</div>
+<div class="line"><a name="l12109"></a><span class="lineno">12109</span>&#160;                    strategy,</div>
+<div class="line"><a name="l12110"></a><span class="lineno">12110</span>&#160;                    pAllocation);</div>
+<div class="line"><a name="l12111"></a><span class="lineno">12111</span>&#160;                <span class="keywordflow">if</span>(res == VK_SUCCESS)</div>
+<div class="line"><a name="l12112"></a><span class="lineno">12112</span>&#160;                {</div>
+<div class="line"><a name="l12113"></a><span class="lineno">12113</span>&#160;                    VMA_DEBUG_LOG(<span class="stringliteral">&quot;    Created new block #%u Size=%llu&quot;</span>, pBlock-&gt;GetId(), newBlockSize);</div>
+<div class="line"><a name="l12114"></a><span class="lineno">12114</span>&#160;                    <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l12115"></a><span class="lineno">12115</span>&#160;                }</div>
+<div class="line"><a name="l12116"></a><span class="lineno">12116</span>&#160;                <span class="keywordflow">else</span></div>
+<div class="line"><a name="l12117"></a><span class="lineno">12117</span>&#160;                {</div>
+<div class="line"><a name="l12118"></a><span class="lineno">12118</span>&#160;                    <span class="comment">// Allocation from new block failed, possibly due to VMA_DEBUG_MARGIN or alignment.</span></div>
+<div class="line"><a name="l12119"></a><span class="lineno">12119</span>&#160;                    <span class="keywordflow">return</span> VK_ERROR_OUT_OF_DEVICE_MEMORY;</div>
+<div class="line"><a name="l12120"></a><span class="lineno">12120</span>&#160;                }</div>
+<div class="line"><a name="l12121"></a><span class="lineno">12121</span>&#160;            }</div>
+<div class="line"><a name="l12122"></a><span class="lineno">12122</span>&#160;        }</div>
+<div class="line"><a name="l12123"></a><span class="lineno">12123</span>&#160;    }</div>
+<div class="line"><a name="l12124"></a><span class="lineno">12124</span>&#160; </div>
+<div class="line"><a name="l12125"></a><span class="lineno">12125</span>&#160;    <span class="comment">// 3. Try to allocate from existing blocks with making other allocations lost.</span></div>
+<div class="line"><a name="l12126"></a><span class="lineno">12126</span>&#160;    <span class="keywordflow">if</span>(canMakeOtherLost)</div>
+<div class="line"><a name="l12127"></a><span class="lineno">12127</span>&#160;    {</div>
+<div class="line"><a name="l12128"></a><span class="lineno">12128</span>&#160;        uint32_t tryIndex = 0;</div>
+<div class="line"><a name="l12129"></a><span class="lineno">12129</span>&#160;        <span class="keywordflow">for</span>(; tryIndex &lt; VMA_ALLOCATION_TRY_COUNT; ++tryIndex)</div>
+<div class="line"><a name="l12130"></a><span class="lineno">12130</span>&#160;        {</div>
+<div class="line"><a name="l12131"></a><span class="lineno">12131</span>&#160;            VmaDeviceMemoryBlock* pBestRequestBlock = VMA_NULL;</div>
+<div class="line"><a name="l12132"></a><span class="lineno">12132</span>&#160;            VmaAllocationRequest bestRequest = {};</div>
+<div class="line"><a name="l12133"></a><span class="lineno">12133</span>&#160;            VkDeviceSize bestRequestCost = VK_WHOLE_SIZE;</div>
+<div class="line"><a name="l12134"></a><span class="lineno">12134</span>&#160; </div>
+<div class="line"><a name="l12135"></a><span class="lineno">12135</span>&#160;            <span class="comment">// 1. Search existing allocations.</span></div>
+<div class="line"><a name="l12136"></a><span class="lineno">12136</span>&#160;            <span class="keywordflow">if</span>(strategy == <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a839826775c62319466441f86496f036d">VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT</a>)</div>
+<div class="line"><a name="l12137"></a><span class="lineno">12137</span>&#160;            {</div>
+<div class="line"><a name="l12138"></a><span class="lineno">12138</span>&#160;                <span class="comment">// Forward order in m_Blocks - prefer blocks with smallest amount of free space.</span></div>
+<div class="line"><a name="l12139"></a><span class="lineno">12139</span>&#160;                <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; blockIndex &lt; m_Blocks.size(); ++blockIndex )</div>
+<div class="line"><a name="l12140"></a><span class="lineno">12140</span>&#160;                {</div>
+<div class="line"><a name="l12141"></a><span class="lineno">12141</span>&#160;                    VmaDeviceMemoryBlock* <span class="keyword">const</span> pCurrBlock = m_Blocks[blockIndex];</div>
+<div class="line"><a name="l12142"></a><span class="lineno">12142</span>&#160;                    VMA_ASSERT(pCurrBlock);</div>
+<div class="line"><a name="l12143"></a><span class="lineno">12143</span>&#160;                    VmaAllocationRequest currRequest = {};</div>
+<div class="line"><a name="l12144"></a><span class="lineno">12144</span>&#160;                    <span class="keywordflow">if</span>(pCurrBlock-&gt;m_pMetadata-&gt;CreateAllocationRequest(</div>
+<div class="line"><a name="l12145"></a><span class="lineno">12145</span>&#160;                        currentFrameIndex,</div>
+<div class="line"><a name="l12146"></a><span class="lineno">12146</span>&#160;                        m_FrameInUseCount,</div>
+<div class="line"><a name="l12147"></a><span class="lineno">12147</span>&#160;                        m_BufferImageGranularity,</div>
+<div class="line"><a name="l12148"></a><span class="lineno">12148</span>&#160;                        size,</div>
+<div class="line"><a name="l12149"></a><span class="lineno">12149</span>&#160;                        alignment,</div>
+<div class="line"><a name="l12150"></a><span class="lineno">12150</span>&#160;                        (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a42ba3a2d2c7117953210b7c3ef8da0df">VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT</a>) != 0,</div>
+<div class="line"><a name="l12151"></a><span class="lineno">12151</span>&#160;                        suballocType,</div>
+<div class="line"><a name="l12152"></a><span class="lineno">12152</span>&#160;                        canMakeOtherLost,</div>
+<div class="line"><a name="l12153"></a><span class="lineno">12153</span>&#160;                        strategy,</div>
+<div class="line"><a name="l12154"></a><span class="lineno">12154</span>&#160;                        &amp;currRequest))</div>
+<div class="line"><a name="l12155"></a><span class="lineno">12155</span>&#160;                    {</div>
+<div class="line"><a name="l12156"></a><span class="lineno">12156</span>&#160;                        <span class="keyword">const</span> VkDeviceSize currRequestCost = currRequest.CalcCost();</div>
+<div class="line"><a name="l12157"></a><span class="lineno">12157</span>&#160;                        <span class="keywordflow">if</span>(pBestRequestBlock == VMA_NULL ||</div>
+<div class="line"><a name="l12158"></a><span class="lineno">12158</span>&#160;                            currRequestCost &lt; bestRequestCost)</div>
+<div class="line"><a name="l12159"></a><span class="lineno">12159</span>&#160;                        {</div>
+<div class="line"><a name="l12160"></a><span class="lineno">12160</span>&#160;                            pBestRequestBlock = pCurrBlock;</div>
+<div class="line"><a name="l12161"></a><span class="lineno">12161</span>&#160;                            bestRequest = currRequest;</div>
+<div class="line"><a name="l12162"></a><span class="lineno">12162</span>&#160;                            bestRequestCost = currRequestCost;</div>
+<div class="line"><a name="l12163"></a><span class="lineno">12163</span>&#160; </div>
+<div class="line"><a name="l12164"></a><span class="lineno">12164</span>&#160;                            <span class="keywordflow">if</span>(bestRequestCost == 0)</div>
+<div class="line"><a name="l12165"></a><span class="lineno">12165</span>&#160;                            {</div>
+<div class="line"><a name="l12166"></a><span class="lineno">12166</span>&#160;                                <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l12167"></a><span class="lineno">12167</span>&#160;                            }</div>
+<div class="line"><a name="l12168"></a><span class="lineno">12168</span>&#160;                        }</div>
+<div class="line"><a name="l12169"></a><span class="lineno">12169</span>&#160;                    }</div>
+<div class="line"><a name="l12170"></a><span class="lineno">12170</span>&#160;                }</div>
+<div class="line"><a name="l12171"></a><span class="lineno">12171</span>&#160;            }</div>
+<div class="line"><a name="l12172"></a><span class="lineno">12172</span>&#160;            <span class="keywordflow">else</span> <span class="comment">// WORST_FIT, FIRST_FIT</span></div>
+<div class="line"><a name="l12173"></a><span class="lineno">12173</span>&#160;            {</div>
+<div class="line"><a name="l12174"></a><span class="lineno">12174</span>&#160;                <span class="comment">// Backward order in m_Blocks - prefer blocks with largest amount of free space.</span></div>
+<div class="line"><a name="l12175"></a><span class="lineno">12175</span>&#160;                <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = m_Blocks.size(); blockIndex--; )</div>
+<div class="line"><a name="l12176"></a><span class="lineno">12176</span>&#160;                {</div>
+<div class="line"><a name="l12177"></a><span class="lineno">12177</span>&#160;                    VmaDeviceMemoryBlock* <span class="keyword">const</span> pCurrBlock = m_Blocks[blockIndex];</div>
+<div class="line"><a name="l12178"></a><span class="lineno">12178</span>&#160;                    VMA_ASSERT(pCurrBlock);</div>
+<div class="line"><a name="l12179"></a><span class="lineno">12179</span>&#160;                    VmaAllocationRequest currRequest = {};</div>
+<div class="line"><a name="l12180"></a><span class="lineno">12180</span>&#160;                    <span class="keywordflow">if</span>(pCurrBlock-&gt;m_pMetadata-&gt;CreateAllocationRequest(</div>
+<div class="line"><a name="l12181"></a><span class="lineno">12181</span>&#160;                        currentFrameIndex,</div>
+<div class="line"><a name="l12182"></a><span class="lineno">12182</span>&#160;                        m_FrameInUseCount,</div>
+<div class="line"><a name="l12183"></a><span class="lineno">12183</span>&#160;                        m_BufferImageGranularity,</div>
+<div class="line"><a name="l12184"></a><span class="lineno">12184</span>&#160;                        size,</div>
+<div class="line"><a name="l12185"></a><span class="lineno">12185</span>&#160;                        alignment,</div>
+<div class="line"><a name="l12186"></a><span class="lineno">12186</span>&#160;                        (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a42ba3a2d2c7117953210b7c3ef8da0df">VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT</a>) != 0,</div>
+<div class="line"><a name="l12187"></a><span class="lineno">12187</span>&#160;                        suballocType,</div>
+<div class="line"><a name="l12188"></a><span class="lineno">12188</span>&#160;                        canMakeOtherLost,</div>
+<div class="line"><a name="l12189"></a><span class="lineno">12189</span>&#160;                        strategy,</div>
+<div class="line"><a name="l12190"></a><span class="lineno">12190</span>&#160;                        &amp;currRequest))</div>
+<div class="line"><a name="l12191"></a><span class="lineno">12191</span>&#160;                    {</div>
+<div class="line"><a name="l12192"></a><span class="lineno">12192</span>&#160;                        <span class="keyword">const</span> VkDeviceSize currRequestCost = currRequest.CalcCost();</div>
+<div class="line"><a name="l12193"></a><span class="lineno">12193</span>&#160;                        <span class="keywordflow">if</span>(pBestRequestBlock == VMA_NULL ||</div>
+<div class="line"><a name="l12194"></a><span class="lineno">12194</span>&#160;                            currRequestCost &lt; bestRequestCost ||</div>
+<div class="line"><a name="l12195"></a><span class="lineno">12195</span>&#160;                            strategy == <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a33eb2052674f3ad92386c714a65fb777">VMA_ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT</a>)</div>
+<div class="line"><a name="l12196"></a><span class="lineno">12196</span>&#160;                        {</div>
+<div class="line"><a name="l12197"></a><span class="lineno">12197</span>&#160;                            pBestRequestBlock = pCurrBlock;</div>
+<div class="line"><a name="l12198"></a><span class="lineno">12198</span>&#160;                            bestRequest = currRequest;</div>
+<div class="line"><a name="l12199"></a><span class="lineno">12199</span>&#160;                            bestRequestCost = currRequestCost;</div>
+<div class="line"><a name="l12200"></a><span class="lineno">12200</span>&#160; </div>
+<div class="line"><a name="l12201"></a><span class="lineno">12201</span>&#160;                            <span class="keywordflow">if</span>(bestRequestCost == 0 ||</div>
+<div class="line"><a name="l12202"></a><span class="lineno">12202</span>&#160;                                strategy == <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a33eb2052674f3ad92386c714a65fb777">VMA_ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT</a>)</div>
+<div class="line"><a name="l12203"></a><span class="lineno">12203</span>&#160;                            {</div>
+<div class="line"><a name="l12204"></a><span class="lineno">12204</span>&#160;                                <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l12205"></a><span class="lineno">12205</span>&#160;                            }</div>
+<div class="line"><a name="l12206"></a><span class="lineno">12206</span>&#160;                        }</div>
+<div class="line"><a name="l12207"></a><span class="lineno">12207</span>&#160;                    }</div>
+<div class="line"><a name="l12208"></a><span class="lineno">12208</span>&#160;                }</div>
+<div class="line"><a name="l12209"></a><span class="lineno">12209</span>&#160;            }</div>
+<div class="line"><a name="l12210"></a><span class="lineno">12210</span>&#160; </div>
+<div class="line"><a name="l12211"></a><span class="lineno">12211</span>&#160;            <span class="keywordflow">if</span>(pBestRequestBlock != VMA_NULL)</div>
+<div class="line"><a name="l12212"></a><span class="lineno">12212</span>&#160;            {</div>
+<div class="line"><a name="l12213"></a><span class="lineno">12213</span>&#160;                <span class="keywordflow">if</span>(mapped)</div>
+<div class="line"><a name="l12214"></a><span class="lineno">12214</span>&#160;                {</div>
+<div class="line"><a name="l12215"></a><span class="lineno">12215</span>&#160;                    VkResult res = pBestRequestBlock-&gt;Map(m_hAllocator, 1, VMA_NULL);</div>
+<div class="line"><a name="l12216"></a><span class="lineno">12216</span>&#160;                    <span class="keywordflow">if</span>(res != VK_SUCCESS)</div>
+<div class="line"><a name="l12217"></a><span class="lineno">12217</span>&#160;                    {</div>
+<div class="line"><a name="l12218"></a><span class="lineno">12218</span>&#160;                        <span class="keywordflow">return</span> res;</div>
+<div class="line"><a name="l12219"></a><span class="lineno">12219</span>&#160;                    }</div>
+<div class="line"><a name="l12220"></a><span class="lineno">12220</span>&#160;                }</div>
+<div class="line"><a name="l12221"></a><span class="lineno">12221</span>&#160; </div>
+<div class="line"><a name="l12222"></a><span class="lineno">12222</span>&#160;                <span class="keywordflow">if</span>(pBestRequestBlock-&gt;m_pMetadata-&gt;MakeRequestedAllocationsLost(</div>
+<div class="line"><a name="l12223"></a><span class="lineno">12223</span>&#160;                    currentFrameIndex,</div>
+<div class="line"><a name="l12224"></a><span class="lineno">12224</span>&#160;                    m_FrameInUseCount,</div>
+<div class="line"><a name="l12225"></a><span class="lineno">12225</span>&#160;                    &amp;bestRequest))</div>
+<div class="line"><a name="l12226"></a><span class="lineno">12226</span>&#160;                {</div>
+<div class="line"><a name="l12227"></a><span class="lineno">12227</span>&#160;                    <span class="comment">// Allocate from this pBlock.</span></div>
+<div class="line"><a name="l12228"></a><span class="lineno">12228</span>&#160;                    *pAllocation = m_hAllocator-&gt;m_AllocationObjectAllocator.Allocate();</div>
+<div class="line"><a name="l12229"></a><span class="lineno">12229</span>&#160;                    (*pAllocation)-&gt;Ctor(currentFrameIndex, isUserDataString);</div>
+<div class="line"><a name="l12230"></a><span class="lineno">12230</span>&#160;                    pBestRequestBlock-&gt;m_pMetadata-&gt;Alloc(bestRequest, suballocType, size, *pAllocation);</div>
+<div class="line"><a name="l12231"></a><span class="lineno">12231</span>&#160;                    UpdateHasEmptyBlock();</div>
+<div class="line"><a name="l12232"></a><span class="lineno">12232</span>&#160;                    (*pAllocation)-&gt;InitBlockAllocation(</div>
+<div class="line"><a name="l12233"></a><span class="lineno">12233</span>&#160;                        pBestRequestBlock,</div>
+<div class="line"><a name="l12234"></a><span class="lineno">12234</span>&#160;                        bestRequest.offset,</div>
+<div class="line"><a name="l12235"></a><span class="lineno">12235</span>&#160;                        alignment,</div>
+<div class="line"><a name="l12236"></a><span class="lineno">12236</span>&#160;                        size,</div>
+<div class="line"><a name="l12237"></a><span class="lineno">12237</span>&#160;                        m_MemoryTypeIndex,</div>
+<div class="line"><a name="l12238"></a><span class="lineno">12238</span>&#160;                        suballocType,</div>
+<div class="line"><a name="l12239"></a><span class="lineno">12239</span>&#160;                        mapped,</div>
+<div class="line"><a name="l12240"></a><span class="lineno">12240</span>&#160;                        (createInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a5f436af6c8fe8540573a6d22627a6fd2">VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT</a>) != 0);</div>
+<div class="line"><a name="l12241"></a><span class="lineno">12241</span>&#160;                    VMA_HEAVY_ASSERT(pBestRequestBlock-&gt;Validate());</div>
+<div class="line"><a name="l12242"></a><span class="lineno">12242</span>&#160;                    VMA_DEBUG_LOG(<span class="stringliteral">&quot;    Returned from existing block&quot;</span>);</div>
+<div class="line"><a name="l12243"></a><span class="lineno">12243</span>&#160;                    (*pAllocation)-&gt;SetUserData(m_hAllocator, createInfo.<a class="code" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19">pUserData</a>);</div>
+<div class="line"><a name="l12244"></a><span class="lineno">12244</span>&#160;                    m_hAllocator-&gt;m_Budget.AddAllocation(m_hAllocator-&gt;MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), size);</div>
+<div class="line"><a name="l12245"></a><span class="lineno">12245</span>&#160;                    <span class="keywordflow">if</span>(VMA_DEBUG_INITIALIZE_ALLOCATIONS)</div>
+<div class="line"><a name="l12246"></a><span class="lineno">12246</span>&#160;                    {</div>
+<div class="line"><a name="l12247"></a><span class="lineno">12247</span>&#160;                        m_hAllocator-&gt;FillAllocation(*pAllocation, VMA_ALLOCATION_FILL_PATTERN_CREATED);</div>
+<div class="line"><a name="l12248"></a><span class="lineno">12248</span>&#160;                    }</div>
+<div class="line"><a name="l12249"></a><span class="lineno">12249</span>&#160;                    <span class="keywordflow">if</span>(IsCorruptionDetectionEnabled())</div>
+<div class="line"><a name="l12250"></a><span class="lineno">12250</span>&#160;                    {</div>
+<div class="line"><a name="l12251"></a><span class="lineno">12251</span>&#160;                        VkResult res = pBestRequestBlock-&gt;WriteMagicValueAroundAllocation(m_hAllocator, bestRequest.offset, size);</div>
+<div class="line"><a name="l12252"></a><span class="lineno">12252</span>&#160;                        VMA_ASSERT(res == VK_SUCCESS &amp;&amp; <span class="stringliteral">&quot;Couldn&#39;t map block memory to write magic value.&quot;</span>);</div>
+<div class="line"><a name="l12253"></a><span class="lineno">12253</span>&#160;                    }</div>
+<div class="line"><a name="l12254"></a><span class="lineno">12254</span>&#160;                    <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l12255"></a><span class="lineno">12255</span>&#160;                }</div>
+<div class="line"><a name="l12256"></a><span class="lineno">12256</span>&#160;                <span class="comment">// else: Some allocations must have been touched while we are here. Next try.</span></div>
+<div class="line"><a name="l12257"></a><span class="lineno">12257</span>&#160;            }</div>
+<div class="line"><a name="l12258"></a><span class="lineno">12258</span>&#160;            <span class="keywordflow">else</span></div>
+<div class="line"><a name="l12259"></a><span class="lineno">12259</span>&#160;            {</div>
+<div class="line"><a name="l12260"></a><span class="lineno">12260</span>&#160;                <span class="comment">// Could not find place in any of the blocks - break outer loop.</span></div>
+<div class="line"><a name="l12261"></a><span class="lineno">12261</span>&#160;                <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l12262"></a><span class="lineno">12262</span>&#160;            }</div>
+<div class="line"><a name="l12263"></a><span class="lineno">12263</span>&#160;        }</div>
+<div class="line"><a name="l12264"></a><span class="lineno">12264</span>&#160;        <span class="comment">/* Maximum number of tries exceeded - a very unlike event when many other</span></div>
+<div class="line"><a name="l12265"></a><span class="lineno">12265</span>&#160;<span class="comment">        threads are simultaneously touching allocations making it impossible to make</span></div>
+<div class="line"><a name="l12266"></a><span class="lineno">12266</span>&#160;<span class="comment">        lost at the same time as we try to allocate. */</span></div>
+<div class="line"><a name="l12267"></a><span class="lineno">12267</span>&#160;        <span class="keywordflow">if</span>(tryIndex == VMA_ALLOCATION_TRY_COUNT)</div>
+<div class="line"><a name="l12268"></a><span class="lineno">12268</span>&#160;        {</div>
+<div class="line"><a name="l12269"></a><span class="lineno">12269</span>&#160;            <span class="keywordflow">return</span> VK_ERROR_TOO_MANY_OBJECTS;</div>
+<div class="line"><a name="l12270"></a><span class="lineno">12270</span>&#160;        }</div>
+<div class="line"><a name="l12271"></a><span class="lineno">12271</span>&#160;    }</div>
+<div class="line"><a name="l12272"></a><span class="lineno">12272</span>&#160; </div>
+<div class="line"><a name="l12273"></a><span class="lineno">12273</span>&#160;    <span class="keywordflow">return</span> VK_ERROR_OUT_OF_DEVICE_MEMORY;</div>
+<div class="line"><a name="l12274"></a><span class="lineno">12274</span>&#160;}</div>
+<div class="line"><a name="l12275"></a><span class="lineno">12275</span>&#160; </div>
+<div class="line"><a name="l12276"></a><span class="lineno">12276</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::Free(</div>
+<div class="line"><a name="l12277"></a><span class="lineno">12277</span>&#160;    <span class="keyword">const</span> <a class="code" href="struct_vma_allocation.html">VmaAllocation</a> hAllocation)</div>
+<div class="line"><a name="l12278"></a><span class="lineno">12278</span>&#160;{</div>
+<div class="line"><a name="l12279"></a><span class="lineno">12279</span>&#160;    VmaDeviceMemoryBlock* pBlockToDelete = VMA_NULL;</div>
+<div class="line"><a name="l12280"></a><span class="lineno">12280</span>&#160; </div>
+<div class="line"><a name="l12281"></a><span class="lineno">12281</span>&#160;    <span class="keywordtype">bool</span> budgetExceeded = <span class="keyword">false</span>;</div>
+<div class="line"><a name="l12282"></a><span class="lineno">12282</span>&#160;    {</div>
+<div class="line"><a name="l12283"></a><span class="lineno">12283</span>&#160;        <span class="keyword">const</span> uint32_t heapIndex = m_hAllocator-&gt;MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex);</div>
+<div class="line"><a name="l12284"></a><span class="lineno">12284</span>&#160;        <a class="code" href="struct_vma_budget.html">VmaBudget</a> heapBudget = {};</div>
+<div class="line"><a name="l12285"></a><span class="lineno">12285</span>&#160;        m_hAllocator-&gt;GetBudget(&amp;heapBudget, heapIndex, 1);</div>
+<div class="line"><a name="l12286"></a><span class="lineno">12286</span>&#160;        budgetExceeded = heapBudget.<a class="code" href="struct_vma_budget.html#a84dd1ecca8b0110259eb206dbadb11f6">usage</a> &gt;= heapBudget.<a class="code" href="struct_vma_budget.html#ab82e1d1754c2d210d0bdf90220bc6cdd">budget</a>;</div>
+<div class="line"><a name="l12287"></a><span class="lineno">12287</span>&#160;    }</div>
 <div class="line"><a name="l12288"></a><span class="lineno">12288</span>&#160; </div>
-<div class="line"><a name="l12289"></a><span class="lineno">12289</span>&#160;        <span class="keywordflow">if</span>(IsCorruptionDetectionEnabled())</div>
-<div class="line"><a name="l12290"></a><span class="lineno">12290</span>&#160;        {</div>
-<div class="line"><a name="l12291"></a><span class="lineno">12291</span>&#160;            VkResult res = pBlock-&gt;ValidateMagicValueAroundAllocation(m_hAllocator, hAllocation-&gt;GetOffset(), hAllocation-&gt;GetSize());</div>
-<div class="line"><a name="l12292"></a><span class="lineno">12292</span>&#160;            VMA_ASSERT(res == VK_SUCCESS &amp;&amp; <span class="stringliteral">&quot;Couldn&#39;t map block memory to validate magic value.&quot;</span>);</div>
-<div class="line"><a name="l12293"></a><span class="lineno">12293</span>&#160;        }</div>
+<div class="line"><a name="l12289"></a><span class="lineno">12289</span>&#160;    <span class="comment">// Scope for lock.</span></div>
+<div class="line"><a name="l12290"></a><span class="lineno">12290</span>&#160;    {</div>
+<div class="line"><a name="l12291"></a><span class="lineno">12291</span>&#160;        VmaMutexLockWrite lock(m_Mutex, m_hAllocator-&gt;m_UseMutex);</div>
+<div class="line"><a name="l12292"></a><span class="lineno">12292</span>&#160; </div>
+<div class="line"><a name="l12293"></a><span class="lineno">12293</span>&#160;        VmaDeviceMemoryBlock* pBlock = hAllocation-&gt;GetBlock();</div>
 <div class="line"><a name="l12294"></a><span class="lineno">12294</span>&#160; </div>
-<div class="line"><a name="l12295"></a><span class="lineno">12295</span>&#160;        <span class="keywordflow">if</span>(hAllocation-&gt;IsPersistentMap())</div>
+<div class="line"><a name="l12295"></a><span class="lineno">12295</span>&#160;        <span class="keywordflow">if</span>(IsCorruptionDetectionEnabled())</div>
 <div class="line"><a name="l12296"></a><span class="lineno">12296</span>&#160;        {</div>
-<div class="line"><a name="l12297"></a><span class="lineno">12297</span>&#160;            pBlock-&gt;Unmap(m_hAllocator, 1);</div>
-<div class="line"><a name="l12298"></a><span class="lineno">12298</span>&#160;        }</div>
-<div class="line"><a name="l12299"></a><span class="lineno">12299</span>&#160; </div>
-<div class="line"><a name="l12300"></a><span class="lineno">12300</span>&#160;        pBlock-&gt;m_pMetadata-&gt;Free(hAllocation);</div>
-<div class="line"><a name="l12301"></a><span class="lineno">12301</span>&#160;        VMA_HEAVY_ASSERT(pBlock-&gt;Validate());</div>
-<div class="line"><a name="l12302"></a><span class="lineno">12302</span>&#160; </div>
-<div class="line"><a name="l12303"></a><span class="lineno">12303</span>&#160;        VMA_DEBUG_LOG(<span class="stringliteral">&quot;  Freed from MemoryTypeIndex=%u&quot;</span>, m_MemoryTypeIndex);</div>
-<div class="line"><a name="l12304"></a><span class="lineno">12304</span>&#160; </div>
-<div class="line"><a name="l12305"></a><span class="lineno">12305</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">bool</span> canDeleteBlock = m_Blocks.size() &gt; m_MinBlockCount;</div>
-<div class="line"><a name="l12306"></a><span class="lineno">12306</span>&#160;        <span class="comment">// pBlock became empty after this deallocation.</span></div>
-<div class="line"><a name="l12307"></a><span class="lineno">12307</span>&#160;        <span class="keywordflow">if</span>(pBlock-&gt;m_pMetadata-&gt;IsEmpty())</div>
-<div class="line"><a name="l12308"></a><span class="lineno">12308</span>&#160;        {</div>
-<div class="line"><a name="l12309"></a><span class="lineno">12309</span>&#160;            <span class="comment">// Already has empty block. We don&#39;t want to have two, so delete this one.</span></div>
-<div class="line"><a name="l12310"></a><span class="lineno">12310</span>&#160;            <span class="keywordflow">if</span>((m_HasEmptyBlock || budgetExceeded) &amp;&amp; canDeleteBlock)</div>
-<div class="line"><a name="l12311"></a><span class="lineno">12311</span>&#160;            {</div>
-<div class="line"><a name="l12312"></a><span class="lineno">12312</span>&#160;                pBlockToDelete = pBlock;</div>
-<div class="line"><a name="l12313"></a><span class="lineno">12313</span>&#160;                Remove(pBlock);</div>
-<div class="line"><a name="l12314"></a><span class="lineno">12314</span>&#160;            }</div>
-<div class="line"><a name="l12315"></a><span class="lineno">12315</span>&#160;            <span class="comment">// else: We now have an empty block - leave it.</span></div>
-<div class="line"><a name="l12316"></a><span class="lineno">12316</span>&#160;        }</div>
-<div class="line"><a name="l12317"></a><span class="lineno">12317</span>&#160;        <span class="comment">// pBlock didn&#39;t become empty, but we have another empty block - find and free that one.</span></div>
-<div class="line"><a name="l12318"></a><span class="lineno">12318</span>&#160;        <span class="comment">// (This is optional, heuristics.)</span></div>
-<div class="line"><a name="l12319"></a><span class="lineno">12319</span>&#160;        <span class="keywordflow">else</span> <span class="keywordflow">if</span>(m_HasEmptyBlock &amp;&amp; canDeleteBlock)</div>
-<div class="line"><a name="l12320"></a><span class="lineno">12320</span>&#160;        {</div>
-<div class="line"><a name="l12321"></a><span class="lineno">12321</span>&#160;            VmaDeviceMemoryBlock* pLastBlock = m_Blocks.back();</div>
-<div class="line"><a name="l12322"></a><span class="lineno">12322</span>&#160;            <span class="keywordflow">if</span>(pLastBlock-&gt;m_pMetadata-&gt;IsEmpty())</div>
-<div class="line"><a name="l12323"></a><span class="lineno">12323</span>&#160;            {</div>
-<div class="line"><a name="l12324"></a><span class="lineno">12324</span>&#160;                pBlockToDelete = pLastBlock;</div>
-<div class="line"><a name="l12325"></a><span class="lineno">12325</span>&#160;                m_Blocks.pop_back();</div>
-<div class="line"><a name="l12326"></a><span class="lineno">12326</span>&#160;            }</div>
-<div class="line"><a name="l12327"></a><span class="lineno">12327</span>&#160;        }</div>
-<div class="line"><a name="l12328"></a><span class="lineno">12328</span>&#160; </div>
-<div class="line"><a name="l12329"></a><span class="lineno">12329</span>&#160;        UpdateHasEmptyBlock();</div>
-<div class="line"><a name="l12330"></a><span class="lineno">12330</span>&#160;        IncrementallySortBlocks();</div>
-<div class="line"><a name="l12331"></a><span class="lineno">12331</span>&#160;    }</div>
-<div class="line"><a name="l12332"></a><span class="lineno">12332</span>&#160; </div>
-<div class="line"><a name="l12333"></a><span class="lineno">12333</span>&#160;    <span class="comment">// Destruction of a free block. Deferred until this point, outside of mutex</span></div>
-<div class="line"><a name="l12334"></a><span class="lineno">12334</span>&#160;    <span class="comment">// lock, for performance reason.</span></div>
-<div class="line"><a name="l12335"></a><span class="lineno">12335</span>&#160;    <span class="keywordflow">if</span>(pBlockToDelete != VMA_NULL)</div>
-<div class="line"><a name="l12336"></a><span class="lineno">12336</span>&#160;    {</div>
-<div class="line"><a name="l12337"></a><span class="lineno">12337</span>&#160;        VMA_DEBUG_LOG(<span class="stringliteral">&quot;    Deleted empty block&quot;</span>);</div>
-<div class="line"><a name="l12338"></a><span class="lineno">12338</span>&#160;        pBlockToDelete-&gt;Destroy(m_hAllocator);</div>
-<div class="line"><a name="l12339"></a><span class="lineno">12339</span>&#160;        vma_delete(m_hAllocator, pBlockToDelete);</div>
-<div class="line"><a name="l12340"></a><span class="lineno">12340</span>&#160;    }</div>
-<div class="line"><a name="l12341"></a><span class="lineno">12341</span>&#160;}</div>
-<div class="line"><a name="l12342"></a><span class="lineno">12342</span>&#160; </div>
-<div class="line"><a name="l12343"></a><span class="lineno">12343</span>&#160;VkDeviceSize VmaBlockVector::CalcMaxBlockSize()<span class="keyword"> const</span></div>
-<div class="line"><a name="l12344"></a><span class="lineno">12344</span>&#160;<span class="keyword"></span>{</div>
-<div class="line"><a name="l12345"></a><span class="lineno">12345</span>&#160;    VkDeviceSize result = 0;</div>
-<div class="line"><a name="l12346"></a><span class="lineno">12346</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = m_Blocks.size(); i--; )</div>
-<div class="line"><a name="l12347"></a><span class="lineno">12347</span>&#160;    {</div>
-<div class="line"><a name="l12348"></a><span class="lineno">12348</span>&#160;        result = VMA_MAX(result, m_Blocks[i]-&gt;m_pMetadata-&gt;GetSize());</div>
-<div class="line"><a name="l12349"></a><span class="lineno">12349</span>&#160;        <span class="keywordflow">if</span>(result &gt;= m_PreferredBlockSize)</div>
-<div class="line"><a name="l12350"></a><span class="lineno">12350</span>&#160;        {</div>
-<div class="line"><a name="l12351"></a><span class="lineno">12351</span>&#160;            <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l12352"></a><span class="lineno">12352</span>&#160;        }</div>
-<div class="line"><a name="l12353"></a><span class="lineno">12353</span>&#160;    }</div>
-<div class="line"><a name="l12354"></a><span class="lineno">12354</span>&#160;    <span class="keywordflow">return</span> result;</div>
-<div class="line"><a name="l12355"></a><span class="lineno">12355</span>&#160;}</div>
-<div class="line"><a name="l12356"></a><span class="lineno">12356</span>&#160; </div>
-<div class="line"><a name="l12357"></a><span class="lineno">12357</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::Remove(VmaDeviceMemoryBlock* pBlock)</div>
-<div class="line"><a name="l12358"></a><span class="lineno">12358</span>&#160;{</div>
-<div class="line"><a name="l12359"></a><span class="lineno">12359</span>&#160;    <span class="keywordflow">for</span>(uint32_t blockIndex = 0; blockIndex &lt; m_Blocks.size(); ++blockIndex)</div>
-<div class="line"><a name="l12360"></a><span class="lineno">12360</span>&#160;    {</div>
-<div class="line"><a name="l12361"></a><span class="lineno">12361</span>&#160;        <span class="keywordflow">if</span>(m_Blocks[blockIndex] == pBlock)</div>
-<div class="line"><a name="l12362"></a><span class="lineno">12362</span>&#160;        {</div>
-<div class="line"><a name="l12363"></a><span class="lineno">12363</span>&#160;            VmaVectorRemove(m_Blocks, blockIndex);</div>
-<div class="line"><a name="l12364"></a><span class="lineno">12364</span>&#160;            <span class="keywordflow">return</span>;</div>
-<div class="line"><a name="l12365"></a><span class="lineno">12365</span>&#160;        }</div>
-<div class="line"><a name="l12366"></a><span class="lineno">12366</span>&#160;    }</div>
-<div class="line"><a name="l12367"></a><span class="lineno">12367</span>&#160;    VMA_ASSERT(0);</div>
-<div class="line"><a name="l12368"></a><span class="lineno">12368</span>&#160;}</div>
-<div class="line"><a name="l12369"></a><span class="lineno">12369</span>&#160; </div>
-<div class="line"><a name="l12370"></a><span class="lineno">12370</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::IncrementallySortBlocks()</div>
-<div class="line"><a name="l12371"></a><span class="lineno">12371</span>&#160;{</div>
-<div class="line"><a name="l12372"></a><span class="lineno">12372</span>&#160;    <span class="keywordflow">if</span>(m_Algorithm != <a class="code" href="vk__mem__alloc_8h.html#a9a7c45f9c863695d98c83fa5ac940fe7a13c8a444197c67866be9cb05599fc726">VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT</a>)</div>
-<div class="line"><a name="l12373"></a><span class="lineno">12373</span>&#160;    {</div>
-<div class="line"><a name="l12374"></a><span class="lineno">12374</span>&#160;        <span class="comment">// Bubble sort only until first swap.</span></div>
-<div class="line"><a name="l12375"></a><span class="lineno">12375</span>&#160;        <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 1; i &lt; m_Blocks.size(); ++i)</div>
-<div class="line"><a name="l12376"></a><span class="lineno">12376</span>&#160;        {</div>
-<div class="line"><a name="l12377"></a><span class="lineno">12377</span>&#160;            <span class="keywordflow">if</span>(m_Blocks[i - 1]-&gt;m_pMetadata-&gt;GetSumFreeSize() &gt; m_Blocks[i]-&gt;m_pMetadata-&gt;GetSumFreeSize())</div>
-<div class="line"><a name="l12378"></a><span class="lineno">12378</span>&#160;            {</div>
-<div class="line"><a name="l12379"></a><span class="lineno">12379</span>&#160;                VMA_SWAP(m_Blocks[i - 1], m_Blocks[i]);</div>
-<div class="line"><a name="l12380"></a><span class="lineno">12380</span>&#160;                <span class="keywordflow">return</span>;</div>
-<div class="line"><a name="l12381"></a><span class="lineno">12381</span>&#160;            }</div>
-<div class="line"><a name="l12382"></a><span class="lineno">12382</span>&#160;        }</div>
-<div class="line"><a name="l12383"></a><span class="lineno">12383</span>&#160;    }</div>
-<div class="line"><a name="l12384"></a><span class="lineno">12384</span>&#160;}</div>
-<div class="line"><a name="l12385"></a><span class="lineno">12385</span>&#160; </div>
-<div class="line"><a name="l12386"></a><span class="lineno">12386</span>&#160;VkResult VmaBlockVector::AllocateFromBlock(</div>
-<div class="line"><a name="l12387"></a><span class="lineno">12387</span>&#160;    VmaDeviceMemoryBlock* pBlock,</div>
-<div class="line"><a name="l12388"></a><span class="lineno">12388</span>&#160;    uint32_t currentFrameIndex,</div>
-<div class="line"><a name="l12389"></a><span class="lineno">12389</span>&#160;    VkDeviceSize size,</div>
-<div class="line"><a name="l12390"></a><span class="lineno">12390</span>&#160;    VkDeviceSize alignment,</div>
-<div class="line"><a name="l12391"></a><span class="lineno">12391</span>&#160;    <a class="code" href="vk__mem__alloc_8h.html#a5225e5e11f8376f6a31a1791f3d6e817">VmaAllocationCreateFlags</a> allocFlags,</div>
-<div class="line"><a name="l12392"></a><span class="lineno">12392</span>&#160;    <span class="keywordtype">void</span>* pUserData,</div>
-<div class="line"><a name="l12393"></a><span class="lineno">12393</span>&#160;    VmaSuballocationType suballocType,</div>
-<div class="line"><a name="l12394"></a><span class="lineno">12394</span>&#160;    uint32_t strategy,</div>
-<div class="line"><a name="l12395"></a><span class="lineno">12395</span>&#160;    <a class="code" href="struct_vma_allocation.html">VmaAllocation</a>* pAllocation)</div>
-<div class="line"><a name="l12396"></a><span class="lineno">12396</span>&#160;{</div>
-<div class="line"><a name="l12397"></a><span class="lineno">12397</span>&#160;    VMA_ASSERT((allocFlags &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a68686d0ce9beb0d4d1b9f2b8b1389a7e">VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT</a>) == 0);</div>
-<div class="line"><a name="l12398"></a><span class="lineno">12398</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> isUpperAddress = (allocFlags &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a42ba3a2d2c7117953210b7c3ef8da0df">VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT</a>) != 0;</div>
-<div class="line"><a name="l12399"></a><span class="lineno">12399</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> mapped = (allocFlags &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a11da372cc3a82931c5e5d6146cd9dd1f">VMA_ALLOCATION_CREATE_MAPPED_BIT</a>) != 0;</div>
-<div class="line"><a name="l12400"></a><span class="lineno">12400</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> isUserDataString = (allocFlags &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597aa6f24f821cd6a7c5e4a443f7bf59c520">VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT</a>) != 0;</div>
-<div class="line"><a name="l12401"></a><span class="lineno">12401</span>&#160; </div>
-<div class="line"><a name="l12402"></a><span class="lineno">12402</span>&#160;    VmaAllocationRequest currRequest = {};</div>
-<div class="line"><a name="l12403"></a><span class="lineno">12403</span>&#160;    <span class="keywordflow">if</span>(pBlock-&gt;m_pMetadata-&gt;CreateAllocationRequest(</div>
-<div class="line"><a name="l12404"></a><span class="lineno">12404</span>&#160;        currentFrameIndex,</div>
-<div class="line"><a name="l12405"></a><span class="lineno">12405</span>&#160;        m_FrameInUseCount,</div>
-<div class="line"><a name="l12406"></a><span class="lineno">12406</span>&#160;        m_BufferImageGranularity,</div>
-<div class="line"><a name="l12407"></a><span class="lineno">12407</span>&#160;        size,</div>
-<div class="line"><a name="l12408"></a><span class="lineno">12408</span>&#160;        alignment,</div>
-<div class="line"><a name="l12409"></a><span class="lineno">12409</span>&#160;        isUpperAddress,</div>
-<div class="line"><a name="l12410"></a><span class="lineno">12410</span>&#160;        suballocType,</div>
-<div class="line"><a name="l12411"></a><span class="lineno">12411</span>&#160;        <span class="keyword">false</span>, <span class="comment">// canMakeOtherLost</span></div>
-<div class="line"><a name="l12412"></a><span class="lineno">12412</span>&#160;        strategy,</div>
-<div class="line"><a name="l12413"></a><span class="lineno">12413</span>&#160;        &amp;currRequest))</div>
-<div class="line"><a name="l12414"></a><span class="lineno">12414</span>&#160;    {</div>
-<div class="line"><a name="l12415"></a><span class="lineno">12415</span>&#160;        <span class="comment">// Allocate from pCurrBlock.</span></div>
-<div class="line"><a name="l12416"></a><span class="lineno">12416</span>&#160;        VMA_ASSERT(currRequest.itemsToMakeLostCount == 0);</div>
-<div class="line"><a name="l12417"></a><span class="lineno">12417</span>&#160; </div>
-<div class="line"><a name="l12418"></a><span class="lineno">12418</span>&#160;        <span class="keywordflow">if</span>(mapped)</div>
-<div class="line"><a name="l12419"></a><span class="lineno">12419</span>&#160;        {</div>
-<div class="line"><a name="l12420"></a><span class="lineno">12420</span>&#160;            VkResult res = pBlock-&gt;Map(m_hAllocator, 1, VMA_NULL);</div>
-<div class="line"><a name="l12421"></a><span class="lineno">12421</span>&#160;            <span class="keywordflow">if</span>(res != VK_SUCCESS)</div>
-<div class="line"><a name="l12422"></a><span class="lineno">12422</span>&#160;            {</div>
-<div class="line"><a name="l12423"></a><span class="lineno">12423</span>&#160;                <span class="keywordflow">return</span> res;</div>
-<div class="line"><a name="l12424"></a><span class="lineno">12424</span>&#160;            }</div>
-<div class="line"><a name="l12425"></a><span class="lineno">12425</span>&#160;        }</div>
-<div class="line"><a name="l12426"></a><span class="lineno">12426</span>&#160;            </div>
-<div class="line"><a name="l12427"></a><span class="lineno">12427</span>&#160;        *pAllocation = m_hAllocator-&gt;m_AllocationObjectAllocator.Allocate();</div>
-<div class="line"><a name="l12428"></a><span class="lineno">12428</span>&#160;        (*pAllocation)-&gt;Ctor(currentFrameIndex, isUserDataString);</div>
-<div class="line"><a name="l12429"></a><span class="lineno">12429</span>&#160;        pBlock-&gt;m_pMetadata-&gt;Alloc(currRequest, suballocType, size, *pAllocation);</div>
-<div class="line"><a name="l12430"></a><span class="lineno">12430</span>&#160;        UpdateHasEmptyBlock();</div>
-<div class="line"><a name="l12431"></a><span class="lineno">12431</span>&#160;        (*pAllocation)-&gt;InitBlockAllocation(</div>
-<div class="line"><a name="l12432"></a><span class="lineno">12432</span>&#160;            pBlock,</div>
-<div class="line"><a name="l12433"></a><span class="lineno">12433</span>&#160;            currRequest.offset,</div>
-<div class="line"><a name="l12434"></a><span class="lineno">12434</span>&#160;            alignment,</div>
-<div class="line"><a name="l12435"></a><span class="lineno">12435</span>&#160;            size,</div>
-<div class="line"><a name="l12436"></a><span class="lineno">12436</span>&#160;            m_MemoryTypeIndex,</div>
-<div class="line"><a name="l12437"></a><span class="lineno">12437</span>&#160;            suballocType,</div>
-<div class="line"><a name="l12438"></a><span class="lineno">12438</span>&#160;            mapped,</div>
-<div class="line"><a name="l12439"></a><span class="lineno">12439</span>&#160;            (allocFlags &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a5f436af6c8fe8540573a6d22627a6fd2">VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT</a>) != 0);</div>
-<div class="line"><a name="l12440"></a><span class="lineno">12440</span>&#160;        VMA_HEAVY_ASSERT(pBlock-&gt;Validate());</div>
-<div class="line"><a name="l12441"></a><span class="lineno">12441</span>&#160;        (*pAllocation)-&gt;SetUserData(m_hAllocator, pUserData);</div>
-<div class="line"><a name="l12442"></a><span class="lineno">12442</span>&#160;        m_hAllocator-&gt;m_Budget.AddAllocation(m_hAllocator-&gt;MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), size);</div>
-<div class="line"><a name="l12443"></a><span class="lineno">12443</span>&#160;        <span class="keywordflow">if</span>(VMA_DEBUG_INITIALIZE_ALLOCATIONS)</div>
-<div class="line"><a name="l12444"></a><span class="lineno">12444</span>&#160;        {</div>
-<div class="line"><a name="l12445"></a><span class="lineno">12445</span>&#160;            m_hAllocator-&gt;FillAllocation(*pAllocation, VMA_ALLOCATION_FILL_PATTERN_CREATED);</div>
-<div class="line"><a name="l12446"></a><span class="lineno">12446</span>&#160;        }</div>
-<div class="line"><a name="l12447"></a><span class="lineno">12447</span>&#160;        <span class="keywordflow">if</span>(IsCorruptionDetectionEnabled())</div>
-<div class="line"><a name="l12448"></a><span class="lineno">12448</span>&#160;        {</div>
-<div class="line"><a name="l12449"></a><span class="lineno">12449</span>&#160;            VkResult res = pBlock-&gt;WriteMagicValueAroundAllocation(m_hAllocator, currRequest.offset, size);</div>
-<div class="line"><a name="l12450"></a><span class="lineno">12450</span>&#160;            VMA_ASSERT(res == VK_SUCCESS &amp;&amp; <span class="stringliteral">&quot;Couldn&#39;t map block memory to write magic value.&quot;</span>);</div>
-<div class="line"><a name="l12451"></a><span class="lineno">12451</span>&#160;        }</div>
-<div class="line"><a name="l12452"></a><span class="lineno">12452</span>&#160;        <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l12453"></a><span class="lineno">12453</span>&#160;    }</div>
-<div class="line"><a name="l12454"></a><span class="lineno">12454</span>&#160;    <span class="keywordflow">return</span> VK_ERROR_OUT_OF_DEVICE_MEMORY;</div>
-<div class="line"><a name="l12455"></a><span class="lineno">12455</span>&#160;}</div>
-<div class="line"><a name="l12456"></a><span class="lineno">12456</span>&#160; </div>
-<div class="line"><a name="l12457"></a><span class="lineno">12457</span>&#160;VkResult VmaBlockVector::CreateBlock(VkDeviceSize blockSize, <span class="keywordtype">size_t</span>* pNewBlockIndex)</div>
-<div class="line"><a name="l12458"></a><span class="lineno">12458</span>&#160;{</div>
-<div class="line"><a name="l12459"></a><span class="lineno">12459</span>&#160;    VkMemoryAllocateInfo allocInfo = { VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO };</div>
-<div class="line"><a name="l12460"></a><span class="lineno">12460</span>&#160;    allocInfo.memoryTypeIndex = m_MemoryTypeIndex;</div>
-<div class="line"><a name="l12461"></a><span class="lineno">12461</span>&#160;    allocInfo.allocationSize = blockSize;</div>
-<div class="line"><a name="l12462"></a><span class="lineno">12462</span>&#160;    VkDeviceMemory mem = VK_NULL_HANDLE;</div>
-<div class="line"><a name="l12463"></a><span class="lineno">12463</span>&#160;    VkResult res = m_hAllocator-&gt;AllocateVulkanMemory(&amp;allocInfo, &amp;mem);</div>
-<div class="line"><a name="l12464"></a><span class="lineno">12464</span>&#160;    <span class="keywordflow">if</span>(res &lt; 0)</div>
-<div class="line"><a name="l12465"></a><span class="lineno">12465</span>&#160;    {</div>
-<div class="line"><a name="l12466"></a><span class="lineno">12466</span>&#160;        <span class="keywordflow">return</span> res;</div>
-<div class="line"><a name="l12467"></a><span class="lineno">12467</span>&#160;    }</div>
-<div class="line"><a name="l12468"></a><span class="lineno">12468</span>&#160; </div>
-<div class="line"><a name="l12469"></a><span class="lineno">12469</span>&#160;    <span class="comment">// New VkDeviceMemory successfully created.</span></div>
-<div class="line"><a name="l12470"></a><span class="lineno">12470</span>&#160; </div>
-<div class="line"><a name="l12471"></a><span class="lineno">12471</span>&#160;    <span class="comment">// Create new Allocation for it.</span></div>
-<div class="line"><a name="l12472"></a><span class="lineno">12472</span>&#160;    VmaDeviceMemoryBlock* <span class="keyword">const</span> pBlock = vma_new(m_hAllocator, VmaDeviceMemoryBlock)(m_hAllocator);</div>
-<div class="line"><a name="l12473"></a><span class="lineno">12473</span>&#160;    pBlock-&gt;Init(</div>
-<div class="line"><a name="l12474"></a><span class="lineno">12474</span>&#160;        m_hAllocator,</div>
-<div class="line"><a name="l12475"></a><span class="lineno">12475</span>&#160;        m_hParentPool,</div>
-<div class="line"><a name="l12476"></a><span class="lineno">12476</span>&#160;        m_MemoryTypeIndex,</div>
-<div class="line"><a name="l12477"></a><span class="lineno">12477</span>&#160;        mem,</div>
-<div class="line"><a name="l12478"></a><span class="lineno">12478</span>&#160;        allocInfo.allocationSize,</div>
-<div class="line"><a name="l12479"></a><span class="lineno">12479</span>&#160;        m_NextBlockId++,</div>
-<div class="line"><a name="l12480"></a><span class="lineno">12480</span>&#160;        m_Algorithm);</div>
-<div class="line"><a name="l12481"></a><span class="lineno">12481</span>&#160; </div>
-<div class="line"><a name="l12482"></a><span class="lineno">12482</span>&#160;    m_Blocks.push_back(pBlock);</div>
-<div class="line"><a name="l12483"></a><span class="lineno">12483</span>&#160;    <span class="keywordflow">if</span>(pNewBlockIndex != VMA_NULL)</div>
-<div class="line"><a name="l12484"></a><span class="lineno">12484</span>&#160;    {</div>
-<div class="line"><a name="l12485"></a><span class="lineno">12485</span>&#160;        *pNewBlockIndex = m_Blocks.size() - 1;</div>
-<div class="line"><a name="l12486"></a><span class="lineno">12486</span>&#160;    }</div>
+<div class="line"><a name="l12297"></a><span class="lineno">12297</span>&#160;            VkResult res = pBlock-&gt;ValidateMagicValueAroundAllocation(m_hAllocator, hAllocation-&gt;GetOffset(), hAllocation-&gt;GetSize());</div>
+<div class="line"><a name="l12298"></a><span class="lineno">12298</span>&#160;            VMA_ASSERT(res == VK_SUCCESS &amp;&amp; <span class="stringliteral">&quot;Couldn&#39;t map block memory to validate magic value.&quot;</span>);</div>
+<div class="line"><a name="l12299"></a><span class="lineno">12299</span>&#160;        }</div>
+<div class="line"><a name="l12300"></a><span class="lineno">12300</span>&#160; </div>
+<div class="line"><a name="l12301"></a><span class="lineno">12301</span>&#160;        <span class="keywordflow">if</span>(hAllocation-&gt;IsPersistentMap())</div>
+<div class="line"><a name="l12302"></a><span class="lineno">12302</span>&#160;        {</div>
+<div class="line"><a name="l12303"></a><span class="lineno">12303</span>&#160;            pBlock-&gt;Unmap(m_hAllocator, 1);</div>
+<div class="line"><a name="l12304"></a><span class="lineno">12304</span>&#160;        }</div>
+<div class="line"><a name="l12305"></a><span class="lineno">12305</span>&#160; </div>
+<div class="line"><a name="l12306"></a><span class="lineno">12306</span>&#160;        pBlock-&gt;m_pMetadata-&gt;Free(hAllocation);</div>
+<div class="line"><a name="l12307"></a><span class="lineno">12307</span>&#160;        VMA_HEAVY_ASSERT(pBlock-&gt;Validate());</div>
+<div class="line"><a name="l12308"></a><span class="lineno">12308</span>&#160; </div>
+<div class="line"><a name="l12309"></a><span class="lineno">12309</span>&#160;        VMA_DEBUG_LOG(<span class="stringliteral">&quot;  Freed from MemoryTypeIndex=%u&quot;</span>, m_MemoryTypeIndex);</div>
+<div class="line"><a name="l12310"></a><span class="lineno">12310</span>&#160; </div>
+<div class="line"><a name="l12311"></a><span class="lineno">12311</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">bool</span> canDeleteBlock = m_Blocks.size() &gt; m_MinBlockCount;</div>
+<div class="line"><a name="l12312"></a><span class="lineno">12312</span>&#160;        <span class="comment">// pBlock became empty after this deallocation.</span></div>
+<div class="line"><a name="l12313"></a><span class="lineno">12313</span>&#160;        <span class="keywordflow">if</span>(pBlock-&gt;m_pMetadata-&gt;IsEmpty())</div>
+<div class="line"><a name="l12314"></a><span class="lineno">12314</span>&#160;        {</div>
+<div class="line"><a name="l12315"></a><span class="lineno">12315</span>&#160;            <span class="comment">// Already has empty block. We don&#39;t want to have two, so delete this one.</span></div>
+<div class="line"><a name="l12316"></a><span class="lineno">12316</span>&#160;            <span class="keywordflow">if</span>((m_HasEmptyBlock || budgetExceeded) &amp;&amp; canDeleteBlock)</div>
+<div class="line"><a name="l12317"></a><span class="lineno">12317</span>&#160;            {</div>
+<div class="line"><a name="l12318"></a><span class="lineno">12318</span>&#160;                pBlockToDelete = pBlock;</div>
+<div class="line"><a name="l12319"></a><span class="lineno">12319</span>&#160;                Remove(pBlock);</div>
+<div class="line"><a name="l12320"></a><span class="lineno">12320</span>&#160;            }</div>
+<div class="line"><a name="l12321"></a><span class="lineno">12321</span>&#160;            <span class="comment">// else: We now have an empty block - leave it.</span></div>
+<div class="line"><a name="l12322"></a><span class="lineno">12322</span>&#160;        }</div>
+<div class="line"><a name="l12323"></a><span class="lineno">12323</span>&#160;        <span class="comment">// pBlock didn&#39;t become empty, but we have another empty block - find and free that one.</span></div>
+<div class="line"><a name="l12324"></a><span class="lineno">12324</span>&#160;        <span class="comment">// (This is optional, heuristics.)</span></div>
+<div class="line"><a name="l12325"></a><span class="lineno">12325</span>&#160;        <span class="keywordflow">else</span> <span class="keywordflow">if</span>(m_HasEmptyBlock &amp;&amp; canDeleteBlock)</div>
+<div class="line"><a name="l12326"></a><span class="lineno">12326</span>&#160;        {</div>
+<div class="line"><a name="l12327"></a><span class="lineno">12327</span>&#160;            VmaDeviceMemoryBlock* pLastBlock = m_Blocks.back();</div>
+<div class="line"><a name="l12328"></a><span class="lineno">12328</span>&#160;            <span class="keywordflow">if</span>(pLastBlock-&gt;m_pMetadata-&gt;IsEmpty())</div>
+<div class="line"><a name="l12329"></a><span class="lineno">12329</span>&#160;            {</div>
+<div class="line"><a name="l12330"></a><span class="lineno">12330</span>&#160;                pBlockToDelete = pLastBlock;</div>
+<div class="line"><a name="l12331"></a><span class="lineno">12331</span>&#160;                m_Blocks.pop_back();</div>
+<div class="line"><a name="l12332"></a><span class="lineno">12332</span>&#160;            }</div>
+<div class="line"><a name="l12333"></a><span class="lineno">12333</span>&#160;        }</div>
+<div class="line"><a name="l12334"></a><span class="lineno">12334</span>&#160; </div>
+<div class="line"><a name="l12335"></a><span class="lineno">12335</span>&#160;        UpdateHasEmptyBlock();</div>
+<div class="line"><a name="l12336"></a><span class="lineno">12336</span>&#160;        IncrementallySortBlocks();</div>
+<div class="line"><a name="l12337"></a><span class="lineno">12337</span>&#160;    }</div>
+<div class="line"><a name="l12338"></a><span class="lineno">12338</span>&#160; </div>
+<div class="line"><a name="l12339"></a><span class="lineno">12339</span>&#160;    <span class="comment">// Destruction of a free block. Deferred until this point, outside of mutex</span></div>
+<div class="line"><a name="l12340"></a><span class="lineno">12340</span>&#160;    <span class="comment">// lock, for performance reason.</span></div>
+<div class="line"><a name="l12341"></a><span class="lineno">12341</span>&#160;    <span class="keywordflow">if</span>(pBlockToDelete != VMA_NULL)</div>
+<div class="line"><a name="l12342"></a><span class="lineno">12342</span>&#160;    {</div>
+<div class="line"><a name="l12343"></a><span class="lineno">12343</span>&#160;        VMA_DEBUG_LOG(<span class="stringliteral">&quot;    Deleted empty block&quot;</span>);</div>
+<div class="line"><a name="l12344"></a><span class="lineno">12344</span>&#160;        pBlockToDelete-&gt;Destroy(m_hAllocator);</div>
+<div class="line"><a name="l12345"></a><span class="lineno">12345</span>&#160;        vma_delete(m_hAllocator, pBlockToDelete);</div>
+<div class="line"><a name="l12346"></a><span class="lineno">12346</span>&#160;    }</div>
+<div class="line"><a name="l12347"></a><span class="lineno">12347</span>&#160;}</div>
+<div class="line"><a name="l12348"></a><span class="lineno">12348</span>&#160; </div>
+<div class="line"><a name="l12349"></a><span class="lineno">12349</span>&#160;VkDeviceSize VmaBlockVector::CalcMaxBlockSize()<span class="keyword"> const</span></div>
+<div class="line"><a name="l12350"></a><span class="lineno">12350</span>&#160;<span class="keyword"></span>{</div>
+<div class="line"><a name="l12351"></a><span class="lineno">12351</span>&#160;    VkDeviceSize result = 0;</div>
+<div class="line"><a name="l12352"></a><span class="lineno">12352</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = m_Blocks.size(); i--; )</div>
+<div class="line"><a name="l12353"></a><span class="lineno">12353</span>&#160;    {</div>
+<div class="line"><a name="l12354"></a><span class="lineno">12354</span>&#160;        result = VMA_MAX(result, m_Blocks[i]-&gt;m_pMetadata-&gt;GetSize());</div>
+<div class="line"><a name="l12355"></a><span class="lineno">12355</span>&#160;        <span class="keywordflow">if</span>(result &gt;= m_PreferredBlockSize)</div>
+<div class="line"><a name="l12356"></a><span class="lineno">12356</span>&#160;        {</div>
+<div class="line"><a name="l12357"></a><span class="lineno">12357</span>&#160;            <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l12358"></a><span class="lineno">12358</span>&#160;        }</div>
+<div class="line"><a name="l12359"></a><span class="lineno">12359</span>&#160;    }</div>
+<div class="line"><a name="l12360"></a><span class="lineno">12360</span>&#160;    <span class="keywordflow">return</span> result;</div>
+<div class="line"><a name="l12361"></a><span class="lineno">12361</span>&#160;}</div>
+<div class="line"><a name="l12362"></a><span class="lineno">12362</span>&#160; </div>
+<div class="line"><a name="l12363"></a><span class="lineno">12363</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::Remove(VmaDeviceMemoryBlock* pBlock)</div>
+<div class="line"><a name="l12364"></a><span class="lineno">12364</span>&#160;{</div>
+<div class="line"><a name="l12365"></a><span class="lineno">12365</span>&#160;    <span class="keywordflow">for</span>(uint32_t blockIndex = 0; blockIndex &lt; m_Blocks.size(); ++blockIndex)</div>
+<div class="line"><a name="l12366"></a><span class="lineno">12366</span>&#160;    {</div>
+<div class="line"><a name="l12367"></a><span class="lineno">12367</span>&#160;        <span class="keywordflow">if</span>(m_Blocks[blockIndex] == pBlock)</div>
+<div class="line"><a name="l12368"></a><span class="lineno">12368</span>&#160;        {</div>
+<div class="line"><a name="l12369"></a><span class="lineno">12369</span>&#160;            VmaVectorRemove(m_Blocks, blockIndex);</div>
+<div class="line"><a name="l12370"></a><span class="lineno">12370</span>&#160;            <span class="keywordflow">return</span>;</div>
+<div class="line"><a name="l12371"></a><span class="lineno">12371</span>&#160;        }</div>
+<div class="line"><a name="l12372"></a><span class="lineno">12372</span>&#160;    }</div>
+<div class="line"><a name="l12373"></a><span class="lineno">12373</span>&#160;    VMA_ASSERT(0);</div>
+<div class="line"><a name="l12374"></a><span class="lineno">12374</span>&#160;}</div>
+<div class="line"><a name="l12375"></a><span class="lineno">12375</span>&#160; </div>
+<div class="line"><a name="l12376"></a><span class="lineno">12376</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::IncrementallySortBlocks()</div>
+<div class="line"><a name="l12377"></a><span class="lineno">12377</span>&#160;{</div>
+<div class="line"><a name="l12378"></a><span class="lineno">12378</span>&#160;    <span class="keywordflow">if</span>(m_Algorithm != <a class="code" href="vk__mem__alloc_8h.html#a9a7c45f9c863695d98c83fa5ac940fe7a13c8a444197c67866be9cb05599fc726">VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT</a>)</div>
+<div class="line"><a name="l12379"></a><span class="lineno">12379</span>&#160;    {</div>
+<div class="line"><a name="l12380"></a><span class="lineno">12380</span>&#160;        <span class="comment">// Bubble sort only until first swap.</span></div>
+<div class="line"><a name="l12381"></a><span class="lineno">12381</span>&#160;        <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 1; i &lt; m_Blocks.size(); ++i)</div>
+<div class="line"><a name="l12382"></a><span class="lineno">12382</span>&#160;        {</div>
+<div class="line"><a name="l12383"></a><span class="lineno">12383</span>&#160;            <span class="keywordflow">if</span>(m_Blocks[i - 1]-&gt;m_pMetadata-&gt;GetSumFreeSize() &gt; m_Blocks[i]-&gt;m_pMetadata-&gt;GetSumFreeSize())</div>
+<div class="line"><a name="l12384"></a><span class="lineno">12384</span>&#160;            {</div>
+<div class="line"><a name="l12385"></a><span class="lineno">12385</span>&#160;                VMA_SWAP(m_Blocks[i - 1], m_Blocks[i]);</div>
+<div class="line"><a name="l12386"></a><span class="lineno">12386</span>&#160;                <span class="keywordflow">return</span>;</div>
+<div class="line"><a name="l12387"></a><span class="lineno">12387</span>&#160;            }</div>
+<div class="line"><a name="l12388"></a><span class="lineno">12388</span>&#160;        }</div>
+<div class="line"><a name="l12389"></a><span class="lineno">12389</span>&#160;    }</div>
+<div class="line"><a name="l12390"></a><span class="lineno">12390</span>&#160;}</div>
+<div class="line"><a name="l12391"></a><span class="lineno">12391</span>&#160; </div>
+<div class="line"><a name="l12392"></a><span class="lineno">12392</span>&#160;VkResult VmaBlockVector::AllocateFromBlock(</div>
+<div class="line"><a name="l12393"></a><span class="lineno">12393</span>&#160;    VmaDeviceMemoryBlock* pBlock,</div>
+<div class="line"><a name="l12394"></a><span class="lineno">12394</span>&#160;    uint32_t currentFrameIndex,</div>
+<div class="line"><a name="l12395"></a><span class="lineno">12395</span>&#160;    VkDeviceSize size,</div>
+<div class="line"><a name="l12396"></a><span class="lineno">12396</span>&#160;    VkDeviceSize alignment,</div>
+<div class="line"><a name="l12397"></a><span class="lineno">12397</span>&#160;    <a class="code" href="vk__mem__alloc_8h.html#a5225e5e11f8376f6a31a1791f3d6e817">VmaAllocationCreateFlags</a> allocFlags,</div>
+<div class="line"><a name="l12398"></a><span class="lineno">12398</span>&#160;    <span class="keywordtype">void</span>* pUserData,</div>
+<div class="line"><a name="l12399"></a><span class="lineno">12399</span>&#160;    VmaSuballocationType suballocType,</div>
+<div class="line"><a name="l12400"></a><span class="lineno">12400</span>&#160;    uint32_t strategy,</div>
+<div class="line"><a name="l12401"></a><span class="lineno">12401</span>&#160;    <a class="code" href="struct_vma_allocation.html">VmaAllocation</a>* pAllocation)</div>
+<div class="line"><a name="l12402"></a><span class="lineno">12402</span>&#160;{</div>
+<div class="line"><a name="l12403"></a><span class="lineno">12403</span>&#160;    VMA_ASSERT((allocFlags &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a68686d0ce9beb0d4d1b9f2b8b1389a7e">VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT</a>) == 0);</div>
+<div class="line"><a name="l12404"></a><span class="lineno">12404</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> isUpperAddress = (allocFlags &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a42ba3a2d2c7117953210b7c3ef8da0df">VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT</a>) != 0;</div>
+<div class="line"><a name="l12405"></a><span class="lineno">12405</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> mapped = (allocFlags &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a11da372cc3a82931c5e5d6146cd9dd1f">VMA_ALLOCATION_CREATE_MAPPED_BIT</a>) != 0;</div>
+<div class="line"><a name="l12406"></a><span class="lineno">12406</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> isUserDataString = (allocFlags &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597aa6f24f821cd6a7c5e4a443f7bf59c520">VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT</a>) != 0;</div>
+<div class="line"><a name="l12407"></a><span class="lineno">12407</span>&#160; </div>
+<div class="line"><a name="l12408"></a><span class="lineno">12408</span>&#160;    VmaAllocationRequest currRequest = {};</div>
+<div class="line"><a name="l12409"></a><span class="lineno">12409</span>&#160;    <span class="keywordflow">if</span>(pBlock-&gt;m_pMetadata-&gt;CreateAllocationRequest(</div>
+<div class="line"><a name="l12410"></a><span class="lineno">12410</span>&#160;        currentFrameIndex,</div>
+<div class="line"><a name="l12411"></a><span class="lineno">12411</span>&#160;        m_FrameInUseCount,</div>
+<div class="line"><a name="l12412"></a><span class="lineno">12412</span>&#160;        m_BufferImageGranularity,</div>
+<div class="line"><a name="l12413"></a><span class="lineno">12413</span>&#160;        size,</div>
+<div class="line"><a name="l12414"></a><span class="lineno">12414</span>&#160;        alignment,</div>
+<div class="line"><a name="l12415"></a><span class="lineno">12415</span>&#160;        isUpperAddress,</div>
+<div class="line"><a name="l12416"></a><span class="lineno">12416</span>&#160;        suballocType,</div>
+<div class="line"><a name="l12417"></a><span class="lineno">12417</span>&#160;        <span class="keyword">false</span>, <span class="comment">// canMakeOtherLost</span></div>
+<div class="line"><a name="l12418"></a><span class="lineno">12418</span>&#160;        strategy,</div>
+<div class="line"><a name="l12419"></a><span class="lineno">12419</span>&#160;        &amp;currRequest))</div>
+<div class="line"><a name="l12420"></a><span class="lineno">12420</span>&#160;    {</div>
+<div class="line"><a name="l12421"></a><span class="lineno">12421</span>&#160;        <span class="comment">// Allocate from pCurrBlock.</span></div>
+<div class="line"><a name="l12422"></a><span class="lineno">12422</span>&#160;        VMA_ASSERT(currRequest.itemsToMakeLostCount == 0);</div>
+<div class="line"><a name="l12423"></a><span class="lineno">12423</span>&#160; </div>
+<div class="line"><a name="l12424"></a><span class="lineno">12424</span>&#160;        <span class="keywordflow">if</span>(mapped)</div>
+<div class="line"><a name="l12425"></a><span class="lineno">12425</span>&#160;        {</div>
+<div class="line"><a name="l12426"></a><span class="lineno">12426</span>&#160;            VkResult res = pBlock-&gt;Map(m_hAllocator, 1, VMA_NULL);</div>
+<div class="line"><a name="l12427"></a><span class="lineno">12427</span>&#160;            <span class="keywordflow">if</span>(res != VK_SUCCESS)</div>
+<div class="line"><a name="l12428"></a><span class="lineno">12428</span>&#160;            {</div>
+<div class="line"><a name="l12429"></a><span class="lineno">12429</span>&#160;                <span class="keywordflow">return</span> res;</div>
+<div class="line"><a name="l12430"></a><span class="lineno">12430</span>&#160;            }</div>
+<div class="line"><a name="l12431"></a><span class="lineno">12431</span>&#160;        }</div>
+<div class="line"><a name="l12432"></a><span class="lineno">12432</span>&#160;            </div>
+<div class="line"><a name="l12433"></a><span class="lineno">12433</span>&#160;        *pAllocation = m_hAllocator-&gt;m_AllocationObjectAllocator.Allocate();</div>
+<div class="line"><a name="l12434"></a><span class="lineno">12434</span>&#160;        (*pAllocation)-&gt;Ctor(currentFrameIndex, isUserDataString);</div>
+<div class="line"><a name="l12435"></a><span class="lineno">12435</span>&#160;        pBlock-&gt;m_pMetadata-&gt;Alloc(currRequest, suballocType, size, *pAllocation);</div>
+<div class="line"><a name="l12436"></a><span class="lineno">12436</span>&#160;        UpdateHasEmptyBlock();</div>
+<div class="line"><a name="l12437"></a><span class="lineno">12437</span>&#160;        (*pAllocation)-&gt;InitBlockAllocation(</div>
+<div class="line"><a name="l12438"></a><span class="lineno">12438</span>&#160;            pBlock,</div>
+<div class="line"><a name="l12439"></a><span class="lineno">12439</span>&#160;            currRequest.offset,</div>
+<div class="line"><a name="l12440"></a><span class="lineno">12440</span>&#160;            alignment,</div>
+<div class="line"><a name="l12441"></a><span class="lineno">12441</span>&#160;            size,</div>
+<div class="line"><a name="l12442"></a><span class="lineno">12442</span>&#160;            m_MemoryTypeIndex,</div>
+<div class="line"><a name="l12443"></a><span class="lineno">12443</span>&#160;            suballocType,</div>
+<div class="line"><a name="l12444"></a><span class="lineno">12444</span>&#160;            mapped,</div>
+<div class="line"><a name="l12445"></a><span class="lineno">12445</span>&#160;            (allocFlags &amp; <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a5f436af6c8fe8540573a6d22627a6fd2">VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT</a>) != 0);</div>
+<div class="line"><a name="l12446"></a><span class="lineno">12446</span>&#160;        VMA_HEAVY_ASSERT(pBlock-&gt;Validate());</div>
+<div class="line"><a name="l12447"></a><span class="lineno">12447</span>&#160;        (*pAllocation)-&gt;SetUserData(m_hAllocator, pUserData);</div>
+<div class="line"><a name="l12448"></a><span class="lineno">12448</span>&#160;        m_hAllocator-&gt;m_Budget.AddAllocation(m_hAllocator-&gt;MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), size);</div>
+<div class="line"><a name="l12449"></a><span class="lineno">12449</span>&#160;        <span class="keywordflow">if</span>(VMA_DEBUG_INITIALIZE_ALLOCATIONS)</div>
+<div class="line"><a name="l12450"></a><span class="lineno">12450</span>&#160;        {</div>
+<div class="line"><a name="l12451"></a><span class="lineno">12451</span>&#160;            m_hAllocator-&gt;FillAllocation(*pAllocation, VMA_ALLOCATION_FILL_PATTERN_CREATED);</div>
+<div class="line"><a name="l12452"></a><span class="lineno">12452</span>&#160;        }</div>
+<div class="line"><a name="l12453"></a><span class="lineno">12453</span>&#160;        <span class="keywordflow">if</span>(IsCorruptionDetectionEnabled())</div>
+<div class="line"><a name="l12454"></a><span class="lineno">12454</span>&#160;        {</div>
+<div class="line"><a name="l12455"></a><span class="lineno">12455</span>&#160;            VkResult res = pBlock-&gt;WriteMagicValueAroundAllocation(m_hAllocator, currRequest.offset, size);</div>
+<div class="line"><a name="l12456"></a><span class="lineno">12456</span>&#160;            VMA_ASSERT(res == VK_SUCCESS &amp;&amp; <span class="stringliteral">&quot;Couldn&#39;t map block memory to write magic value.&quot;</span>);</div>
+<div class="line"><a name="l12457"></a><span class="lineno">12457</span>&#160;        }</div>
+<div class="line"><a name="l12458"></a><span class="lineno">12458</span>&#160;        <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l12459"></a><span class="lineno">12459</span>&#160;    }</div>
+<div class="line"><a name="l12460"></a><span class="lineno">12460</span>&#160;    <span class="keywordflow">return</span> VK_ERROR_OUT_OF_DEVICE_MEMORY;</div>
+<div class="line"><a name="l12461"></a><span class="lineno">12461</span>&#160;}</div>
+<div class="line"><a name="l12462"></a><span class="lineno">12462</span>&#160; </div>
+<div class="line"><a name="l12463"></a><span class="lineno">12463</span>&#160;VkResult VmaBlockVector::CreateBlock(VkDeviceSize blockSize, <span class="keywordtype">size_t</span>* pNewBlockIndex)</div>
+<div class="line"><a name="l12464"></a><span class="lineno">12464</span>&#160;{</div>
+<div class="line"><a name="l12465"></a><span class="lineno">12465</span>&#160;    VkMemoryAllocateInfo allocInfo = { VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO };</div>
+<div class="line"><a name="l12466"></a><span class="lineno">12466</span>&#160;    allocInfo.memoryTypeIndex = m_MemoryTypeIndex;</div>
+<div class="line"><a name="l12467"></a><span class="lineno">12467</span>&#160;    allocInfo.allocationSize = blockSize;</div>
+<div class="line"><a name="l12468"></a><span class="lineno">12468</span>&#160;    VkDeviceMemory mem = VK_NULL_HANDLE;</div>
+<div class="line"><a name="l12469"></a><span class="lineno">12469</span>&#160;    VkResult res = m_hAllocator-&gt;AllocateVulkanMemory(&amp;allocInfo, &amp;mem);</div>
+<div class="line"><a name="l12470"></a><span class="lineno">12470</span>&#160;    <span class="keywordflow">if</span>(res &lt; 0)</div>
+<div class="line"><a name="l12471"></a><span class="lineno">12471</span>&#160;    {</div>
+<div class="line"><a name="l12472"></a><span class="lineno">12472</span>&#160;        <span class="keywordflow">return</span> res;</div>
+<div class="line"><a name="l12473"></a><span class="lineno">12473</span>&#160;    }</div>
+<div class="line"><a name="l12474"></a><span class="lineno">12474</span>&#160; </div>
+<div class="line"><a name="l12475"></a><span class="lineno">12475</span>&#160;    <span class="comment">// New VkDeviceMemory successfully created.</span></div>
+<div class="line"><a name="l12476"></a><span class="lineno">12476</span>&#160; </div>
+<div class="line"><a name="l12477"></a><span class="lineno">12477</span>&#160;    <span class="comment">// Create new Allocation for it.</span></div>
+<div class="line"><a name="l12478"></a><span class="lineno">12478</span>&#160;    VmaDeviceMemoryBlock* <span class="keyword">const</span> pBlock = vma_new(m_hAllocator, VmaDeviceMemoryBlock)(m_hAllocator);</div>
+<div class="line"><a name="l12479"></a><span class="lineno">12479</span>&#160;    pBlock-&gt;Init(</div>
+<div class="line"><a name="l12480"></a><span class="lineno">12480</span>&#160;        m_hAllocator,</div>
+<div class="line"><a name="l12481"></a><span class="lineno">12481</span>&#160;        m_hParentPool,</div>
+<div class="line"><a name="l12482"></a><span class="lineno">12482</span>&#160;        m_MemoryTypeIndex,</div>
+<div class="line"><a name="l12483"></a><span class="lineno">12483</span>&#160;        mem,</div>
+<div class="line"><a name="l12484"></a><span class="lineno">12484</span>&#160;        allocInfo.allocationSize,</div>
+<div class="line"><a name="l12485"></a><span class="lineno">12485</span>&#160;        m_NextBlockId++,</div>
+<div class="line"><a name="l12486"></a><span class="lineno">12486</span>&#160;        m_Algorithm);</div>
 <div class="line"><a name="l12487"></a><span class="lineno">12487</span>&#160; </div>
-<div class="line"><a name="l12488"></a><span class="lineno">12488</span>&#160;    <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l12489"></a><span class="lineno">12489</span>&#160;}</div>
-<div class="line"><a name="l12490"></a><span class="lineno">12490</span>&#160; </div>
-<div class="line"><a name="l12491"></a><span class="lineno">12491</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::ApplyDefragmentationMovesCpu(</div>
-<div class="line"><a name="l12492"></a><span class="lineno">12492</span>&#160;    <span class="keyword">class</span> VmaBlockVectorDefragmentationContext* pDefragCtx,</div>
-<div class="line"><a name="l12493"></a><span class="lineno">12493</span>&#160;    <span class="keyword">const</span> VmaVector&lt; VmaDefragmentationMove, VmaStlAllocator&lt;VmaDefragmentationMove&gt; &gt;&amp; moves)</div>
-<div class="line"><a name="l12494"></a><span class="lineno">12494</span>&#160;{</div>
-<div class="line"><a name="l12495"></a><span class="lineno">12495</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> blockCount = m_Blocks.size();</div>
-<div class="line"><a name="l12496"></a><span class="lineno">12496</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> isNonCoherent = m_hAllocator-&gt;IsMemoryTypeNonCoherent(m_MemoryTypeIndex);</div>
-<div class="line"><a name="l12497"></a><span class="lineno">12497</span>&#160; </div>
-<div class="line"><a name="l12498"></a><span class="lineno">12498</span>&#160;    <span class="keyword">enum</span> BLOCK_FLAG</div>
-<div class="line"><a name="l12499"></a><span class="lineno">12499</span>&#160;    {</div>
-<div class="line"><a name="l12500"></a><span class="lineno">12500</span>&#160;        BLOCK_FLAG_USED = 0x00000001,</div>
-<div class="line"><a name="l12501"></a><span class="lineno">12501</span>&#160;        BLOCK_FLAG_MAPPED_FOR_DEFRAGMENTATION = 0x00000002,</div>
-<div class="line"><a name="l12502"></a><span class="lineno">12502</span>&#160;    };</div>
+<div class="line"><a name="l12488"></a><span class="lineno">12488</span>&#160;    m_Blocks.push_back(pBlock);</div>
+<div class="line"><a name="l12489"></a><span class="lineno">12489</span>&#160;    <span class="keywordflow">if</span>(pNewBlockIndex != VMA_NULL)</div>
+<div class="line"><a name="l12490"></a><span class="lineno">12490</span>&#160;    {</div>
+<div class="line"><a name="l12491"></a><span class="lineno">12491</span>&#160;        *pNewBlockIndex = m_Blocks.size() - 1;</div>
+<div class="line"><a name="l12492"></a><span class="lineno">12492</span>&#160;    }</div>
+<div class="line"><a name="l12493"></a><span class="lineno">12493</span>&#160; </div>
+<div class="line"><a name="l12494"></a><span class="lineno">12494</span>&#160;    <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l12495"></a><span class="lineno">12495</span>&#160;}</div>
+<div class="line"><a name="l12496"></a><span class="lineno">12496</span>&#160; </div>
+<div class="line"><a name="l12497"></a><span class="lineno">12497</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::ApplyDefragmentationMovesCpu(</div>
+<div class="line"><a name="l12498"></a><span class="lineno">12498</span>&#160;    <span class="keyword">class</span> VmaBlockVectorDefragmentationContext* pDefragCtx,</div>
+<div class="line"><a name="l12499"></a><span class="lineno">12499</span>&#160;    <span class="keyword">const</span> VmaVector&lt; VmaDefragmentationMove, VmaStlAllocator&lt;VmaDefragmentationMove&gt; &gt;&amp; moves)</div>
+<div class="line"><a name="l12500"></a><span class="lineno">12500</span>&#160;{</div>
+<div class="line"><a name="l12501"></a><span class="lineno">12501</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> blockCount = m_Blocks.size();</div>
+<div class="line"><a name="l12502"></a><span class="lineno">12502</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> isNonCoherent = m_hAllocator-&gt;IsMemoryTypeNonCoherent(m_MemoryTypeIndex);</div>
 <div class="line"><a name="l12503"></a><span class="lineno">12503</span>&#160; </div>
-<div class="line"><a name="l12504"></a><span class="lineno">12504</span>&#160;    <span class="keyword">struct </span>BlockInfo</div>
+<div class="line"><a name="l12504"></a><span class="lineno">12504</span>&#160;    <span class="keyword">enum</span> BLOCK_FLAG</div>
 <div class="line"><a name="l12505"></a><span class="lineno">12505</span>&#160;    {</div>
-<div class="line"><a name="l12506"></a><span class="lineno">12506</span>&#160;        uint32_t flags;</div>
-<div class="line"><a name="l12507"></a><span class="lineno">12507</span>&#160;        <span class="keywordtype">void</span>* pMappedData;</div>
+<div class="line"><a name="l12506"></a><span class="lineno">12506</span>&#160;        BLOCK_FLAG_USED = 0x00000001,</div>
+<div class="line"><a name="l12507"></a><span class="lineno">12507</span>&#160;        BLOCK_FLAG_MAPPED_FOR_DEFRAGMENTATION = 0x00000002,</div>
 <div class="line"><a name="l12508"></a><span class="lineno">12508</span>&#160;    };</div>
-<div class="line"><a name="l12509"></a><span class="lineno">12509</span>&#160;    VmaVector&lt; BlockInfo, VmaStlAllocator&lt;BlockInfo&gt; &gt;</div>
-<div class="line"><a name="l12510"></a><span class="lineno">12510</span>&#160;        blockInfo(blockCount, BlockInfo(), VmaStlAllocator&lt;BlockInfo&gt;(m_hAllocator-&gt;GetAllocationCallbacks()));</div>
-<div class="line"><a name="l12511"></a><span class="lineno">12511</span>&#160;    memset(blockInfo.data(), 0, blockCount * <span class="keyword">sizeof</span>(BlockInfo));</div>
-<div class="line"><a name="l12512"></a><span class="lineno">12512</span>&#160; </div>
-<div class="line"><a name="l12513"></a><span class="lineno">12513</span>&#160;    <span class="comment">// Go over all moves. Mark blocks that are used with BLOCK_FLAG_USED.</span></div>
-<div class="line"><a name="l12514"></a><span class="lineno">12514</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> moveCount = moves.size();</div>
-<div class="line"><a name="l12515"></a><span class="lineno">12515</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> moveIndex = 0; moveIndex &lt; moveCount; ++moveIndex)</div>
-<div class="line"><a name="l12516"></a><span class="lineno">12516</span>&#160;    {</div>
-<div class="line"><a name="l12517"></a><span class="lineno">12517</span>&#160;        <span class="keyword">const</span> VmaDefragmentationMove&amp; move = moves[moveIndex];</div>
-<div class="line"><a name="l12518"></a><span class="lineno">12518</span>&#160;        blockInfo[move.srcBlockIndex].flags |= BLOCK_FLAG_USED;</div>
-<div class="line"><a name="l12519"></a><span class="lineno">12519</span>&#160;        blockInfo[move.dstBlockIndex].flags |= BLOCK_FLAG_USED;</div>
-<div class="line"><a name="l12520"></a><span class="lineno">12520</span>&#160;    }</div>
-<div class="line"><a name="l12521"></a><span class="lineno">12521</span>&#160; </div>
-<div class="line"><a name="l12522"></a><span class="lineno">12522</span>&#160;    VMA_ASSERT(pDefragCtx-&gt;res == VK_SUCCESS);</div>
-<div class="line"><a name="l12523"></a><span class="lineno">12523</span>&#160; </div>
-<div class="line"><a name="l12524"></a><span class="lineno">12524</span>&#160;    <span class="comment">// Go over all blocks. Get mapped pointer or map if necessary.</span></div>
-<div class="line"><a name="l12525"></a><span class="lineno">12525</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; pDefragCtx-&gt;res == VK_SUCCESS &amp;&amp; blockIndex &lt; blockCount; ++blockIndex)</div>
-<div class="line"><a name="l12526"></a><span class="lineno">12526</span>&#160;    {</div>
-<div class="line"><a name="l12527"></a><span class="lineno">12527</span>&#160;        BlockInfo&amp; currBlockInfo = blockInfo[blockIndex];</div>
-<div class="line"><a name="l12528"></a><span class="lineno">12528</span>&#160;        VmaDeviceMemoryBlock* pBlock = m_Blocks[blockIndex];</div>
-<div class="line"><a name="l12529"></a><span class="lineno">12529</span>&#160;        <span class="keywordflow">if</span>((currBlockInfo.flags &amp; BLOCK_FLAG_USED) != 0)</div>
-<div class="line"><a name="l12530"></a><span class="lineno">12530</span>&#160;        {</div>
-<div class="line"><a name="l12531"></a><span class="lineno">12531</span>&#160;            currBlockInfo.pMappedData = pBlock-&gt;GetMappedData();</div>
-<div class="line"><a name="l12532"></a><span class="lineno">12532</span>&#160;            <span class="comment">// It is not originally mapped - map it.</span></div>
-<div class="line"><a name="l12533"></a><span class="lineno">12533</span>&#160;            <span class="keywordflow">if</span>(currBlockInfo.pMappedData == VMA_NULL)</div>
-<div class="line"><a name="l12534"></a><span class="lineno">12534</span>&#160;            {</div>
-<div class="line"><a name="l12535"></a><span class="lineno">12535</span>&#160;                pDefragCtx-&gt;res = pBlock-&gt;Map(m_hAllocator, 1, &amp;currBlockInfo.pMappedData);</div>
-<div class="line"><a name="l12536"></a><span class="lineno">12536</span>&#160;                <span class="keywordflow">if</span>(pDefragCtx-&gt;res == VK_SUCCESS)</div>
-<div class="line"><a name="l12537"></a><span class="lineno">12537</span>&#160;                {</div>
-<div class="line"><a name="l12538"></a><span class="lineno">12538</span>&#160;                    currBlockInfo.flags |= BLOCK_FLAG_MAPPED_FOR_DEFRAGMENTATION;</div>
-<div class="line"><a name="l12539"></a><span class="lineno">12539</span>&#160;                }</div>
-<div class="line"><a name="l12540"></a><span class="lineno">12540</span>&#160;            }</div>
-<div class="line"><a name="l12541"></a><span class="lineno">12541</span>&#160;        }</div>
-<div class="line"><a name="l12542"></a><span class="lineno">12542</span>&#160;    }</div>
-<div class="line"><a name="l12543"></a><span class="lineno">12543</span>&#160; </div>
-<div class="line"><a name="l12544"></a><span class="lineno">12544</span>&#160;    <span class="comment">// Go over all moves. Do actual data transfer.</span></div>
-<div class="line"><a name="l12545"></a><span class="lineno">12545</span>&#160;    <span class="keywordflow">if</span>(pDefragCtx-&gt;res == VK_SUCCESS)</div>
-<div class="line"><a name="l12546"></a><span class="lineno">12546</span>&#160;    {</div>
-<div class="line"><a name="l12547"></a><span class="lineno">12547</span>&#160;        <span class="keyword">const</span> VkDeviceSize nonCoherentAtomSize = m_hAllocator-&gt;m_PhysicalDeviceProperties.limits.nonCoherentAtomSize;</div>
-<div class="line"><a name="l12548"></a><span class="lineno">12548</span>&#160;        VkMappedMemoryRange memRange = { VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE };</div>
+<div class="line"><a name="l12509"></a><span class="lineno">12509</span>&#160; </div>
+<div class="line"><a name="l12510"></a><span class="lineno">12510</span>&#160;    <span class="keyword">struct </span>BlockInfo</div>
+<div class="line"><a name="l12511"></a><span class="lineno">12511</span>&#160;    {</div>
+<div class="line"><a name="l12512"></a><span class="lineno">12512</span>&#160;        uint32_t flags;</div>
+<div class="line"><a name="l12513"></a><span class="lineno">12513</span>&#160;        <span class="keywordtype">void</span>* pMappedData;</div>
+<div class="line"><a name="l12514"></a><span class="lineno">12514</span>&#160;    };</div>
+<div class="line"><a name="l12515"></a><span class="lineno">12515</span>&#160;    VmaVector&lt; BlockInfo, VmaStlAllocator&lt;BlockInfo&gt; &gt;</div>
+<div class="line"><a name="l12516"></a><span class="lineno">12516</span>&#160;        blockInfo(blockCount, BlockInfo(), VmaStlAllocator&lt;BlockInfo&gt;(m_hAllocator-&gt;GetAllocationCallbacks()));</div>
+<div class="line"><a name="l12517"></a><span class="lineno">12517</span>&#160;    memset(blockInfo.data(), 0, blockCount * <span class="keyword">sizeof</span>(BlockInfo));</div>
+<div class="line"><a name="l12518"></a><span class="lineno">12518</span>&#160; </div>
+<div class="line"><a name="l12519"></a><span class="lineno">12519</span>&#160;    <span class="comment">// Go over all moves. Mark blocks that are used with BLOCK_FLAG_USED.</span></div>
+<div class="line"><a name="l12520"></a><span class="lineno">12520</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> moveCount = moves.size();</div>
+<div class="line"><a name="l12521"></a><span class="lineno">12521</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> moveIndex = 0; moveIndex &lt; moveCount; ++moveIndex)</div>
+<div class="line"><a name="l12522"></a><span class="lineno">12522</span>&#160;    {</div>
+<div class="line"><a name="l12523"></a><span class="lineno">12523</span>&#160;        <span class="keyword">const</span> VmaDefragmentationMove&amp; move = moves[moveIndex];</div>
+<div class="line"><a name="l12524"></a><span class="lineno">12524</span>&#160;        blockInfo[move.srcBlockIndex].flags |= BLOCK_FLAG_USED;</div>
+<div class="line"><a name="l12525"></a><span class="lineno">12525</span>&#160;        blockInfo[move.dstBlockIndex].flags |= BLOCK_FLAG_USED;</div>
+<div class="line"><a name="l12526"></a><span class="lineno">12526</span>&#160;    }</div>
+<div class="line"><a name="l12527"></a><span class="lineno">12527</span>&#160; </div>
+<div class="line"><a name="l12528"></a><span class="lineno">12528</span>&#160;    VMA_ASSERT(pDefragCtx-&gt;res == VK_SUCCESS);</div>
+<div class="line"><a name="l12529"></a><span class="lineno">12529</span>&#160; </div>
+<div class="line"><a name="l12530"></a><span class="lineno">12530</span>&#160;    <span class="comment">// Go over all blocks. Get mapped pointer or map if necessary.</span></div>
+<div class="line"><a name="l12531"></a><span class="lineno">12531</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; pDefragCtx-&gt;res == VK_SUCCESS &amp;&amp; blockIndex &lt; blockCount; ++blockIndex)</div>
+<div class="line"><a name="l12532"></a><span class="lineno">12532</span>&#160;    {</div>
+<div class="line"><a name="l12533"></a><span class="lineno">12533</span>&#160;        BlockInfo&amp; currBlockInfo = blockInfo[blockIndex];</div>
+<div class="line"><a name="l12534"></a><span class="lineno">12534</span>&#160;        VmaDeviceMemoryBlock* pBlock = m_Blocks[blockIndex];</div>
+<div class="line"><a name="l12535"></a><span class="lineno">12535</span>&#160;        <span class="keywordflow">if</span>((currBlockInfo.flags &amp; BLOCK_FLAG_USED) != 0)</div>
+<div class="line"><a name="l12536"></a><span class="lineno">12536</span>&#160;        {</div>
+<div class="line"><a name="l12537"></a><span class="lineno">12537</span>&#160;            currBlockInfo.pMappedData = pBlock-&gt;GetMappedData();</div>
+<div class="line"><a name="l12538"></a><span class="lineno">12538</span>&#160;            <span class="comment">// It is not originally mapped - map it.</span></div>
+<div class="line"><a name="l12539"></a><span class="lineno">12539</span>&#160;            <span class="keywordflow">if</span>(currBlockInfo.pMappedData == VMA_NULL)</div>
+<div class="line"><a name="l12540"></a><span class="lineno">12540</span>&#160;            {</div>
+<div class="line"><a name="l12541"></a><span class="lineno">12541</span>&#160;                pDefragCtx-&gt;res = pBlock-&gt;Map(m_hAllocator, 1, &amp;currBlockInfo.pMappedData);</div>
+<div class="line"><a name="l12542"></a><span class="lineno">12542</span>&#160;                <span class="keywordflow">if</span>(pDefragCtx-&gt;res == VK_SUCCESS)</div>
+<div class="line"><a name="l12543"></a><span class="lineno">12543</span>&#160;                {</div>
+<div class="line"><a name="l12544"></a><span class="lineno">12544</span>&#160;                    currBlockInfo.flags |= BLOCK_FLAG_MAPPED_FOR_DEFRAGMENTATION;</div>
+<div class="line"><a name="l12545"></a><span class="lineno">12545</span>&#160;                }</div>
+<div class="line"><a name="l12546"></a><span class="lineno">12546</span>&#160;            }</div>
+<div class="line"><a name="l12547"></a><span class="lineno">12547</span>&#160;        }</div>
+<div class="line"><a name="l12548"></a><span class="lineno">12548</span>&#160;    }</div>
 <div class="line"><a name="l12549"></a><span class="lineno">12549</span>&#160; </div>
-<div class="line"><a name="l12550"></a><span class="lineno">12550</span>&#160;        <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> moveIndex = 0; moveIndex &lt; moveCount; ++moveIndex)</div>
-<div class="line"><a name="l12551"></a><span class="lineno">12551</span>&#160;        {</div>
-<div class="line"><a name="l12552"></a><span class="lineno">12552</span>&#160;            <span class="keyword">const</span> VmaDefragmentationMove&amp; move = moves[moveIndex];</div>
-<div class="line"><a name="l12553"></a><span class="lineno">12553</span>&#160; </div>
-<div class="line"><a name="l12554"></a><span class="lineno">12554</span>&#160;            <span class="keyword">const</span> BlockInfo&amp; srcBlockInfo = blockInfo[move.srcBlockIndex];</div>
-<div class="line"><a name="l12555"></a><span class="lineno">12555</span>&#160;            <span class="keyword">const</span> BlockInfo&amp; dstBlockInfo = blockInfo[move.dstBlockIndex];</div>
-<div class="line"><a name="l12556"></a><span class="lineno">12556</span>&#160; </div>
-<div class="line"><a name="l12557"></a><span class="lineno">12557</span>&#160;            VMA_ASSERT(srcBlockInfo.pMappedData &amp;&amp; dstBlockInfo.pMappedData);</div>
-<div class="line"><a name="l12558"></a><span class="lineno">12558</span>&#160; </div>
-<div class="line"><a name="l12559"></a><span class="lineno">12559</span>&#160;            <span class="comment">// Invalidate source.</span></div>
-<div class="line"><a name="l12560"></a><span class="lineno">12560</span>&#160;            <span class="keywordflow">if</span>(isNonCoherent)</div>
-<div class="line"><a name="l12561"></a><span class="lineno">12561</span>&#160;            {</div>
-<div class="line"><a name="l12562"></a><span class="lineno">12562</span>&#160;                VmaDeviceMemoryBlock* <span class="keyword">const</span> pSrcBlock = m_Blocks[move.srcBlockIndex];</div>
-<div class="line"><a name="l12563"></a><span class="lineno">12563</span>&#160;                memRange.memory = pSrcBlock-&gt;GetDeviceMemory();</div>
-<div class="line"><a name="l12564"></a><span class="lineno">12564</span>&#160;                memRange.offset = VmaAlignDown(move.srcOffset, nonCoherentAtomSize);</div>
-<div class="line"><a name="l12565"></a><span class="lineno">12565</span>&#160;                memRange.size = VMA_MIN(</div>
-<div class="line"><a name="l12566"></a><span class="lineno">12566</span>&#160;                    VmaAlignUp(move.size + (move.srcOffset - memRange.offset), nonCoherentAtomSize),</div>
-<div class="line"><a name="l12567"></a><span class="lineno">12567</span>&#160;                    pSrcBlock-&gt;m_pMetadata-&gt;GetSize() - memRange.offset);</div>
-<div class="line"><a name="l12568"></a><span class="lineno">12568</span>&#160;                (*m_hAllocator-&gt;GetVulkanFunctions().vkInvalidateMappedMemoryRanges)(m_hAllocator-&gt;m_hDevice, 1, &amp;memRange);</div>
-<div class="line"><a name="l12569"></a><span class="lineno">12569</span>&#160;            }</div>
-<div class="line"><a name="l12570"></a><span class="lineno">12570</span>&#160; </div>
-<div class="line"><a name="l12571"></a><span class="lineno">12571</span>&#160;            <span class="comment">// THE PLACE WHERE ACTUAL DATA COPY HAPPENS.</span></div>
-<div class="line"><a name="l12572"></a><span class="lineno">12572</span>&#160;            memmove(</div>
-<div class="line"><a name="l12573"></a><span class="lineno">12573</span>&#160;                reinterpret_cast&lt;char*&gt;(dstBlockInfo.pMappedData) + move.dstOffset,</div>
-<div class="line"><a name="l12574"></a><span class="lineno">12574</span>&#160;                reinterpret_cast&lt;char*&gt;(srcBlockInfo.pMappedData) + move.srcOffset,</div>
-<div class="line"><a name="l12575"></a><span class="lineno">12575</span>&#160;                static_cast&lt;size_t&gt;(move.size));</div>
+<div class="line"><a name="l12550"></a><span class="lineno">12550</span>&#160;    <span class="comment">// Go over all moves. Do actual data transfer.</span></div>
+<div class="line"><a name="l12551"></a><span class="lineno">12551</span>&#160;    <span class="keywordflow">if</span>(pDefragCtx-&gt;res == VK_SUCCESS)</div>
+<div class="line"><a name="l12552"></a><span class="lineno">12552</span>&#160;    {</div>
+<div class="line"><a name="l12553"></a><span class="lineno">12553</span>&#160;        <span class="keyword">const</span> VkDeviceSize nonCoherentAtomSize = m_hAllocator-&gt;m_PhysicalDeviceProperties.limits.nonCoherentAtomSize;</div>
+<div class="line"><a name="l12554"></a><span class="lineno">12554</span>&#160;        VkMappedMemoryRange memRange = { VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE };</div>
+<div class="line"><a name="l12555"></a><span class="lineno">12555</span>&#160; </div>
+<div class="line"><a name="l12556"></a><span class="lineno">12556</span>&#160;        <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> moveIndex = 0; moveIndex &lt; moveCount; ++moveIndex)</div>
+<div class="line"><a name="l12557"></a><span class="lineno">12557</span>&#160;        {</div>
+<div class="line"><a name="l12558"></a><span class="lineno">12558</span>&#160;            <span class="keyword">const</span> VmaDefragmentationMove&amp; move = moves[moveIndex];</div>
+<div class="line"><a name="l12559"></a><span class="lineno">12559</span>&#160; </div>
+<div class="line"><a name="l12560"></a><span class="lineno">12560</span>&#160;            <span class="keyword">const</span> BlockInfo&amp; srcBlockInfo = blockInfo[move.srcBlockIndex];</div>
+<div class="line"><a name="l12561"></a><span class="lineno">12561</span>&#160;            <span class="keyword">const</span> BlockInfo&amp; dstBlockInfo = blockInfo[move.dstBlockIndex];</div>
+<div class="line"><a name="l12562"></a><span class="lineno">12562</span>&#160; </div>
+<div class="line"><a name="l12563"></a><span class="lineno">12563</span>&#160;            VMA_ASSERT(srcBlockInfo.pMappedData &amp;&amp; dstBlockInfo.pMappedData);</div>
+<div class="line"><a name="l12564"></a><span class="lineno">12564</span>&#160; </div>
+<div class="line"><a name="l12565"></a><span class="lineno">12565</span>&#160;            <span class="comment">// Invalidate source.</span></div>
+<div class="line"><a name="l12566"></a><span class="lineno">12566</span>&#160;            <span class="keywordflow">if</span>(isNonCoherent)</div>
+<div class="line"><a name="l12567"></a><span class="lineno">12567</span>&#160;            {</div>
+<div class="line"><a name="l12568"></a><span class="lineno">12568</span>&#160;                VmaDeviceMemoryBlock* <span class="keyword">const</span> pSrcBlock = m_Blocks[move.srcBlockIndex];</div>
+<div class="line"><a name="l12569"></a><span class="lineno">12569</span>&#160;                memRange.memory = pSrcBlock-&gt;GetDeviceMemory();</div>
+<div class="line"><a name="l12570"></a><span class="lineno">12570</span>&#160;                memRange.offset = VmaAlignDown(move.srcOffset, nonCoherentAtomSize);</div>
+<div class="line"><a name="l12571"></a><span class="lineno">12571</span>&#160;                memRange.size = VMA_MIN(</div>
+<div class="line"><a name="l12572"></a><span class="lineno">12572</span>&#160;                    VmaAlignUp(move.size + (move.srcOffset - memRange.offset), nonCoherentAtomSize),</div>
+<div class="line"><a name="l12573"></a><span class="lineno">12573</span>&#160;                    pSrcBlock-&gt;m_pMetadata-&gt;GetSize() - memRange.offset);</div>
+<div class="line"><a name="l12574"></a><span class="lineno">12574</span>&#160;                (*m_hAllocator-&gt;GetVulkanFunctions().vkInvalidateMappedMemoryRanges)(m_hAllocator-&gt;m_hDevice, 1, &amp;memRange);</div>
+<div class="line"><a name="l12575"></a><span class="lineno">12575</span>&#160;            }</div>
 <div class="line"><a name="l12576"></a><span class="lineno">12576</span>&#160; </div>
-<div class="line"><a name="l12577"></a><span class="lineno">12577</span>&#160;            <span class="keywordflow">if</span>(IsCorruptionDetectionEnabled())</div>
-<div class="line"><a name="l12578"></a><span class="lineno">12578</span>&#160;            {</div>
-<div class="line"><a name="l12579"></a><span class="lineno">12579</span>&#160;                VmaWriteMagicValue(dstBlockInfo.pMappedData, move.dstOffset - VMA_DEBUG_MARGIN);</div>
-<div class="line"><a name="l12580"></a><span class="lineno">12580</span>&#160;                VmaWriteMagicValue(dstBlockInfo.pMappedData, move.dstOffset + move.size);</div>
-<div class="line"><a name="l12581"></a><span class="lineno">12581</span>&#160;            }</div>
+<div class="line"><a name="l12577"></a><span class="lineno">12577</span>&#160;            <span class="comment">// THE PLACE WHERE ACTUAL DATA COPY HAPPENS.</span></div>
+<div class="line"><a name="l12578"></a><span class="lineno">12578</span>&#160;            memmove(</div>
+<div class="line"><a name="l12579"></a><span class="lineno">12579</span>&#160;                reinterpret_cast&lt;char*&gt;(dstBlockInfo.pMappedData) + move.dstOffset,</div>
+<div class="line"><a name="l12580"></a><span class="lineno">12580</span>&#160;                reinterpret_cast&lt;char*&gt;(srcBlockInfo.pMappedData) + move.srcOffset,</div>
+<div class="line"><a name="l12581"></a><span class="lineno">12581</span>&#160;                static_cast&lt;size_t&gt;(move.size));</div>
 <div class="line"><a name="l12582"></a><span class="lineno">12582</span>&#160; </div>
-<div class="line"><a name="l12583"></a><span class="lineno">12583</span>&#160;            <span class="comment">// Flush destination.</span></div>
-<div class="line"><a name="l12584"></a><span class="lineno">12584</span>&#160;            <span class="keywordflow">if</span>(isNonCoherent)</div>
-<div class="line"><a name="l12585"></a><span class="lineno">12585</span>&#160;            {</div>
-<div class="line"><a name="l12586"></a><span class="lineno">12586</span>&#160;                VmaDeviceMemoryBlock* <span class="keyword">const</span> pDstBlock = m_Blocks[move.dstBlockIndex];</div>
-<div class="line"><a name="l12587"></a><span class="lineno">12587</span>&#160;                memRange.memory = pDstBlock-&gt;GetDeviceMemory();</div>
-<div class="line"><a name="l12588"></a><span class="lineno">12588</span>&#160;                memRange.offset = VmaAlignDown(move.dstOffset, nonCoherentAtomSize);</div>
-<div class="line"><a name="l12589"></a><span class="lineno">12589</span>&#160;                memRange.size = VMA_MIN(</div>
-<div class="line"><a name="l12590"></a><span class="lineno">12590</span>&#160;                    VmaAlignUp(move.size + (move.dstOffset - memRange.offset), nonCoherentAtomSize),</div>
-<div class="line"><a name="l12591"></a><span class="lineno">12591</span>&#160;                    pDstBlock-&gt;m_pMetadata-&gt;GetSize() - memRange.offset);</div>
-<div class="line"><a name="l12592"></a><span class="lineno">12592</span>&#160;                (*m_hAllocator-&gt;GetVulkanFunctions().vkFlushMappedMemoryRanges)(m_hAllocator-&gt;m_hDevice, 1, &amp;memRange);</div>
-<div class="line"><a name="l12593"></a><span class="lineno">12593</span>&#160;            }</div>
-<div class="line"><a name="l12594"></a><span class="lineno">12594</span>&#160;        }</div>
-<div class="line"><a name="l12595"></a><span class="lineno">12595</span>&#160;    }</div>
-<div class="line"><a name="l12596"></a><span class="lineno">12596</span>&#160; </div>
-<div class="line"><a name="l12597"></a><span class="lineno">12597</span>&#160;    <span class="comment">// Go over all blocks in reverse order. Unmap those that were mapped just for defragmentation.</span></div>
-<div class="line"><a name="l12598"></a><span class="lineno">12598</span>&#160;    <span class="comment">// Regardless of pCtx-&gt;res == VK_SUCCESS.</span></div>
-<div class="line"><a name="l12599"></a><span class="lineno">12599</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = blockCount; blockIndex--; )</div>
-<div class="line"><a name="l12600"></a><span class="lineno">12600</span>&#160;    {</div>
-<div class="line"><a name="l12601"></a><span class="lineno">12601</span>&#160;        <span class="keyword">const</span> BlockInfo&amp; currBlockInfo = blockInfo[blockIndex];</div>
-<div class="line"><a name="l12602"></a><span class="lineno">12602</span>&#160;        <span class="keywordflow">if</span>((currBlockInfo.flags &amp; BLOCK_FLAG_MAPPED_FOR_DEFRAGMENTATION) != 0)</div>
-<div class="line"><a name="l12603"></a><span class="lineno">12603</span>&#160;        {</div>
-<div class="line"><a name="l12604"></a><span class="lineno">12604</span>&#160;            VmaDeviceMemoryBlock* pBlock = m_Blocks[blockIndex];</div>
-<div class="line"><a name="l12605"></a><span class="lineno">12605</span>&#160;            pBlock-&gt;Unmap(m_hAllocator, 1);</div>
-<div class="line"><a name="l12606"></a><span class="lineno">12606</span>&#160;        }</div>
-<div class="line"><a name="l12607"></a><span class="lineno">12607</span>&#160;    }</div>
-<div class="line"><a name="l12608"></a><span class="lineno">12608</span>&#160;}</div>
-<div class="line"><a name="l12609"></a><span class="lineno">12609</span>&#160; </div>
-<div class="line"><a name="l12610"></a><span class="lineno">12610</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::ApplyDefragmentationMovesGpu(</div>
-<div class="line"><a name="l12611"></a><span class="lineno">12611</span>&#160;    <span class="keyword">class</span> VmaBlockVectorDefragmentationContext* pDefragCtx,</div>
-<div class="line"><a name="l12612"></a><span class="lineno">12612</span>&#160;    <span class="keyword">const</span> VmaVector&lt; VmaDefragmentationMove, VmaStlAllocator&lt;VmaDefragmentationMove&gt; &gt;&amp; moves,</div>
-<div class="line"><a name="l12613"></a><span class="lineno">12613</span>&#160;    VkCommandBuffer commandBuffer)</div>
-<div class="line"><a name="l12614"></a><span class="lineno">12614</span>&#160;{</div>
-<div class="line"><a name="l12615"></a><span class="lineno">12615</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> blockCount = m_Blocks.size();</div>
-<div class="line"><a name="l12616"></a><span class="lineno">12616</span>&#160; </div>
-<div class="line"><a name="l12617"></a><span class="lineno">12617</span>&#160;    pDefragCtx-&gt;blockContexts.resize(blockCount);</div>
-<div class="line"><a name="l12618"></a><span class="lineno">12618</span>&#160;    memset(pDefragCtx-&gt;blockContexts.data(), 0, blockCount * <span class="keyword">sizeof</span>(VmaBlockDefragmentationContext));</div>
-<div class="line"><a name="l12619"></a><span class="lineno">12619</span>&#160; </div>
-<div class="line"><a name="l12620"></a><span class="lineno">12620</span>&#160;    <span class="comment">// Go over all moves. Mark blocks that are used with BLOCK_FLAG_USED.</span></div>
-<div class="line"><a name="l12621"></a><span class="lineno">12621</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> moveCount = moves.size();</div>
-<div class="line"><a name="l12622"></a><span class="lineno">12622</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> moveIndex = 0; moveIndex &lt; moveCount; ++moveIndex)</div>
-<div class="line"><a name="l12623"></a><span class="lineno">12623</span>&#160;    {</div>
-<div class="line"><a name="l12624"></a><span class="lineno">12624</span>&#160;        <span class="keyword">const</span> VmaDefragmentationMove&amp; move = moves[moveIndex];</div>
-<div class="line"><a name="l12625"></a><span class="lineno">12625</span>&#160;        pDefragCtx-&gt;blockContexts[move.srcBlockIndex].flags |= VmaBlockDefragmentationContext::BLOCK_FLAG_USED;</div>
-<div class="line"><a name="l12626"></a><span class="lineno">12626</span>&#160;        pDefragCtx-&gt;blockContexts[move.dstBlockIndex].flags |= VmaBlockDefragmentationContext::BLOCK_FLAG_USED;</div>
-<div class="line"><a name="l12627"></a><span class="lineno">12627</span>&#160;    }</div>
-<div class="line"><a name="l12628"></a><span class="lineno">12628</span>&#160; </div>
-<div class="line"><a name="l12629"></a><span class="lineno">12629</span>&#160;    VMA_ASSERT(pDefragCtx-&gt;res == VK_SUCCESS);</div>
-<div class="line"><a name="l12630"></a><span class="lineno">12630</span>&#160; </div>
-<div class="line"><a name="l12631"></a><span class="lineno">12631</span>&#160;    <span class="comment">// Go over all blocks. Create and bind buffer for whole block if necessary.</span></div>
-<div class="line"><a name="l12632"></a><span class="lineno">12632</span>&#160;    {</div>
-<div class="line"><a name="l12633"></a><span class="lineno">12633</span>&#160;        VkBufferCreateInfo bufCreateInfo;</div>
-<div class="line"><a name="l12634"></a><span class="lineno">12634</span>&#160;        VmaFillGpuDefragmentationBufferCreateInfo(bufCreateInfo);</div>
-<div class="line"><a name="l12635"></a><span class="lineno">12635</span>&#160; </div>
-<div class="line"><a name="l12636"></a><span class="lineno">12636</span>&#160;        <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; pDefragCtx-&gt;res == VK_SUCCESS &amp;&amp; blockIndex &lt; blockCount; ++blockIndex)</div>
-<div class="line"><a name="l12637"></a><span class="lineno">12637</span>&#160;        {</div>
-<div class="line"><a name="l12638"></a><span class="lineno">12638</span>&#160;            VmaBlockDefragmentationContext&amp; currBlockCtx = pDefragCtx-&gt;blockContexts[blockIndex];</div>
-<div class="line"><a name="l12639"></a><span class="lineno">12639</span>&#160;            VmaDeviceMemoryBlock* pBlock = m_Blocks[blockIndex];</div>
-<div class="line"><a name="l12640"></a><span class="lineno">12640</span>&#160;            <span class="keywordflow">if</span>((currBlockCtx.flags &amp; VmaBlockDefragmentationContext::BLOCK_FLAG_USED) != 0)</div>
-<div class="line"><a name="l12641"></a><span class="lineno">12641</span>&#160;            {</div>
-<div class="line"><a name="l12642"></a><span class="lineno">12642</span>&#160;                bufCreateInfo.size = pBlock-&gt;m_pMetadata-&gt;GetSize();</div>
-<div class="line"><a name="l12643"></a><span class="lineno">12643</span>&#160;                pDefragCtx-&gt;res = (*m_hAllocator-&gt;GetVulkanFunctions().vkCreateBuffer)(</div>
-<div class="line"><a name="l12644"></a><span class="lineno">12644</span>&#160;                    m_hAllocator-&gt;m_hDevice, &amp;bufCreateInfo, m_hAllocator-&gt;GetAllocationCallbacks(), &amp;currBlockCtx.hBuffer);</div>
-<div class="line"><a name="l12645"></a><span class="lineno">12645</span>&#160;                <span class="keywordflow">if</span>(pDefragCtx-&gt;res == VK_SUCCESS)</div>
-<div class="line"><a name="l12646"></a><span class="lineno">12646</span>&#160;                {</div>
-<div class="line"><a name="l12647"></a><span class="lineno">12647</span>&#160;                    pDefragCtx-&gt;res = (*m_hAllocator-&gt;GetVulkanFunctions().vkBindBufferMemory)(</div>
-<div class="line"><a name="l12648"></a><span class="lineno">12648</span>&#160;                        m_hAllocator-&gt;m_hDevice, currBlockCtx.hBuffer, pBlock-&gt;GetDeviceMemory(), 0);</div>
-<div class="line"><a name="l12649"></a><span class="lineno">12649</span>&#160;                }</div>
-<div class="line"><a name="l12650"></a><span class="lineno">12650</span>&#160;            }</div>
-<div class="line"><a name="l12651"></a><span class="lineno">12651</span>&#160;        }</div>
-<div class="line"><a name="l12652"></a><span class="lineno">12652</span>&#160;    }</div>
-<div class="line"><a name="l12653"></a><span class="lineno">12653</span>&#160; </div>
-<div class="line"><a name="l12654"></a><span class="lineno">12654</span>&#160;    <span class="comment">// Go over all moves. Post data transfer commands to command buffer.</span></div>
-<div class="line"><a name="l12655"></a><span class="lineno">12655</span>&#160;    <span class="keywordflow">if</span>(pDefragCtx-&gt;res == VK_SUCCESS)</div>
-<div class="line"><a name="l12656"></a><span class="lineno">12656</span>&#160;    {</div>
-<div class="line"><a name="l12657"></a><span class="lineno">12657</span>&#160;        <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> moveIndex = 0; moveIndex &lt; moveCount; ++moveIndex)</div>
-<div class="line"><a name="l12658"></a><span class="lineno">12658</span>&#160;        {</div>
-<div class="line"><a name="l12659"></a><span class="lineno">12659</span>&#160;            <span class="keyword">const</span> VmaDefragmentationMove&amp; move = moves[moveIndex];</div>
-<div class="line"><a name="l12660"></a><span class="lineno">12660</span>&#160; </div>
-<div class="line"><a name="l12661"></a><span class="lineno">12661</span>&#160;            <span class="keyword">const</span> VmaBlockDefragmentationContext&amp; srcBlockCtx = pDefragCtx-&gt;blockContexts[move.srcBlockIndex];</div>
-<div class="line"><a name="l12662"></a><span class="lineno">12662</span>&#160;            <span class="keyword">const</span> VmaBlockDefragmentationContext&amp; dstBlockCtx = pDefragCtx-&gt;blockContexts[move.dstBlockIndex];</div>
-<div class="line"><a name="l12663"></a><span class="lineno">12663</span>&#160; </div>
-<div class="line"><a name="l12664"></a><span class="lineno">12664</span>&#160;            VMA_ASSERT(srcBlockCtx.hBuffer &amp;&amp; dstBlockCtx.hBuffer);</div>
-<div class="line"><a name="l12665"></a><span class="lineno">12665</span>&#160; </div>
-<div class="line"><a name="l12666"></a><span class="lineno">12666</span>&#160;            VkBufferCopy region = {</div>
-<div class="line"><a name="l12667"></a><span class="lineno">12667</span>&#160;                move.srcOffset,</div>
-<div class="line"><a name="l12668"></a><span class="lineno">12668</span>&#160;                move.dstOffset,</div>
-<div class="line"><a name="l12669"></a><span class="lineno">12669</span>&#160;                move.size };</div>
-<div class="line"><a name="l12670"></a><span class="lineno">12670</span>&#160;            (*m_hAllocator-&gt;GetVulkanFunctions().vkCmdCopyBuffer)(</div>
-<div class="line"><a name="l12671"></a><span class="lineno">12671</span>&#160;                commandBuffer, srcBlockCtx.hBuffer, dstBlockCtx.hBuffer, 1, &amp;region);</div>
-<div class="line"><a name="l12672"></a><span class="lineno">12672</span>&#160;        }</div>
-<div class="line"><a name="l12673"></a><span class="lineno">12673</span>&#160;    }</div>
-<div class="line"><a name="l12674"></a><span class="lineno">12674</span>&#160; </div>
-<div class="line"><a name="l12675"></a><span class="lineno">12675</span>&#160;    <span class="comment">// Save buffers to defrag context for later destruction.</span></div>
-<div class="line"><a name="l12676"></a><span class="lineno">12676</span>&#160;    <span class="keywordflow">if</span>(pDefragCtx-&gt;res == VK_SUCCESS &amp;&amp; moveCount &gt; 0)</div>
-<div class="line"><a name="l12677"></a><span class="lineno">12677</span>&#160;    {</div>
-<div class="line"><a name="l12678"></a><span class="lineno">12678</span>&#160;        pDefragCtx-&gt;res = VK_NOT_READY;</div>
+<div class="line"><a name="l12583"></a><span class="lineno">12583</span>&#160;            <span class="keywordflow">if</span>(IsCorruptionDetectionEnabled())</div>
+<div class="line"><a name="l12584"></a><span class="lineno">12584</span>&#160;            {</div>
+<div class="line"><a name="l12585"></a><span class="lineno">12585</span>&#160;                VmaWriteMagicValue(dstBlockInfo.pMappedData, move.dstOffset - VMA_DEBUG_MARGIN);</div>
+<div class="line"><a name="l12586"></a><span class="lineno">12586</span>&#160;                VmaWriteMagicValue(dstBlockInfo.pMappedData, move.dstOffset + move.size);</div>
+<div class="line"><a name="l12587"></a><span class="lineno">12587</span>&#160;            }</div>
+<div class="line"><a name="l12588"></a><span class="lineno">12588</span>&#160; </div>
+<div class="line"><a name="l12589"></a><span class="lineno">12589</span>&#160;            <span class="comment">// Flush destination.</span></div>
+<div class="line"><a name="l12590"></a><span class="lineno">12590</span>&#160;            <span class="keywordflow">if</span>(isNonCoherent)</div>
+<div class="line"><a name="l12591"></a><span class="lineno">12591</span>&#160;            {</div>
+<div class="line"><a name="l12592"></a><span class="lineno">12592</span>&#160;                VmaDeviceMemoryBlock* <span class="keyword">const</span> pDstBlock = m_Blocks[move.dstBlockIndex];</div>
+<div class="line"><a name="l12593"></a><span class="lineno">12593</span>&#160;                memRange.memory = pDstBlock-&gt;GetDeviceMemory();</div>
+<div class="line"><a name="l12594"></a><span class="lineno">12594</span>&#160;                memRange.offset = VmaAlignDown(move.dstOffset, nonCoherentAtomSize);</div>
+<div class="line"><a name="l12595"></a><span class="lineno">12595</span>&#160;                memRange.size = VMA_MIN(</div>
+<div class="line"><a name="l12596"></a><span class="lineno">12596</span>&#160;                    VmaAlignUp(move.size + (move.dstOffset - memRange.offset), nonCoherentAtomSize),</div>
+<div class="line"><a name="l12597"></a><span class="lineno">12597</span>&#160;                    pDstBlock-&gt;m_pMetadata-&gt;GetSize() - memRange.offset);</div>
+<div class="line"><a name="l12598"></a><span class="lineno">12598</span>&#160;                (*m_hAllocator-&gt;GetVulkanFunctions().vkFlushMappedMemoryRanges)(m_hAllocator-&gt;m_hDevice, 1, &amp;memRange);</div>
+<div class="line"><a name="l12599"></a><span class="lineno">12599</span>&#160;            }</div>
+<div class="line"><a name="l12600"></a><span class="lineno">12600</span>&#160;        }</div>
+<div class="line"><a name="l12601"></a><span class="lineno">12601</span>&#160;    }</div>
+<div class="line"><a name="l12602"></a><span class="lineno">12602</span>&#160; </div>
+<div class="line"><a name="l12603"></a><span class="lineno">12603</span>&#160;    <span class="comment">// Go over all blocks in reverse order. Unmap those that were mapped just for defragmentation.</span></div>
+<div class="line"><a name="l12604"></a><span class="lineno">12604</span>&#160;    <span class="comment">// Regardless of pCtx-&gt;res == VK_SUCCESS.</span></div>
+<div class="line"><a name="l12605"></a><span class="lineno">12605</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = blockCount; blockIndex--; )</div>
+<div class="line"><a name="l12606"></a><span class="lineno">12606</span>&#160;    {</div>
+<div class="line"><a name="l12607"></a><span class="lineno">12607</span>&#160;        <span class="keyword">const</span> BlockInfo&amp; currBlockInfo = blockInfo[blockIndex];</div>
+<div class="line"><a name="l12608"></a><span class="lineno">12608</span>&#160;        <span class="keywordflow">if</span>((currBlockInfo.flags &amp; BLOCK_FLAG_MAPPED_FOR_DEFRAGMENTATION) != 0)</div>
+<div class="line"><a name="l12609"></a><span class="lineno">12609</span>&#160;        {</div>
+<div class="line"><a name="l12610"></a><span class="lineno">12610</span>&#160;            VmaDeviceMemoryBlock* pBlock = m_Blocks[blockIndex];</div>
+<div class="line"><a name="l12611"></a><span class="lineno">12611</span>&#160;            pBlock-&gt;Unmap(m_hAllocator, 1);</div>
+<div class="line"><a name="l12612"></a><span class="lineno">12612</span>&#160;        }</div>
+<div class="line"><a name="l12613"></a><span class="lineno">12613</span>&#160;    }</div>
+<div class="line"><a name="l12614"></a><span class="lineno">12614</span>&#160;}</div>
+<div class="line"><a name="l12615"></a><span class="lineno">12615</span>&#160; </div>
+<div class="line"><a name="l12616"></a><span class="lineno">12616</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::ApplyDefragmentationMovesGpu(</div>
+<div class="line"><a name="l12617"></a><span class="lineno">12617</span>&#160;    <span class="keyword">class</span> VmaBlockVectorDefragmentationContext* pDefragCtx,</div>
+<div class="line"><a name="l12618"></a><span class="lineno">12618</span>&#160;    <span class="keyword">const</span> VmaVector&lt; VmaDefragmentationMove, VmaStlAllocator&lt;VmaDefragmentationMove&gt; &gt;&amp; moves,</div>
+<div class="line"><a name="l12619"></a><span class="lineno">12619</span>&#160;    VkCommandBuffer commandBuffer)</div>
+<div class="line"><a name="l12620"></a><span class="lineno">12620</span>&#160;{</div>
+<div class="line"><a name="l12621"></a><span class="lineno">12621</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> blockCount = m_Blocks.size();</div>
+<div class="line"><a name="l12622"></a><span class="lineno">12622</span>&#160; </div>
+<div class="line"><a name="l12623"></a><span class="lineno">12623</span>&#160;    pDefragCtx-&gt;blockContexts.resize(blockCount);</div>
+<div class="line"><a name="l12624"></a><span class="lineno">12624</span>&#160;    memset(pDefragCtx-&gt;blockContexts.data(), 0, blockCount * <span class="keyword">sizeof</span>(VmaBlockDefragmentationContext));</div>
+<div class="line"><a name="l12625"></a><span class="lineno">12625</span>&#160; </div>
+<div class="line"><a name="l12626"></a><span class="lineno">12626</span>&#160;    <span class="comment">// Go over all moves. Mark blocks that are used with BLOCK_FLAG_USED.</span></div>
+<div class="line"><a name="l12627"></a><span class="lineno">12627</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> moveCount = moves.size();</div>
+<div class="line"><a name="l12628"></a><span class="lineno">12628</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> moveIndex = 0; moveIndex &lt; moveCount; ++moveIndex)</div>
+<div class="line"><a name="l12629"></a><span class="lineno">12629</span>&#160;    {</div>
+<div class="line"><a name="l12630"></a><span class="lineno">12630</span>&#160;        <span class="keyword">const</span> VmaDefragmentationMove&amp; move = moves[moveIndex];</div>
+<div class="line"><a name="l12631"></a><span class="lineno">12631</span>&#160;        pDefragCtx-&gt;blockContexts[move.srcBlockIndex].flags |= VmaBlockDefragmentationContext::BLOCK_FLAG_USED;</div>
+<div class="line"><a name="l12632"></a><span class="lineno">12632</span>&#160;        pDefragCtx-&gt;blockContexts[move.dstBlockIndex].flags |= VmaBlockDefragmentationContext::BLOCK_FLAG_USED;</div>
+<div class="line"><a name="l12633"></a><span class="lineno">12633</span>&#160;    }</div>
+<div class="line"><a name="l12634"></a><span class="lineno">12634</span>&#160; </div>
+<div class="line"><a name="l12635"></a><span class="lineno">12635</span>&#160;    VMA_ASSERT(pDefragCtx-&gt;res == VK_SUCCESS);</div>
+<div class="line"><a name="l12636"></a><span class="lineno">12636</span>&#160; </div>
+<div class="line"><a name="l12637"></a><span class="lineno">12637</span>&#160;    <span class="comment">// Go over all blocks. Create and bind buffer for whole block if necessary.</span></div>
+<div class="line"><a name="l12638"></a><span class="lineno">12638</span>&#160;    {</div>
+<div class="line"><a name="l12639"></a><span class="lineno">12639</span>&#160;        VkBufferCreateInfo bufCreateInfo;</div>
+<div class="line"><a name="l12640"></a><span class="lineno">12640</span>&#160;        VmaFillGpuDefragmentationBufferCreateInfo(bufCreateInfo);</div>
+<div class="line"><a name="l12641"></a><span class="lineno">12641</span>&#160; </div>
+<div class="line"><a name="l12642"></a><span class="lineno">12642</span>&#160;        <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; pDefragCtx-&gt;res == VK_SUCCESS &amp;&amp; blockIndex &lt; blockCount; ++blockIndex)</div>
+<div class="line"><a name="l12643"></a><span class="lineno">12643</span>&#160;        {</div>
+<div class="line"><a name="l12644"></a><span class="lineno">12644</span>&#160;            VmaBlockDefragmentationContext&amp; currBlockCtx = pDefragCtx-&gt;blockContexts[blockIndex];</div>
+<div class="line"><a name="l12645"></a><span class="lineno">12645</span>&#160;            VmaDeviceMemoryBlock* pBlock = m_Blocks[blockIndex];</div>
+<div class="line"><a name="l12646"></a><span class="lineno">12646</span>&#160;            <span class="keywordflow">if</span>((currBlockCtx.flags &amp; VmaBlockDefragmentationContext::BLOCK_FLAG_USED) != 0)</div>
+<div class="line"><a name="l12647"></a><span class="lineno">12647</span>&#160;            {</div>
+<div class="line"><a name="l12648"></a><span class="lineno">12648</span>&#160;                bufCreateInfo.size = pBlock-&gt;m_pMetadata-&gt;GetSize();</div>
+<div class="line"><a name="l12649"></a><span class="lineno">12649</span>&#160;                pDefragCtx-&gt;res = (*m_hAllocator-&gt;GetVulkanFunctions().vkCreateBuffer)(</div>
+<div class="line"><a name="l12650"></a><span class="lineno">12650</span>&#160;                    m_hAllocator-&gt;m_hDevice, &amp;bufCreateInfo, m_hAllocator-&gt;GetAllocationCallbacks(), &amp;currBlockCtx.hBuffer);</div>
+<div class="line"><a name="l12651"></a><span class="lineno">12651</span>&#160;                <span class="keywordflow">if</span>(pDefragCtx-&gt;res == VK_SUCCESS)</div>
+<div class="line"><a name="l12652"></a><span class="lineno">12652</span>&#160;                {</div>
+<div class="line"><a name="l12653"></a><span class="lineno">12653</span>&#160;                    pDefragCtx-&gt;res = (*m_hAllocator-&gt;GetVulkanFunctions().vkBindBufferMemory)(</div>
+<div class="line"><a name="l12654"></a><span class="lineno">12654</span>&#160;                        m_hAllocator-&gt;m_hDevice, currBlockCtx.hBuffer, pBlock-&gt;GetDeviceMemory(), 0);</div>
+<div class="line"><a name="l12655"></a><span class="lineno">12655</span>&#160;                }</div>
+<div class="line"><a name="l12656"></a><span class="lineno">12656</span>&#160;            }</div>
+<div class="line"><a name="l12657"></a><span class="lineno">12657</span>&#160;        }</div>
+<div class="line"><a name="l12658"></a><span class="lineno">12658</span>&#160;    }</div>
+<div class="line"><a name="l12659"></a><span class="lineno">12659</span>&#160; </div>
+<div class="line"><a name="l12660"></a><span class="lineno">12660</span>&#160;    <span class="comment">// Go over all moves. Post data transfer commands to command buffer.</span></div>
+<div class="line"><a name="l12661"></a><span class="lineno">12661</span>&#160;    <span class="keywordflow">if</span>(pDefragCtx-&gt;res == VK_SUCCESS)</div>
+<div class="line"><a name="l12662"></a><span class="lineno">12662</span>&#160;    {</div>
+<div class="line"><a name="l12663"></a><span class="lineno">12663</span>&#160;        <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> moveIndex = 0; moveIndex &lt; moveCount; ++moveIndex)</div>
+<div class="line"><a name="l12664"></a><span class="lineno">12664</span>&#160;        {</div>
+<div class="line"><a name="l12665"></a><span class="lineno">12665</span>&#160;            <span class="keyword">const</span> VmaDefragmentationMove&amp; move = moves[moveIndex];</div>
+<div class="line"><a name="l12666"></a><span class="lineno">12666</span>&#160; </div>
+<div class="line"><a name="l12667"></a><span class="lineno">12667</span>&#160;            <span class="keyword">const</span> VmaBlockDefragmentationContext&amp; srcBlockCtx = pDefragCtx-&gt;blockContexts[move.srcBlockIndex];</div>
+<div class="line"><a name="l12668"></a><span class="lineno">12668</span>&#160;            <span class="keyword">const</span> VmaBlockDefragmentationContext&amp; dstBlockCtx = pDefragCtx-&gt;blockContexts[move.dstBlockIndex];</div>
+<div class="line"><a name="l12669"></a><span class="lineno">12669</span>&#160; </div>
+<div class="line"><a name="l12670"></a><span class="lineno">12670</span>&#160;            VMA_ASSERT(srcBlockCtx.hBuffer &amp;&amp; dstBlockCtx.hBuffer);</div>
+<div class="line"><a name="l12671"></a><span class="lineno">12671</span>&#160; </div>
+<div class="line"><a name="l12672"></a><span class="lineno">12672</span>&#160;            VkBufferCopy region = {</div>
+<div class="line"><a name="l12673"></a><span class="lineno">12673</span>&#160;                move.srcOffset,</div>
+<div class="line"><a name="l12674"></a><span class="lineno">12674</span>&#160;                move.dstOffset,</div>
+<div class="line"><a name="l12675"></a><span class="lineno">12675</span>&#160;                move.size };</div>
+<div class="line"><a name="l12676"></a><span class="lineno">12676</span>&#160;            (*m_hAllocator-&gt;GetVulkanFunctions().vkCmdCopyBuffer)(</div>
+<div class="line"><a name="l12677"></a><span class="lineno">12677</span>&#160;                commandBuffer, srcBlockCtx.hBuffer, dstBlockCtx.hBuffer, 1, &amp;region);</div>
+<div class="line"><a name="l12678"></a><span class="lineno">12678</span>&#160;        }</div>
 <div class="line"><a name="l12679"></a><span class="lineno">12679</span>&#160;    }</div>
-<div class="line"><a name="l12680"></a><span class="lineno">12680</span>&#160;}</div>
-<div class="line"><a name="l12681"></a><span class="lineno">12681</span>&#160; </div>
-<div class="line"><a name="l12682"></a><span class="lineno">12682</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::FreeEmptyBlocks(<a class="code" href="struct_vma_defragmentation_stats.html">VmaDefragmentationStats</a>* pDefragmentationStats)</div>
-<div class="line"><a name="l12683"></a><span class="lineno">12683</span>&#160;{</div>
-<div class="line"><a name="l12684"></a><span class="lineno">12684</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = m_Blocks.size(); blockIndex--; )</div>
-<div class="line"><a name="l12685"></a><span class="lineno">12685</span>&#160;    {</div>
-<div class="line"><a name="l12686"></a><span class="lineno">12686</span>&#160;        VmaDeviceMemoryBlock* pBlock = m_Blocks[blockIndex];</div>
-<div class="line"><a name="l12687"></a><span class="lineno">12687</span>&#160;        <span class="keywordflow">if</span>(pBlock-&gt;m_pMetadata-&gt;IsEmpty())</div>
-<div class="line"><a name="l12688"></a><span class="lineno">12688</span>&#160;        {</div>
-<div class="line"><a name="l12689"></a><span class="lineno">12689</span>&#160;            <span class="keywordflow">if</span>(m_Blocks.size() &gt; m_MinBlockCount)</div>
-<div class="line"><a name="l12690"></a><span class="lineno">12690</span>&#160;            {</div>
-<div class="line"><a name="l12691"></a><span class="lineno">12691</span>&#160;                <span class="keywordflow">if</span>(pDefragmentationStats != VMA_NULL)</div>
-<div class="line"><a name="l12692"></a><span class="lineno">12692</span>&#160;                {</div>
-<div class="line"><a name="l12693"></a><span class="lineno">12693</span>&#160;                    ++pDefragmentationStats-&gt;<a class="code" href="struct_vma_defragmentation_stats.html#a0113f1877904a5d1ee8f409216ff276b">deviceMemoryBlocksFreed</a>;</div>
-<div class="line"><a name="l12694"></a><span class="lineno">12694</span>&#160;                    pDefragmentationStats-&gt;<a class="code" href="struct_vma_defragmentation_stats.html#ab0cb9ac0dbc106c77e384ea676422f28">bytesFreed</a> += pBlock-&gt;m_pMetadata-&gt;GetSize();</div>
-<div class="line"><a name="l12695"></a><span class="lineno">12695</span>&#160;                }</div>
-<div class="line"><a name="l12696"></a><span class="lineno">12696</span>&#160; </div>
-<div class="line"><a name="l12697"></a><span class="lineno">12697</span>&#160;                VmaVectorRemove(m_Blocks, blockIndex);</div>
-<div class="line"><a name="l12698"></a><span class="lineno">12698</span>&#160;                pBlock-&gt;Destroy(m_hAllocator);</div>
-<div class="line"><a name="l12699"></a><span class="lineno">12699</span>&#160;                vma_delete(m_hAllocator, pBlock);</div>
-<div class="line"><a name="l12700"></a><span class="lineno">12700</span>&#160;            }</div>
-<div class="line"><a name="l12701"></a><span class="lineno">12701</span>&#160;            <span class="keywordflow">else</span></div>
-<div class="line"><a name="l12702"></a><span class="lineno">12702</span>&#160;            {</div>
-<div class="line"><a name="l12703"></a><span class="lineno">12703</span>&#160;                <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l12704"></a><span class="lineno">12704</span>&#160;            }</div>
-<div class="line"><a name="l12705"></a><span class="lineno">12705</span>&#160;        }</div>
-<div class="line"><a name="l12706"></a><span class="lineno">12706</span>&#160;    }</div>
-<div class="line"><a name="l12707"></a><span class="lineno">12707</span>&#160;    UpdateHasEmptyBlock();</div>
-<div class="line"><a name="l12708"></a><span class="lineno">12708</span>&#160;}</div>
-<div class="line"><a name="l12709"></a><span class="lineno">12709</span>&#160; </div>
-<div class="line"><a name="l12710"></a><span class="lineno">12710</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::UpdateHasEmptyBlock()</div>
-<div class="line"><a name="l12711"></a><span class="lineno">12711</span>&#160;{</div>
-<div class="line"><a name="l12712"></a><span class="lineno">12712</span>&#160;    m_HasEmptyBlock = <span class="keyword">false</span>;</div>
-<div class="line"><a name="l12713"></a><span class="lineno">12713</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> index = 0, count = m_Blocks.size(); index &lt; count; ++index)</div>
-<div class="line"><a name="l12714"></a><span class="lineno">12714</span>&#160;    {</div>
-<div class="line"><a name="l12715"></a><span class="lineno">12715</span>&#160;        VmaDeviceMemoryBlock* <span class="keyword">const</span> pBlock = m_Blocks[index];</div>
-<div class="line"><a name="l12716"></a><span class="lineno">12716</span>&#160;        <span class="keywordflow">if</span>(pBlock-&gt;m_pMetadata-&gt;IsEmpty())</div>
-<div class="line"><a name="l12717"></a><span class="lineno">12717</span>&#160;        {</div>
-<div class="line"><a name="l12718"></a><span class="lineno">12718</span>&#160;            m_HasEmptyBlock = <span class="keyword">true</span>;</div>
-<div class="line"><a name="l12719"></a><span class="lineno">12719</span>&#160;            <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l12720"></a><span class="lineno">12720</span>&#160;        }</div>
-<div class="line"><a name="l12721"></a><span class="lineno">12721</span>&#160;    }</div>
-<div class="line"><a name="l12722"></a><span class="lineno">12722</span>&#160;}</div>
-<div class="line"><a name="l12723"></a><span class="lineno">12723</span>&#160; </div>
-<div class="line"><a name="l12724"></a><span class="lineno">12724</span>&#160;<span class="preprocessor">#if VMA_STATS_STRING_ENABLED</span></div>
-<div class="line"><a name="l12725"></a><span class="lineno">12725</span>&#160; </div>
-<div class="line"><a name="l12726"></a><span class="lineno">12726</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::PrintDetailedMap(<span class="keyword">class</span> VmaJsonWriter&amp; json)</div>
-<div class="line"><a name="l12727"></a><span class="lineno">12727</span>&#160;{</div>
-<div class="line"><a name="l12728"></a><span class="lineno">12728</span>&#160;    VmaMutexLockRead lock(m_Mutex, m_hAllocator-&gt;m_UseMutex);</div>
+<div class="line"><a name="l12680"></a><span class="lineno">12680</span>&#160; </div>
+<div class="line"><a name="l12681"></a><span class="lineno">12681</span>&#160;    <span class="comment">// Save buffers to defrag context for later destruction.</span></div>
+<div class="line"><a name="l12682"></a><span class="lineno">12682</span>&#160;    <span class="keywordflow">if</span>(pDefragCtx-&gt;res == VK_SUCCESS &amp;&amp; moveCount &gt; 0)</div>
+<div class="line"><a name="l12683"></a><span class="lineno">12683</span>&#160;    {</div>
+<div class="line"><a name="l12684"></a><span class="lineno">12684</span>&#160;        pDefragCtx-&gt;res = VK_NOT_READY;</div>
+<div class="line"><a name="l12685"></a><span class="lineno">12685</span>&#160;    }</div>
+<div class="line"><a name="l12686"></a><span class="lineno">12686</span>&#160;}</div>
+<div class="line"><a name="l12687"></a><span class="lineno">12687</span>&#160; </div>
+<div class="line"><a name="l12688"></a><span class="lineno">12688</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::FreeEmptyBlocks(<a class="code" href="struct_vma_defragmentation_stats.html">VmaDefragmentationStats</a>* pDefragmentationStats)</div>
+<div class="line"><a name="l12689"></a><span class="lineno">12689</span>&#160;{</div>
+<div class="line"><a name="l12690"></a><span class="lineno">12690</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = m_Blocks.size(); blockIndex--; )</div>
+<div class="line"><a name="l12691"></a><span class="lineno">12691</span>&#160;    {</div>
+<div class="line"><a name="l12692"></a><span class="lineno">12692</span>&#160;        VmaDeviceMemoryBlock* pBlock = m_Blocks[blockIndex];</div>
+<div class="line"><a name="l12693"></a><span class="lineno">12693</span>&#160;        <span class="keywordflow">if</span>(pBlock-&gt;m_pMetadata-&gt;IsEmpty())</div>
+<div class="line"><a name="l12694"></a><span class="lineno">12694</span>&#160;        {</div>
+<div class="line"><a name="l12695"></a><span class="lineno">12695</span>&#160;            <span class="keywordflow">if</span>(m_Blocks.size() &gt; m_MinBlockCount)</div>
+<div class="line"><a name="l12696"></a><span class="lineno">12696</span>&#160;            {</div>
+<div class="line"><a name="l12697"></a><span class="lineno">12697</span>&#160;                <span class="keywordflow">if</span>(pDefragmentationStats != VMA_NULL)</div>
+<div class="line"><a name="l12698"></a><span class="lineno">12698</span>&#160;                {</div>
+<div class="line"><a name="l12699"></a><span class="lineno">12699</span>&#160;                    ++pDefragmentationStats-&gt;<a class="code" href="struct_vma_defragmentation_stats.html#a0113f1877904a5d1ee8f409216ff276b">deviceMemoryBlocksFreed</a>;</div>
+<div class="line"><a name="l12700"></a><span class="lineno">12700</span>&#160;                    pDefragmentationStats-&gt;<a class="code" href="struct_vma_defragmentation_stats.html#ab0cb9ac0dbc106c77e384ea676422f28">bytesFreed</a> += pBlock-&gt;m_pMetadata-&gt;GetSize();</div>
+<div class="line"><a name="l12701"></a><span class="lineno">12701</span>&#160;                }</div>
+<div class="line"><a name="l12702"></a><span class="lineno">12702</span>&#160; </div>
+<div class="line"><a name="l12703"></a><span class="lineno">12703</span>&#160;                VmaVectorRemove(m_Blocks, blockIndex);</div>
+<div class="line"><a name="l12704"></a><span class="lineno">12704</span>&#160;                pBlock-&gt;Destroy(m_hAllocator);</div>
+<div class="line"><a name="l12705"></a><span class="lineno">12705</span>&#160;                vma_delete(m_hAllocator, pBlock);</div>
+<div class="line"><a name="l12706"></a><span class="lineno">12706</span>&#160;            }</div>
+<div class="line"><a name="l12707"></a><span class="lineno">12707</span>&#160;            <span class="keywordflow">else</span></div>
+<div class="line"><a name="l12708"></a><span class="lineno">12708</span>&#160;            {</div>
+<div class="line"><a name="l12709"></a><span class="lineno">12709</span>&#160;                <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l12710"></a><span class="lineno">12710</span>&#160;            }</div>
+<div class="line"><a name="l12711"></a><span class="lineno">12711</span>&#160;        }</div>
+<div class="line"><a name="l12712"></a><span class="lineno">12712</span>&#160;    }</div>
+<div class="line"><a name="l12713"></a><span class="lineno">12713</span>&#160;    UpdateHasEmptyBlock();</div>
+<div class="line"><a name="l12714"></a><span class="lineno">12714</span>&#160;}</div>
+<div class="line"><a name="l12715"></a><span class="lineno">12715</span>&#160; </div>
+<div class="line"><a name="l12716"></a><span class="lineno">12716</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::UpdateHasEmptyBlock()</div>
+<div class="line"><a name="l12717"></a><span class="lineno">12717</span>&#160;{</div>
+<div class="line"><a name="l12718"></a><span class="lineno">12718</span>&#160;    m_HasEmptyBlock = <span class="keyword">false</span>;</div>
+<div class="line"><a name="l12719"></a><span class="lineno">12719</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> index = 0, count = m_Blocks.size(); index &lt; count; ++index)</div>
+<div class="line"><a name="l12720"></a><span class="lineno">12720</span>&#160;    {</div>
+<div class="line"><a name="l12721"></a><span class="lineno">12721</span>&#160;        VmaDeviceMemoryBlock* <span class="keyword">const</span> pBlock = m_Blocks[index];</div>
+<div class="line"><a name="l12722"></a><span class="lineno">12722</span>&#160;        <span class="keywordflow">if</span>(pBlock-&gt;m_pMetadata-&gt;IsEmpty())</div>
+<div class="line"><a name="l12723"></a><span class="lineno">12723</span>&#160;        {</div>
+<div class="line"><a name="l12724"></a><span class="lineno">12724</span>&#160;            m_HasEmptyBlock = <span class="keyword">true</span>;</div>
+<div class="line"><a name="l12725"></a><span class="lineno">12725</span>&#160;            <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l12726"></a><span class="lineno">12726</span>&#160;        }</div>
+<div class="line"><a name="l12727"></a><span class="lineno">12727</span>&#160;    }</div>
+<div class="line"><a name="l12728"></a><span class="lineno">12728</span>&#160;}</div>
 <div class="line"><a name="l12729"></a><span class="lineno">12729</span>&#160; </div>
-<div class="line"><a name="l12730"></a><span class="lineno">12730</span>&#160;    json.BeginObject();</div>
+<div class="line"><a name="l12730"></a><span class="lineno">12730</span>&#160;<span class="preprocessor">#if VMA_STATS_STRING_ENABLED</span></div>
 <div class="line"><a name="l12731"></a><span class="lineno">12731</span>&#160; </div>
-<div class="line"><a name="l12732"></a><span class="lineno">12732</span>&#160;    <span class="keywordflow">if</span>(IsCustomPool())</div>
-<div class="line"><a name="l12733"></a><span class="lineno">12733</span>&#160;    {</div>
-<div class="line"><a name="l12734"></a><span class="lineno">12734</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">char</span>* poolName = m_hParentPool-&gt;GetName();</div>
-<div class="line"><a name="l12735"></a><span class="lineno">12735</span>&#160;        <span class="keywordflow">if</span>(poolName != VMA_NULL &amp;&amp; poolName[0] != <span class="charliteral">&#39;\0&#39;</span>)</div>
-<div class="line"><a name="l12736"></a><span class="lineno">12736</span>&#160;        {</div>
-<div class="line"><a name="l12737"></a><span class="lineno">12737</span>&#160;            json.WriteString(<span class="stringliteral">&quot;Name&quot;</span>);</div>
-<div class="line"><a name="l12738"></a><span class="lineno">12738</span>&#160;            json.WriteString(poolName);</div>
-<div class="line"><a name="l12739"></a><span class="lineno">12739</span>&#160;        }</div>
-<div class="line"><a name="l12740"></a><span class="lineno">12740</span>&#160; </div>
-<div class="line"><a name="l12741"></a><span class="lineno">12741</span>&#160;        json.WriteString(<span class="stringliteral">&quot;MemoryTypeIndex&quot;</span>);</div>
-<div class="line"><a name="l12742"></a><span class="lineno">12742</span>&#160;        json.WriteNumber(m_MemoryTypeIndex);</div>
-<div class="line"><a name="l12743"></a><span class="lineno">12743</span>&#160; </div>
-<div class="line"><a name="l12744"></a><span class="lineno">12744</span>&#160;        json.WriteString(<span class="stringliteral">&quot;BlockSize&quot;</span>);</div>
-<div class="line"><a name="l12745"></a><span class="lineno">12745</span>&#160;        json.WriteNumber(m_PreferredBlockSize);</div>
+<div class="line"><a name="l12732"></a><span class="lineno">12732</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::PrintDetailedMap(<span class="keyword">class</span> VmaJsonWriter&amp; json)</div>
+<div class="line"><a name="l12733"></a><span class="lineno">12733</span>&#160;{</div>
+<div class="line"><a name="l12734"></a><span class="lineno">12734</span>&#160;    VmaMutexLockRead lock(m_Mutex, m_hAllocator-&gt;m_UseMutex);</div>
+<div class="line"><a name="l12735"></a><span class="lineno">12735</span>&#160; </div>
+<div class="line"><a name="l12736"></a><span class="lineno">12736</span>&#160;    json.BeginObject();</div>
+<div class="line"><a name="l12737"></a><span class="lineno">12737</span>&#160; </div>
+<div class="line"><a name="l12738"></a><span class="lineno">12738</span>&#160;    <span class="keywordflow">if</span>(IsCustomPool())</div>
+<div class="line"><a name="l12739"></a><span class="lineno">12739</span>&#160;    {</div>
+<div class="line"><a name="l12740"></a><span class="lineno">12740</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">char</span>* poolName = m_hParentPool-&gt;GetName();</div>
+<div class="line"><a name="l12741"></a><span class="lineno">12741</span>&#160;        <span class="keywordflow">if</span>(poolName != VMA_NULL &amp;&amp; poolName[0] != <span class="charliteral">&#39;\0&#39;</span>)</div>
+<div class="line"><a name="l12742"></a><span class="lineno">12742</span>&#160;        {</div>
+<div class="line"><a name="l12743"></a><span class="lineno">12743</span>&#160;            json.WriteString(<span class="stringliteral">&quot;Name&quot;</span>);</div>
+<div class="line"><a name="l12744"></a><span class="lineno">12744</span>&#160;            json.WriteString(poolName);</div>
+<div class="line"><a name="l12745"></a><span class="lineno">12745</span>&#160;        }</div>
 <div class="line"><a name="l12746"></a><span class="lineno">12746</span>&#160; </div>
-<div class="line"><a name="l12747"></a><span class="lineno">12747</span>&#160;        json.WriteString(<span class="stringliteral">&quot;BlockCount&quot;</span>);</div>
-<div class="line"><a name="l12748"></a><span class="lineno">12748</span>&#160;        json.BeginObject(<span class="keyword">true</span>);</div>
-<div class="line"><a name="l12749"></a><span class="lineno">12749</span>&#160;        <span class="keywordflow">if</span>(m_MinBlockCount &gt; 0)</div>
-<div class="line"><a name="l12750"></a><span class="lineno">12750</span>&#160;        {</div>
-<div class="line"><a name="l12751"></a><span class="lineno">12751</span>&#160;            json.WriteString(<span class="stringliteral">&quot;Min&quot;</span>);</div>
-<div class="line"><a name="l12752"></a><span class="lineno">12752</span>&#160;            json.WriteNumber((uint64_t)m_MinBlockCount);</div>
-<div class="line"><a name="l12753"></a><span class="lineno">12753</span>&#160;        }</div>
-<div class="line"><a name="l12754"></a><span class="lineno">12754</span>&#160;        <span class="keywordflow">if</span>(m_MaxBlockCount &lt; SIZE_MAX)</div>
-<div class="line"><a name="l12755"></a><span class="lineno">12755</span>&#160;        {</div>
-<div class="line"><a name="l12756"></a><span class="lineno">12756</span>&#160;            json.WriteString(<span class="stringliteral">&quot;Max&quot;</span>);</div>
-<div class="line"><a name="l12757"></a><span class="lineno">12757</span>&#160;            json.WriteNumber((uint64_t)m_MaxBlockCount);</div>
-<div class="line"><a name="l12758"></a><span class="lineno">12758</span>&#160;        }</div>
-<div class="line"><a name="l12759"></a><span class="lineno">12759</span>&#160;        json.WriteString(<span class="stringliteral">&quot;Cur&quot;</span>);</div>
-<div class="line"><a name="l12760"></a><span class="lineno">12760</span>&#160;        json.WriteNumber((uint64_t)m_Blocks.size());</div>
-<div class="line"><a name="l12761"></a><span class="lineno">12761</span>&#160;        json.EndObject();</div>
-<div class="line"><a name="l12762"></a><span class="lineno">12762</span>&#160; </div>
-<div class="line"><a name="l12763"></a><span class="lineno">12763</span>&#160;        <span class="keywordflow">if</span>(m_FrameInUseCount &gt; 0)</div>
-<div class="line"><a name="l12764"></a><span class="lineno">12764</span>&#160;        {</div>
-<div class="line"><a name="l12765"></a><span class="lineno">12765</span>&#160;            json.WriteString(<span class="stringliteral">&quot;FrameInUseCount&quot;</span>);</div>
-<div class="line"><a name="l12766"></a><span class="lineno">12766</span>&#160;            json.WriteNumber(m_FrameInUseCount);</div>
-<div class="line"><a name="l12767"></a><span class="lineno">12767</span>&#160;        }</div>
+<div class="line"><a name="l12747"></a><span class="lineno">12747</span>&#160;        json.WriteString(<span class="stringliteral">&quot;MemoryTypeIndex&quot;</span>);</div>
+<div class="line"><a name="l12748"></a><span class="lineno">12748</span>&#160;        json.WriteNumber(m_MemoryTypeIndex);</div>
+<div class="line"><a name="l12749"></a><span class="lineno">12749</span>&#160; </div>
+<div class="line"><a name="l12750"></a><span class="lineno">12750</span>&#160;        json.WriteString(<span class="stringliteral">&quot;BlockSize&quot;</span>);</div>
+<div class="line"><a name="l12751"></a><span class="lineno">12751</span>&#160;        json.WriteNumber(m_PreferredBlockSize);</div>
+<div class="line"><a name="l12752"></a><span class="lineno">12752</span>&#160; </div>
+<div class="line"><a name="l12753"></a><span class="lineno">12753</span>&#160;        json.WriteString(<span class="stringliteral">&quot;BlockCount&quot;</span>);</div>
+<div class="line"><a name="l12754"></a><span class="lineno">12754</span>&#160;        json.BeginObject(<span class="keyword">true</span>);</div>
+<div class="line"><a name="l12755"></a><span class="lineno">12755</span>&#160;        <span class="keywordflow">if</span>(m_MinBlockCount &gt; 0)</div>
+<div class="line"><a name="l12756"></a><span class="lineno">12756</span>&#160;        {</div>
+<div class="line"><a name="l12757"></a><span class="lineno">12757</span>&#160;            json.WriteString(<span class="stringliteral">&quot;Min&quot;</span>);</div>
+<div class="line"><a name="l12758"></a><span class="lineno">12758</span>&#160;            json.WriteNumber((uint64_t)m_MinBlockCount);</div>
+<div class="line"><a name="l12759"></a><span class="lineno">12759</span>&#160;        }</div>
+<div class="line"><a name="l12760"></a><span class="lineno">12760</span>&#160;        <span class="keywordflow">if</span>(m_MaxBlockCount &lt; SIZE_MAX)</div>
+<div class="line"><a name="l12761"></a><span class="lineno">12761</span>&#160;        {</div>
+<div class="line"><a name="l12762"></a><span class="lineno">12762</span>&#160;            json.WriteString(<span class="stringliteral">&quot;Max&quot;</span>);</div>
+<div class="line"><a name="l12763"></a><span class="lineno">12763</span>&#160;            json.WriteNumber((uint64_t)m_MaxBlockCount);</div>
+<div class="line"><a name="l12764"></a><span class="lineno">12764</span>&#160;        }</div>
+<div class="line"><a name="l12765"></a><span class="lineno">12765</span>&#160;        json.WriteString(<span class="stringliteral">&quot;Cur&quot;</span>);</div>
+<div class="line"><a name="l12766"></a><span class="lineno">12766</span>&#160;        json.WriteNumber((uint64_t)m_Blocks.size());</div>
+<div class="line"><a name="l12767"></a><span class="lineno">12767</span>&#160;        json.EndObject();</div>
 <div class="line"><a name="l12768"></a><span class="lineno">12768</span>&#160; </div>
-<div class="line"><a name="l12769"></a><span class="lineno">12769</span>&#160;        <span class="keywordflow">if</span>(m_Algorithm != 0)</div>
+<div class="line"><a name="l12769"></a><span class="lineno">12769</span>&#160;        <span class="keywordflow">if</span>(m_FrameInUseCount &gt; 0)</div>
 <div class="line"><a name="l12770"></a><span class="lineno">12770</span>&#160;        {</div>
-<div class="line"><a name="l12771"></a><span class="lineno">12771</span>&#160;            json.WriteString(<span class="stringliteral">&quot;Algorithm&quot;</span>);</div>
-<div class="line"><a name="l12772"></a><span class="lineno">12772</span>&#160;            json.WriteString(VmaAlgorithmToStr(m_Algorithm));</div>
+<div class="line"><a name="l12771"></a><span class="lineno">12771</span>&#160;            json.WriteString(<span class="stringliteral">&quot;FrameInUseCount&quot;</span>);</div>
+<div class="line"><a name="l12772"></a><span class="lineno">12772</span>&#160;            json.WriteNumber(m_FrameInUseCount);</div>
 <div class="line"><a name="l12773"></a><span class="lineno">12773</span>&#160;        }</div>
-<div class="line"><a name="l12774"></a><span class="lineno">12774</span>&#160;    }</div>
-<div class="line"><a name="l12775"></a><span class="lineno">12775</span>&#160;    <span class="keywordflow">else</span></div>
-<div class="line"><a name="l12776"></a><span class="lineno">12776</span>&#160;    {</div>
-<div class="line"><a name="l12777"></a><span class="lineno">12777</span>&#160;        json.WriteString(<span class="stringliteral">&quot;PreferredBlockSize&quot;</span>);</div>
-<div class="line"><a name="l12778"></a><span class="lineno">12778</span>&#160;        json.WriteNumber(m_PreferredBlockSize);</div>
-<div class="line"><a name="l12779"></a><span class="lineno">12779</span>&#160;    }</div>
-<div class="line"><a name="l12780"></a><span class="lineno">12780</span>&#160; </div>
-<div class="line"><a name="l12781"></a><span class="lineno">12781</span>&#160;    json.WriteString(<span class="stringliteral">&quot;Blocks&quot;</span>);</div>
-<div class="line"><a name="l12782"></a><span class="lineno">12782</span>&#160;    json.BeginObject();</div>
-<div class="line"><a name="l12783"></a><span class="lineno">12783</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 0; i &lt; m_Blocks.size(); ++i)</div>
-<div class="line"><a name="l12784"></a><span class="lineno">12784</span>&#160;    {</div>
-<div class="line"><a name="l12785"></a><span class="lineno">12785</span>&#160;        json.BeginString();</div>
-<div class="line"><a name="l12786"></a><span class="lineno">12786</span>&#160;        json.ContinueString(m_Blocks[i]-&gt;GetId());</div>
-<div class="line"><a name="l12787"></a><span class="lineno">12787</span>&#160;        json.EndString();</div>
-<div class="line"><a name="l12788"></a><span class="lineno">12788</span>&#160; </div>
-<div class="line"><a name="l12789"></a><span class="lineno">12789</span>&#160;        m_Blocks[i]-&gt;m_pMetadata-&gt;PrintDetailedMap(json);</div>
-<div class="line"><a name="l12790"></a><span class="lineno">12790</span>&#160;    }</div>
-<div class="line"><a name="l12791"></a><span class="lineno">12791</span>&#160;    json.EndObject();</div>
-<div class="line"><a name="l12792"></a><span class="lineno">12792</span>&#160; </div>
-<div class="line"><a name="l12793"></a><span class="lineno">12793</span>&#160;    json.EndObject();</div>
-<div class="line"><a name="l12794"></a><span class="lineno">12794</span>&#160;}</div>
-<div class="line"><a name="l12795"></a><span class="lineno">12795</span>&#160; </div>
-<div class="line"><a name="l12796"></a><span class="lineno">12796</span>&#160;<span class="preprocessor">#endif // #if VMA_STATS_STRING_ENABLED</span></div>
-<div class="line"><a name="l12797"></a><span class="lineno">12797</span>&#160; </div>
-<div class="line"><a name="l12798"></a><span class="lineno">12798</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::Defragment(</div>
-<div class="line"><a name="l12799"></a><span class="lineno">12799</span>&#160;    <span class="keyword">class</span> VmaBlockVectorDefragmentationContext* pCtx,</div>
-<div class="line"><a name="l12800"></a><span class="lineno">12800</span>&#160;    <a class="code" href="struct_vma_defragmentation_stats.html">VmaDefragmentationStats</a>* pStats,</div>
-<div class="line"><a name="l12801"></a><span class="lineno">12801</span>&#160;    VkDeviceSize&amp; maxCpuBytesToMove, uint32_t&amp; maxCpuAllocationsToMove,</div>
-<div class="line"><a name="l12802"></a><span class="lineno">12802</span>&#160;    VkDeviceSize&amp; maxGpuBytesToMove, uint32_t&amp; maxGpuAllocationsToMove,</div>
-<div class="line"><a name="l12803"></a><span class="lineno">12803</span>&#160;    VkCommandBuffer commandBuffer)</div>
-<div class="line"><a name="l12804"></a><span class="lineno">12804</span>&#160;{</div>
-<div class="line"><a name="l12805"></a><span class="lineno">12805</span>&#160;    pCtx-&gt;res = VK_SUCCESS;</div>
-<div class="line"><a name="l12806"></a><span class="lineno">12806</span>&#160;    </div>
-<div class="line"><a name="l12807"></a><span class="lineno">12807</span>&#160;    <span class="keyword">const</span> VkMemoryPropertyFlags memPropFlags =</div>
-<div class="line"><a name="l12808"></a><span class="lineno">12808</span>&#160;        m_hAllocator-&gt;m_MemProps.memoryTypes[m_MemoryTypeIndex].propertyFlags;</div>
-<div class="line"><a name="l12809"></a><span class="lineno">12809</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> isHostVisible = (memPropFlags &amp; VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0;</div>
-<div class="line"><a name="l12810"></a><span class="lineno">12810</span>&#160; </div>
-<div class="line"><a name="l12811"></a><span class="lineno">12811</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> canDefragmentOnCpu = maxCpuBytesToMove &gt; 0 &amp;&amp; maxCpuAllocationsToMove &gt; 0 &amp;&amp;</div>
-<div class="line"><a name="l12812"></a><span class="lineno">12812</span>&#160;        isHostVisible;</div>
-<div class="line"><a name="l12813"></a><span class="lineno">12813</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> canDefragmentOnGpu = maxGpuBytesToMove &gt; 0 &amp;&amp; maxGpuAllocationsToMove &gt; 0 &amp;&amp;</div>
-<div class="line"><a name="l12814"></a><span class="lineno">12814</span>&#160;        !IsCorruptionDetectionEnabled() &amp;&amp;</div>
-<div class="line"><a name="l12815"></a><span class="lineno">12815</span>&#160;        ((1u &lt;&lt; m_MemoryTypeIndex) &amp; m_hAllocator-&gt;GetGpuDefragmentationMemoryTypeBits()) != 0;</div>
+<div class="line"><a name="l12774"></a><span class="lineno">12774</span>&#160; </div>
+<div class="line"><a name="l12775"></a><span class="lineno">12775</span>&#160;        <span class="keywordflow">if</span>(m_Algorithm != 0)</div>
+<div class="line"><a name="l12776"></a><span class="lineno">12776</span>&#160;        {</div>
+<div class="line"><a name="l12777"></a><span class="lineno">12777</span>&#160;            json.WriteString(<span class="stringliteral">&quot;Algorithm&quot;</span>);</div>
+<div class="line"><a name="l12778"></a><span class="lineno">12778</span>&#160;            json.WriteString(VmaAlgorithmToStr(m_Algorithm));</div>
+<div class="line"><a name="l12779"></a><span class="lineno">12779</span>&#160;        }</div>
+<div class="line"><a name="l12780"></a><span class="lineno">12780</span>&#160;    }</div>
+<div class="line"><a name="l12781"></a><span class="lineno">12781</span>&#160;    <span class="keywordflow">else</span></div>
+<div class="line"><a name="l12782"></a><span class="lineno">12782</span>&#160;    {</div>
+<div class="line"><a name="l12783"></a><span class="lineno">12783</span>&#160;        json.WriteString(<span class="stringliteral">&quot;PreferredBlockSize&quot;</span>);</div>
+<div class="line"><a name="l12784"></a><span class="lineno">12784</span>&#160;        json.WriteNumber(m_PreferredBlockSize);</div>
+<div class="line"><a name="l12785"></a><span class="lineno">12785</span>&#160;    }</div>
+<div class="line"><a name="l12786"></a><span class="lineno">12786</span>&#160; </div>
+<div class="line"><a name="l12787"></a><span class="lineno">12787</span>&#160;    json.WriteString(<span class="stringliteral">&quot;Blocks&quot;</span>);</div>
+<div class="line"><a name="l12788"></a><span class="lineno">12788</span>&#160;    json.BeginObject();</div>
+<div class="line"><a name="l12789"></a><span class="lineno">12789</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 0; i &lt; m_Blocks.size(); ++i)</div>
+<div class="line"><a name="l12790"></a><span class="lineno">12790</span>&#160;    {</div>
+<div class="line"><a name="l12791"></a><span class="lineno">12791</span>&#160;        json.BeginString();</div>
+<div class="line"><a name="l12792"></a><span class="lineno">12792</span>&#160;        json.ContinueString(m_Blocks[i]-&gt;GetId());</div>
+<div class="line"><a name="l12793"></a><span class="lineno">12793</span>&#160;        json.EndString();</div>
+<div class="line"><a name="l12794"></a><span class="lineno">12794</span>&#160; </div>
+<div class="line"><a name="l12795"></a><span class="lineno">12795</span>&#160;        m_Blocks[i]-&gt;m_pMetadata-&gt;PrintDetailedMap(json);</div>
+<div class="line"><a name="l12796"></a><span class="lineno">12796</span>&#160;    }</div>
+<div class="line"><a name="l12797"></a><span class="lineno">12797</span>&#160;    json.EndObject();</div>
+<div class="line"><a name="l12798"></a><span class="lineno">12798</span>&#160; </div>
+<div class="line"><a name="l12799"></a><span class="lineno">12799</span>&#160;    json.EndObject();</div>
+<div class="line"><a name="l12800"></a><span class="lineno">12800</span>&#160;}</div>
+<div class="line"><a name="l12801"></a><span class="lineno">12801</span>&#160; </div>
+<div class="line"><a name="l12802"></a><span class="lineno">12802</span>&#160;<span class="preprocessor">#endif // #if VMA_STATS_STRING_ENABLED</span></div>
+<div class="line"><a name="l12803"></a><span class="lineno">12803</span>&#160; </div>
+<div class="line"><a name="l12804"></a><span class="lineno">12804</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::Defragment(</div>
+<div class="line"><a name="l12805"></a><span class="lineno">12805</span>&#160;    <span class="keyword">class</span> VmaBlockVectorDefragmentationContext* pCtx,</div>
+<div class="line"><a name="l12806"></a><span class="lineno">12806</span>&#160;    <a class="code" href="struct_vma_defragmentation_stats.html">VmaDefragmentationStats</a>* pStats,</div>
+<div class="line"><a name="l12807"></a><span class="lineno">12807</span>&#160;    VkDeviceSize&amp; maxCpuBytesToMove, uint32_t&amp; maxCpuAllocationsToMove,</div>
+<div class="line"><a name="l12808"></a><span class="lineno">12808</span>&#160;    VkDeviceSize&amp; maxGpuBytesToMove, uint32_t&amp; maxGpuAllocationsToMove,</div>
+<div class="line"><a name="l12809"></a><span class="lineno">12809</span>&#160;    VkCommandBuffer commandBuffer)</div>
+<div class="line"><a name="l12810"></a><span class="lineno">12810</span>&#160;{</div>
+<div class="line"><a name="l12811"></a><span class="lineno">12811</span>&#160;    pCtx-&gt;res = VK_SUCCESS;</div>
+<div class="line"><a name="l12812"></a><span class="lineno">12812</span>&#160;    </div>
+<div class="line"><a name="l12813"></a><span class="lineno">12813</span>&#160;    <span class="keyword">const</span> VkMemoryPropertyFlags memPropFlags =</div>
+<div class="line"><a name="l12814"></a><span class="lineno">12814</span>&#160;        m_hAllocator-&gt;m_MemProps.memoryTypes[m_MemoryTypeIndex].propertyFlags;</div>
+<div class="line"><a name="l12815"></a><span class="lineno">12815</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> isHostVisible = (memPropFlags &amp; VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0;</div>
 <div class="line"><a name="l12816"></a><span class="lineno">12816</span>&#160; </div>
-<div class="line"><a name="l12817"></a><span class="lineno">12817</span>&#160;    <span class="comment">// There are options to defragment this memory type.</span></div>
-<div class="line"><a name="l12818"></a><span class="lineno">12818</span>&#160;    <span class="keywordflow">if</span>(canDefragmentOnCpu || canDefragmentOnGpu)</div>
-<div class="line"><a name="l12819"></a><span class="lineno">12819</span>&#160;    {</div>
-<div class="line"><a name="l12820"></a><span class="lineno">12820</span>&#160;        <span class="keywordtype">bool</span> defragmentOnGpu;</div>
-<div class="line"><a name="l12821"></a><span class="lineno">12821</span>&#160;        <span class="comment">// There is only one option to defragment this memory type.</span></div>
-<div class="line"><a name="l12822"></a><span class="lineno">12822</span>&#160;        <span class="keywordflow">if</span>(canDefragmentOnGpu != canDefragmentOnCpu)</div>
-<div class="line"><a name="l12823"></a><span class="lineno">12823</span>&#160;        {</div>
-<div class="line"><a name="l12824"></a><span class="lineno">12824</span>&#160;            defragmentOnGpu = canDefragmentOnGpu;</div>
-<div class="line"><a name="l12825"></a><span class="lineno">12825</span>&#160;        }</div>
-<div class="line"><a name="l12826"></a><span class="lineno">12826</span>&#160;        <span class="comment">// Both options are available: Heuristics to choose the best one.</span></div>
-<div class="line"><a name="l12827"></a><span class="lineno">12827</span>&#160;        <span class="keywordflow">else</span></div>
-<div class="line"><a name="l12828"></a><span class="lineno">12828</span>&#160;        {</div>
-<div class="line"><a name="l12829"></a><span class="lineno">12829</span>&#160;            defragmentOnGpu = (memPropFlags &amp; VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) != 0 ||</div>
-<div class="line"><a name="l12830"></a><span class="lineno">12830</span>&#160;                m_hAllocator-&gt;IsIntegratedGpu();</div>
+<div class="line"><a name="l12817"></a><span class="lineno">12817</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> canDefragmentOnCpu = maxCpuBytesToMove &gt; 0 &amp;&amp; maxCpuAllocationsToMove &gt; 0 &amp;&amp;</div>
+<div class="line"><a name="l12818"></a><span class="lineno">12818</span>&#160;        isHostVisible;</div>
+<div class="line"><a name="l12819"></a><span class="lineno">12819</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> canDefragmentOnGpu = maxGpuBytesToMove &gt; 0 &amp;&amp; maxGpuAllocationsToMove &gt; 0 &amp;&amp;</div>
+<div class="line"><a name="l12820"></a><span class="lineno">12820</span>&#160;        !IsCorruptionDetectionEnabled() &amp;&amp;</div>
+<div class="line"><a name="l12821"></a><span class="lineno">12821</span>&#160;        ((1u &lt;&lt; m_MemoryTypeIndex) &amp; m_hAllocator-&gt;GetGpuDefragmentationMemoryTypeBits()) != 0;</div>
+<div class="line"><a name="l12822"></a><span class="lineno">12822</span>&#160; </div>
+<div class="line"><a name="l12823"></a><span class="lineno">12823</span>&#160;    <span class="comment">// There are options to defragment this memory type.</span></div>
+<div class="line"><a name="l12824"></a><span class="lineno">12824</span>&#160;    <span class="keywordflow">if</span>(canDefragmentOnCpu || canDefragmentOnGpu)</div>
+<div class="line"><a name="l12825"></a><span class="lineno">12825</span>&#160;    {</div>
+<div class="line"><a name="l12826"></a><span class="lineno">12826</span>&#160;        <span class="keywordtype">bool</span> defragmentOnGpu;</div>
+<div class="line"><a name="l12827"></a><span class="lineno">12827</span>&#160;        <span class="comment">// There is only one option to defragment this memory type.</span></div>
+<div class="line"><a name="l12828"></a><span class="lineno">12828</span>&#160;        <span class="keywordflow">if</span>(canDefragmentOnGpu != canDefragmentOnCpu)</div>
+<div class="line"><a name="l12829"></a><span class="lineno">12829</span>&#160;        {</div>
+<div class="line"><a name="l12830"></a><span class="lineno">12830</span>&#160;            defragmentOnGpu = canDefragmentOnGpu;</div>
 <div class="line"><a name="l12831"></a><span class="lineno">12831</span>&#160;        }</div>
-<div class="line"><a name="l12832"></a><span class="lineno">12832</span>&#160; </div>
-<div class="line"><a name="l12833"></a><span class="lineno">12833</span>&#160;        <span class="keywordtype">bool</span> overlappingMoveSupported = !defragmentOnGpu;</div>
-<div class="line"><a name="l12834"></a><span class="lineno">12834</span>&#160; </div>
-<div class="line"><a name="l12835"></a><span class="lineno">12835</span>&#160;        <span class="keywordflow">if</span>(m_hAllocator-&gt;m_UseMutex)</div>
-<div class="line"><a name="l12836"></a><span class="lineno">12836</span>&#160;        {</div>
-<div class="line"><a name="l12837"></a><span class="lineno">12837</span>&#160;            m_Mutex.LockWrite();</div>
-<div class="line"><a name="l12838"></a><span class="lineno">12838</span>&#160;            pCtx-&gt;mutexLocked = <span class="keyword">true</span>;</div>
-<div class="line"><a name="l12839"></a><span class="lineno">12839</span>&#160;        }</div>
+<div class="line"><a name="l12832"></a><span class="lineno">12832</span>&#160;        <span class="comment">// Both options are available: Heuristics to choose the best one.</span></div>
+<div class="line"><a name="l12833"></a><span class="lineno">12833</span>&#160;        <span class="keywordflow">else</span></div>
+<div class="line"><a name="l12834"></a><span class="lineno">12834</span>&#160;        {</div>
+<div class="line"><a name="l12835"></a><span class="lineno">12835</span>&#160;            defragmentOnGpu = (memPropFlags &amp; VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) != 0 ||</div>
+<div class="line"><a name="l12836"></a><span class="lineno">12836</span>&#160;                m_hAllocator-&gt;IsIntegratedGpu();</div>
+<div class="line"><a name="l12837"></a><span class="lineno">12837</span>&#160;        }</div>
+<div class="line"><a name="l12838"></a><span class="lineno">12838</span>&#160; </div>
+<div class="line"><a name="l12839"></a><span class="lineno">12839</span>&#160;        <span class="keywordtype">bool</span> overlappingMoveSupported = !defragmentOnGpu;</div>
 <div class="line"><a name="l12840"></a><span class="lineno">12840</span>&#160; </div>
-<div class="line"><a name="l12841"></a><span class="lineno">12841</span>&#160;        pCtx-&gt;Begin(overlappingMoveSupported);</div>
-<div class="line"><a name="l12842"></a><span class="lineno">12842</span>&#160; </div>
-<div class="line"><a name="l12843"></a><span class="lineno">12843</span>&#160;        <span class="comment">// Defragment.</span></div>
-<div class="line"><a name="l12844"></a><span class="lineno">12844</span>&#160; </div>
-<div class="line"><a name="l12845"></a><span class="lineno">12845</span>&#160;        <span class="keyword">const</span> VkDeviceSize maxBytesToMove = defragmentOnGpu ? maxGpuBytesToMove : maxCpuBytesToMove;</div>
-<div class="line"><a name="l12846"></a><span class="lineno">12846</span>&#160;        <span class="keyword">const</span> uint32_t maxAllocationsToMove = defragmentOnGpu ? maxGpuAllocationsToMove : maxCpuAllocationsToMove;</div>
-<div class="line"><a name="l12847"></a><span class="lineno">12847</span>&#160;        VmaVector&lt; VmaDefragmentationMove, VmaStlAllocator&lt;VmaDefragmentationMove&gt; &gt; moves = </div>
-<div class="line"><a name="l12848"></a><span class="lineno">12848</span>&#160;            VmaVector&lt; VmaDefragmentationMove, VmaStlAllocator&lt;VmaDefragmentationMove&gt; &gt;(VmaStlAllocator&lt;VmaDefragmentationMove&gt;(m_hAllocator-&gt;GetAllocationCallbacks()));</div>
-<div class="line"><a name="l12849"></a><span class="lineno">12849</span>&#160;        pCtx-&gt;res = pCtx-&gt;GetAlgorithm()-&gt;Defragment(moves, maxBytesToMove, maxAllocationsToMove);</div>
+<div class="line"><a name="l12841"></a><span class="lineno">12841</span>&#160;        <span class="keywordflow">if</span>(m_hAllocator-&gt;m_UseMutex)</div>
+<div class="line"><a name="l12842"></a><span class="lineno">12842</span>&#160;        {</div>
+<div class="line"><a name="l12843"></a><span class="lineno">12843</span>&#160;            m_Mutex.LockWrite();</div>
+<div class="line"><a name="l12844"></a><span class="lineno">12844</span>&#160;            pCtx-&gt;mutexLocked = <span class="keyword">true</span>;</div>
+<div class="line"><a name="l12845"></a><span class="lineno">12845</span>&#160;        }</div>
+<div class="line"><a name="l12846"></a><span class="lineno">12846</span>&#160; </div>
+<div class="line"><a name="l12847"></a><span class="lineno">12847</span>&#160;        pCtx-&gt;Begin(overlappingMoveSupported);</div>
+<div class="line"><a name="l12848"></a><span class="lineno">12848</span>&#160; </div>
+<div class="line"><a name="l12849"></a><span class="lineno">12849</span>&#160;        <span class="comment">// Defragment.</span></div>
 <div class="line"><a name="l12850"></a><span class="lineno">12850</span>&#160; </div>
-<div class="line"><a name="l12851"></a><span class="lineno">12851</span>&#160;        <span class="comment">// Accumulate statistics.</span></div>
-<div class="line"><a name="l12852"></a><span class="lineno">12852</span>&#160;        <span class="keywordflow">if</span>(pStats != VMA_NULL)</div>
-<div class="line"><a name="l12853"></a><span class="lineno">12853</span>&#160;        {</div>
-<div class="line"><a name="l12854"></a><span class="lineno">12854</span>&#160;            <span class="keyword">const</span> VkDeviceSize bytesMoved = pCtx-&gt;GetAlgorithm()-&gt;GetBytesMoved();</div>
-<div class="line"><a name="l12855"></a><span class="lineno">12855</span>&#160;            <span class="keyword">const</span> uint32_t allocationsMoved = pCtx-&gt;GetAlgorithm()-&gt;GetAllocationsMoved();</div>
-<div class="line"><a name="l12856"></a><span class="lineno">12856</span>&#160;            pStats-&gt;<a class="code" href="struct_vma_defragmentation_stats.html#a36f9d5df2a10ba2a36b16e126d60572d">bytesMoved</a> += bytesMoved;</div>
-<div class="line"><a name="l12857"></a><span class="lineno">12857</span>&#160;            pStats-&gt;<a class="code" href="struct_vma_defragmentation_stats.html#aefeabf130022008eadd75999478af3f9">allocationsMoved</a> += allocationsMoved;</div>
-<div class="line"><a name="l12858"></a><span class="lineno">12858</span>&#160;            VMA_ASSERT(bytesMoved &lt;= maxBytesToMove);</div>
-<div class="line"><a name="l12859"></a><span class="lineno">12859</span>&#160;            VMA_ASSERT(allocationsMoved &lt;= maxAllocationsToMove);</div>
-<div class="line"><a name="l12860"></a><span class="lineno">12860</span>&#160;            <span class="keywordflow">if</span>(defragmentOnGpu)</div>
-<div class="line"><a name="l12861"></a><span class="lineno">12861</span>&#160;            {</div>
-<div class="line"><a name="l12862"></a><span class="lineno">12862</span>&#160;                maxGpuBytesToMove -= bytesMoved;</div>
-<div class="line"><a name="l12863"></a><span class="lineno">12863</span>&#160;                maxGpuAllocationsToMove -= allocationsMoved;</div>
-<div class="line"><a name="l12864"></a><span class="lineno">12864</span>&#160;            }</div>
-<div class="line"><a name="l12865"></a><span class="lineno">12865</span>&#160;            <span class="keywordflow">else</span></div>
-<div class="line"><a name="l12866"></a><span class="lineno">12866</span>&#160;            {</div>
-<div class="line"><a name="l12867"></a><span class="lineno">12867</span>&#160;                maxCpuBytesToMove -= bytesMoved;</div>
-<div class="line"><a name="l12868"></a><span class="lineno">12868</span>&#160;                maxCpuAllocationsToMove -= allocationsMoved;</div>
-<div class="line"><a name="l12869"></a><span class="lineno">12869</span>&#160;            }</div>
-<div class="line"><a name="l12870"></a><span class="lineno">12870</span>&#160;        }</div>
-<div class="line"><a name="l12871"></a><span class="lineno">12871</span>&#160;    </div>
-<div class="line"><a name="l12872"></a><span class="lineno">12872</span>&#160;        <span class="keywordflow">if</span>(pCtx-&gt;res &gt;= VK_SUCCESS)</div>
-<div class="line"><a name="l12873"></a><span class="lineno">12873</span>&#160;        {</div>
-<div class="line"><a name="l12874"></a><span class="lineno">12874</span>&#160;            <span class="keywordflow">if</span>(defragmentOnGpu)</div>
-<div class="line"><a name="l12875"></a><span class="lineno">12875</span>&#160;            {</div>
-<div class="line"><a name="l12876"></a><span class="lineno">12876</span>&#160;                ApplyDefragmentationMovesGpu(pCtx, moves, commandBuffer);</div>
-<div class="line"><a name="l12877"></a><span class="lineno">12877</span>&#160;            }</div>
-<div class="line"><a name="l12878"></a><span class="lineno">12878</span>&#160;            <span class="keywordflow">else</span></div>
-<div class="line"><a name="l12879"></a><span class="lineno">12879</span>&#160;            {</div>
-<div class="line"><a name="l12880"></a><span class="lineno">12880</span>&#160;                ApplyDefragmentationMovesCpu(pCtx, moves);</div>
-<div class="line"><a name="l12881"></a><span class="lineno">12881</span>&#160;            }</div>
-<div class="line"><a name="l12882"></a><span class="lineno">12882</span>&#160;        }</div>
-<div class="line"><a name="l12883"></a><span class="lineno">12883</span>&#160;    }</div>
-<div class="line"><a name="l12884"></a><span class="lineno">12884</span>&#160;}</div>
-<div class="line"><a name="l12885"></a><span class="lineno">12885</span>&#160; </div>
-<div class="line"><a name="l12886"></a><span class="lineno">12886</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::DefragmentationEnd(</div>
-<div class="line"><a name="l12887"></a><span class="lineno">12887</span>&#160;    <span class="keyword">class</span> VmaBlockVectorDefragmentationContext* pCtx,</div>
-<div class="line"><a name="l12888"></a><span class="lineno">12888</span>&#160;    <a class="code" href="struct_vma_defragmentation_stats.html">VmaDefragmentationStats</a>* pStats)</div>
-<div class="line"><a name="l12889"></a><span class="lineno">12889</span>&#160;{</div>
-<div class="line"><a name="l12890"></a><span class="lineno">12890</span>&#160;    <span class="comment">// Destroy buffers.</span></div>
-<div class="line"><a name="l12891"></a><span class="lineno">12891</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = pCtx-&gt;blockContexts.size(); blockIndex--; )</div>
-<div class="line"><a name="l12892"></a><span class="lineno">12892</span>&#160;    {</div>
-<div class="line"><a name="l12893"></a><span class="lineno">12893</span>&#160;        VmaBlockDefragmentationContext&amp; blockCtx = pCtx-&gt;blockContexts[blockIndex];</div>
-<div class="line"><a name="l12894"></a><span class="lineno">12894</span>&#160;        <span class="keywordflow">if</span>(blockCtx.hBuffer)</div>
-<div class="line"><a name="l12895"></a><span class="lineno">12895</span>&#160;        {</div>
-<div class="line"><a name="l12896"></a><span class="lineno">12896</span>&#160;            (*m_hAllocator-&gt;GetVulkanFunctions().vkDestroyBuffer)(</div>
-<div class="line"><a name="l12897"></a><span class="lineno">12897</span>&#160;                m_hAllocator-&gt;m_hDevice, blockCtx.hBuffer, m_hAllocator-&gt;GetAllocationCallbacks());</div>
-<div class="line"><a name="l12898"></a><span class="lineno">12898</span>&#160;        }</div>
-<div class="line"><a name="l12899"></a><span class="lineno">12899</span>&#160;    }</div>
-<div class="line"><a name="l12900"></a><span class="lineno">12900</span>&#160; </div>
-<div class="line"><a name="l12901"></a><span class="lineno">12901</span>&#160;    <span class="keywordflow">if</span>(pCtx-&gt;res &gt;= VK_SUCCESS)</div>
-<div class="line"><a name="l12902"></a><span class="lineno">12902</span>&#160;    {</div>
-<div class="line"><a name="l12903"></a><span class="lineno">12903</span>&#160;        FreeEmptyBlocks(pStats);</div>
-<div class="line"><a name="l12904"></a><span class="lineno">12904</span>&#160;    }</div>
-<div class="line"><a name="l12905"></a><span class="lineno">12905</span>&#160; </div>
-<div class="line"><a name="l12906"></a><span class="lineno">12906</span>&#160;    <span class="keywordflow">if</span>(pCtx-&gt;mutexLocked)</div>
-<div class="line"><a name="l12907"></a><span class="lineno">12907</span>&#160;    {</div>
-<div class="line"><a name="l12908"></a><span class="lineno">12908</span>&#160;        VMA_ASSERT(m_hAllocator-&gt;m_UseMutex);</div>
-<div class="line"><a name="l12909"></a><span class="lineno">12909</span>&#160;        m_Mutex.UnlockWrite();</div>
+<div class="line"><a name="l12851"></a><span class="lineno">12851</span>&#160;        <span class="keyword">const</span> VkDeviceSize maxBytesToMove = defragmentOnGpu ? maxGpuBytesToMove : maxCpuBytesToMove;</div>
+<div class="line"><a name="l12852"></a><span class="lineno">12852</span>&#160;        <span class="keyword">const</span> uint32_t maxAllocationsToMove = defragmentOnGpu ? maxGpuAllocationsToMove : maxCpuAllocationsToMove;</div>
+<div class="line"><a name="l12853"></a><span class="lineno">12853</span>&#160;        VmaVector&lt; VmaDefragmentationMove, VmaStlAllocator&lt;VmaDefragmentationMove&gt; &gt; moves = </div>
+<div class="line"><a name="l12854"></a><span class="lineno">12854</span>&#160;            VmaVector&lt; VmaDefragmentationMove, VmaStlAllocator&lt;VmaDefragmentationMove&gt; &gt;(VmaStlAllocator&lt;VmaDefragmentationMove&gt;(m_hAllocator-&gt;GetAllocationCallbacks()));</div>
+<div class="line"><a name="l12855"></a><span class="lineno">12855</span>&#160;        pCtx-&gt;res = pCtx-&gt;GetAlgorithm()-&gt;Defragment(moves, maxBytesToMove, maxAllocationsToMove);</div>
+<div class="line"><a name="l12856"></a><span class="lineno">12856</span>&#160; </div>
+<div class="line"><a name="l12857"></a><span class="lineno">12857</span>&#160;        <span class="comment">// Accumulate statistics.</span></div>
+<div class="line"><a name="l12858"></a><span class="lineno">12858</span>&#160;        <span class="keywordflow">if</span>(pStats != VMA_NULL)</div>
+<div class="line"><a name="l12859"></a><span class="lineno">12859</span>&#160;        {</div>
+<div class="line"><a name="l12860"></a><span class="lineno">12860</span>&#160;            <span class="keyword">const</span> VkDeviceSize bytesMoved = pCtx-&gt;GetAlgorithm()-&gt;GetBytesMoved();</div>
+<div class="line"><a name="l12861"></a><span class="lineno">12861</span>&#160;            <span class="keyword">const</span> uint32_t allocationsMoved = pCtx-&gt;GetAlgorithm()-&gt;GetAllocationsMoved();</div>
+<div class="line"><a name="l12862"></a><span class="lineno">12862</span>&#160;            pStats-&gt;<a class="code" href="struct_vma_defragmentation_stats.html#a36f9d5df2a10ba2a36b16e126d60572d">bytesMoved</a> += bytesMoved;</div>
+<div class="line"><a name="l12863"></a><span class="lineno">12863</span>&#160;            pStats-&gt;<a class="code" href="struct_vma_defragmentation_stats.html#aefeabf130022008eadd75999478af3f9">allocationsMoved</a> += allocationsMoved;</div>
+<div class="line"><a name="l12864"></a><span class="lineno">12864</span>&#160;            VMA_ASSERT(bytesMoved &lt;= maxBytesToMove);</div>
+<div class="line"><a name="l12865"></a><span class="lineno">12865</span>&#160;            VMA_ASSERT(allocationsMoved &lt;= maxAllocationsToMove);</div>
+<div class="line"><a name="l12866"></a><span class="lineno">12866</span>&#160;            <span class="keywordflow">if</span>(defragmentOnGpu)</div>
+<div class="line"><a name="l12867"></a><span class="lineno">12867</span>&#160;            {</div>
+<div class="line"><a name="l12868"></a><span class="lineno">12868</span>&#160;                maxGpuBytesToMove -= bytesMoved;</div>
+<div class="line"><a name="l12869"></a><span class="lineno">12869</span>&#160;                maxGpuAllocationsToMove -= allocationsMoved;</div>
+<div class="line"><a name="l12870"></a><span class="lineno">12870</span>&#160;            }</div>
+<div class="line"><a name="l12871"></a><span class="lineno">12871</span>&#160;            <span class="keywordflow">else</span></div>
+<div class="line"><a name="l12872"></a><span class="lineno">12872</span>&#160;            {</div>
+<div class="line"><a name="l12873"></a><span class="lineno">12873</span>&#160;                maxCpuBytesToMove -= bytesMoved;</div>
+<div class="line"><a name="l12874"></a><span class="lineno">12874</span>&#160;                maxCpuAllocationsToMove -= allocationsMoved;</div>
+<div class="line"><a name="l12875"></a><span class="lineno">12875</span>&#160;            }</div>
+<div class="line"><a name="l12876"></a><span class="lineno">12876</span>&#160;        }</div>
+<div class="line"><a name="l12877"></a><span class="lineno">12877</span>&#160;    </div>
+<div class="line"><a name="l12878"></a><span class="lineno">12878</span>&#160;        <span class="keywordflow">if</span>(pCtx-&gt;res &gt;= VK_SUCCESS)</div>
+<div class="line"><a name="l12879"></a><span class="lineno">12879</span>&#160;        {</div>
+<div class="line"><a name="l12880"></a><span class="lineno">12880</span>&#160;            <span class="keywordflow">if</span>(defragmentOnGpu)</div>
+<div class="line"><a name="l12881"></a><span class="lineno">12881</span>&#160;            {</div>
+<div class="line"><a name="l12882"></a><span class="lineno">12882</span>&#160;                ApplyDefragmentationMovesGpu(pCtx, moves, commandBuffer);</div>
+<div class="line"><a name="l12883"></a><span class="lineno">12883</span>&#160;            }</div>
+<div class="line"><a name="l12884"></a><span class="lineno">12884</span>&#160;            <span class="keywordflow">else</span></div>
+<div class="line"><a name="l12885"></a><span class="lineno">12885</span>&#160;            {</div>
+<div class="line"><a name="l12886"></a><span class="lineno">12886</span>&#160;                ApplyDefragmentationMovesCpu(pCtx, moves);</div>
+<div class="line"><a name="l12887"></a><span class="lineno">12887</span>&#160;            }</div>
+<div class="line"><a name="l12888"></a><span class="lineno">12888</span>&#160;        }</div>
+<div class="line"><a name="l12889"></a><span class="lineno">12889</span>&#160;    }</div>
+<div class="line"><a name="l12890"></a><span class="lineno">12890</span>&#160;}</div>
+<div class="line"><a name="l12891"></a><span class="lineno">12891</span>&#160; </div>
+<div class="line"><a name="l12892"></a><span class="lineno">12892</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::DefragmentationEnd(</div>
+<div class="line"><a name="l12893"></a><span class="lineno">12893</span>&#160;    <span class="keyword">class</span> VmaBlockVectorDefragmentationContext* pCtx,</div>
+<div class="line"><a name="l12894"></a><span class="lineno">12894</span>&#160;    <a class="code" href="struct_vma_defragmentation_stats.html">VmaDefragmentationStats</a>* pStats)</div>
+<div class="line"><a name="l12895"></a><span class="lineno">12895</span>&#160;{</div>
+<div class="line"><a name="l12896"></a><span class="lineno">12896</span>&#160;    <span class="comment">// Destroy buffers.</span></div>
+<div class="line"><a name="l12897"></a><span class="lineno">12897</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = pCtx-&gt;blockContexts.size(); blockIndex--; )</div>
+<div class="line"><a name="l12898"></a><span class="lineno">12898</span>&#160;    {</div>
+<div class="line"><a name="l12899"></a><span class="lineno">12899</span>&#160;        VmaBlockDefragmentationContext&amp; blockCtx = pCtx-&gt;blockContexts[blockIndex];</div>
+<div class="line"><a name="l12900"></a><span class="lineno">12900</span>&#160;        <span class="keywordflow">if</span>(blockCtx.hBuffer)</div>
+<div class="line"><a name="l12901"></a><span class="lineno">12901</span>&#160;        {</div>
+<div class="line"><a name="l12902"></a><span class="lineno">12902</span>&#160;            (*m_hAllocator-&gt;GetVulkanFunctions().vkDestroyBuffer)(</div>
+<div class="line"><a name="l12903"></a><span class="lineno">12903</span>&#160;                m_hAllocator-&gt;m_hDevice, blockCtx.hBuffer, m_hAllocator-&gt;GetAllocationCallbacks());</div>
+<div class="line"><a name="l12904"></a><span class="lineno">12904</span>&#160;        }</div>
+<div class="line"><a name="l12905"></a><span class="lineno">12905</span>&#160;    }</div>
+<div class="line"><a name="l12906"></a><span class="lineno">12906</span>&#160; </div>
+<div class="line"><a name="l12907"></a><span class="lineno">12907</span>&#160;    <span class="keywordflow">if</span>(pCtx-&gt;res &gt;= VK_SUCCESS)</div>
+<div class="line"><a name="l12908"></a><span class="lineno">12908</span>&#160;    {</div>
+<div class="line"><a name="l12909"></a><span class="lineno">12909</span>&#160;        FreeEmptyBlocks(pStats);</div>
 <div class="line"><a name="l12910"></a><span class="lineno">12910</span>&#160;    }</div>
-<div class="line"><a name="l12911"></a><span class="lineno">12911</span>&#160;}</div>
-<div class="line"><a name="l12912"></a><span class="lineno">12912</span>&#160; </div>
-<div class="line"><a name="l12913"></a><span class="lineno">12913</span>&#160;<span class="keywordtype">size_t</span> VmaBlockVector::CalcAllocationCount()<span class="keyword"> const</span></div>
-<div class="line"><a name="l12914"></a><span class="lineno">12914</span>&#160;<span class="keyword"></span>{</div>
-<div class="line"><a name="l12915"></a><span class="lineno">12915</span>&#160;    <span class="keywordtype">size_t</span> result = 0;</div>
-<div class="line"><a name="l12916"></a><span class="lineno">12916</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 0; i &lt; m_Blocks.size(); ++i)</div>
-<div class="line"><a name="l12917"></a><span class="lineno">12917</span>&#160;    {</div>
-<div class="line"><a name="l12918"></a><span class="lineno">12918</span>&#160;        result += m_Blocks[i]-&gt;m_pMetadata-&gt;GetAllocationCount();</div>
-<div class="line"><a name="l12919"></a><span class="lineno">12919</span>&#160;    }</div>
-<div class="line"><a name="l12920"></a><span class="lineno">12920</span>&#160;    <span class="keywordflow">return</span> result;</div>
-<div class="line"><a name="l12921"></a><span class="lineno">12921</span>&#160;}</div>
-<div class="line"><a name="l12922"></a><span class="lineno">12922</span>&#160; </div>
-<div class="line"><a name="l12923"></a><span class="lineno">12923</span>&#160;<span class="keywordtype">bool</span> VmaBlockVector::IsBufferImageGranularityConflictPossible()<span class="keyword"> const</span></div>
-<div class="line"><a name="l12924"></a><span class="lineno">12924</span>&#160;<span class="keyword"></span>{</div>
-<div class="line"><a name="l12925"></a><span class="lineno">12925</span>&#160;    <span class="keywordflow">if</span>(m_BufferImageGranularity == 1)</div>
-<div class="line"><a name="l12926"></a><span class="lineno">12926</span>&#160;    {</div>
-<div class="line"><a name="l12927"></a><span class="lineno">12927</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
-<div class="line"><a name="l12928"></a><span class="lineno">12928</span>&#160;    }</div>
-<div class="line"><a name="l12929"></a><span class="lineno">12929</span>&#160;    VmaSuballocationType lastSuballocType = VMA_SUBALLOCATION_TYPE_FREE;</div>
-<div class="line"><a name="l12930"></a><span class="lineno">12930</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 0, count = m_Blocks.size(); i &lt; count; ++i)</div>
-<div class="line"><a name="l12931"></a><span class="lineno">12931</span>&#160;    {</div>
-<div class="line"><a name="l12932"></a><span class="lineno">12932</span>&#160;        VmaDeviceMemoryBlock* <span class="keyword">const</span> pBlock = m_Blocks[i];</div>
-<div class="line"><a name="l12933"></a><span class="lineno">12933</span>&#160;        VMA_ASSERT(m_Algorithm == 0);</div>
-<div class="line"><a name="l12934"></a><span class="lineno">12934</span>&#160;        VmaBlockMetadata_Generic* <span class="keyword">const</span> pMetadata = (VmaBlockMetadata_Generic*)pBlock-&gt;m_pMetadata;</div>
-<div class="line"><a name="l12935"></a><span class="lineno">12935</span>&#160;        <span class="keywordflow">if</span>(pMetadata-&gt;IsBufferImageGranularityConflictPossible(m_BufferImageGranularity, lastSuballocType))</div>
-<div class="line"><a name="l12936"></a><span class="lineno">12936</span>&#160;        {</div>
-<div class="line"><a name="l12937"></a><span class="lineno">12937</span>&#160;            <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
-<div class="line"><a name="l12938"></a><span class="lineno">12938</span>&#160;        }</div>
-<div class="line"><a name="l12939"></a><span class="lineno">12939</span>&#160;    }</div>
-<div class="line"><a name="l12940"></a><span class="lineno">12940</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
-<div class="line"><a name="l12941"></a><span class="lineno">12941</span>&#160;}</div>
-<div class="line"><a name="l12942"></a><span class="lineno">12942</span>&#160; </div>
-<div class="line"><a name="l12943"></a><span class="lineno">12943</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::MakePoolAllocationsLost(</div>
-<div class="line"><a name="l12944"></a><span class="lineno">12944</span>&#160;    uint32_t currentFrameIndex,</div>
-<div class="line"><a name="l12945"></a><span class="lineno">12945</span>&#160;    <span class="keywordtype">size_t</span>* pLostAllocationCount)</div>
-<div class="line"><a name="l12946"></a><span class="lineno">12946</span>&#160;{</div>
-<div class="line"><a name="l12947"></a><span class="lineno">12947</span>&#160;    VmaMutexLockWrite lock(m_Mutex, m_hAllocator-&gt;m_UseMutex);</div>
-<div class="line"><a name="l12948"></a><span class="lineno">12948</span>&#160;    <span class="keywordtype">size_t</span> lostAllocationCount = 0;</div>
-<div class="line"><a name="l12949"></a><span class="lineno">12949</span>&#160;    <span class="keywordflow">for</span>(uint32_t blockIndex = 0; blockIndex &lt; m_Blocks.size(); ++blockIndex)</div>
-<div class="line"><a name="l12950"></a><span class="lineno">12950</span>&#160;    {</div>
-<div class="line"><a name="l12951"></a><span class="lineno">12951</span>&#160;        VmaDeviceMemoryBlock* <span class="keyword">const</span> pBlock = m_Blocks[blockIndex];</div>
-<div class="line"><a name="l12952"></a><span class="lineno">12952</span>&#160;        VMA_ASSERT(pBlock);</div>
-<div class="line"><a name="l12953"></a><span class="lineno">12953</span>&#160;        lostAllocationCount += pBlock-&gt;m_pMetadata-&gt;MakeAllocationsLost(currentFrameIndex, m_FrameInUseCount);</div>
-<div class="line"><a name="l12954"></a><span class="lineno">12954</span>&#160;    }</div>
-<div class="line"><a name="l12955"></a><span class="lineno">12955</span>&#160;    <span class="keywordflow">if</span>(pLostAllocationCount != VMA_NULL)</div>
+<div class="line"><a name="l12911"></a><span class="lineno">12911</span>&#160; </div>
+<div class="line"><a name="l12912"></a><span class="lineno">12912</span>&#160;    <span class="keywordflow">if</span>(pCtx-&gt;mutexLocked)</div>
+<div class="line"><a name="l12913"></a><span class="lineno">12913</span>&#160;    {</div>
+<div class="line"><a name="l12914"></a><span class="lineno">12914</span>&#160;        VMA_ASSERT(m_hAllocator-&gt;m_UseMutex);</div>
+<div class="line"><a name="l12915"></a><span class="lineno">12915</span>&#160;        m_Mutex.UnlockWrite();</div>
+<div class="line"><a name="l12916"></a><span class="lineno">12916</span>&#160;    }</div>
+<div class="line"><a name="l12917"></a><span class="lineno">12917</span>&#160;}</div>
+<div class="line"><a name="l12918"></a><span class="lineno">12918</span>&#160; </div>
+<div class="line"><a name="l12919"></a><span class="lineno">12919</span>&#160;<span class="keywordtype">size_t</span> VmaBlockVector::CalcAllocationCount()<span class="keyword"> const</span></div>
+<div class="line"><a name="l12920"></a><span class="lineno">12920</span>&#160;<span class="keyword"></span>{</div>
+<div class="line"><a name="l12921"></a><span class="lineno">12921</span>&#160;    <span class="keywordtype">size_t</span> result = 0;</div>
+<div class="line"><a name="l12922"></a><span class="lineno">12922</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 0; i &lt; m_Blocks.size(); ++i)</div>
+<div class="line"><a name="l12923"></a><span class="lineno">12923</span>&#160;    {</div>
+<div class="line"><a name="l12924"></a><span class="lineno">12924</span>&#160;        result += m_Blocks[i]-&gt;m_pMetadata-&gt;GetAllocationCount();</div>
+<div class="line"><a name="l12925"></a><span class="lineno">12925</span>&#160;    }</div>
+<div class="line"><a name="l12926"></a><span class="lineno">12926</span>&#160;    <span class="keywordflow">return</span> result;</div>
+<div class="line"><a name="l12927"></a><span class="lineno">12927</span>&#160;}</div>
+<div class="line"><a name="l12928"></a><span class="lineno">12928</span>&#160; </div>
+<div class="line"><a name="l12929"></a><span class="lineno">12929</span>&#160;<span class="keywordtype">bool</span> VmaBlockVector::IsBufferImageGranularityConflictPossible()<span class="keyword"> const</span></div>
+<div class="line"><a name="l12930"></a><span class="lineno">12930</span>&#160;<span class="keyword"></span>{</div>
+<div class="line"><a name="l12931"></a><span class="lineno">12931</span>&#160;    <span class="keywordflow">if</span>(m_BufferImageGranularity == 1)</div>
+<div class="line"><a name="l12932"></a><span class="lineno">12932</span>&#160;    {</div>
+<div class="line"><a name="l12933"></a><span class="lineno">12933</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
+<div class="line"><a name="l12934"></a><span class="lineno">12934</span>&#160;    }</div>
+<div class="line"><a name="l12935"></a><span class="lineno">12935</span>&#160;    VmaSuballocationType lastSuballocType = VMA_SUBALLOCATION_TYPE_FREE;</div>
+<div class="line"><a name="l12936"></a><span class="lineno">12936</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 0, count = m_Blocks.size(); i &lt; count; ++i)</div>
+<div class="line"><a name="l12937"></a><span class="lineno">12937</span>&#160;    {</div>
+<div class="line"><a name="l12938"></a><span class="lineno">12938</span>&#160;        VmaDeviceMemoryBlock* <span class="keyword">const</span> pBlock = m_Blocks[i];</div>
+<div class="line"><a name="l12939"></a><span class="lineno">12939</span>&#160;        VMA_ASSERT(m_Algorithm == 0);</div>
+<div class="line"><a name="l12940"></a><span class="lineno">12940</span>&#160;        VmaBlockMetadata_Generic* <span class="keyword">const</span> pMetadata = (VmaBlockMetadata_Generic*)pBlock-&gt;m_pMetadata;</div>
+<div class="line"><a name="l12941"></a><span class="lineno">12941</span>&#160;        <span class="keywordflow">if</span>(pMetadata-&gt;IsBufferImageGranularityConflictPossible(m_BufferImageGranularity, lastSuballocType))</div>
+<div class="line"><a name="l12942"></a><span class="lineno">12942</span>&#160;        {</div>
+<div class="line"><a name="l12943"></a><span class="lineno">12943</span>&#160;            <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
+<div class="line"><a name="l12944"></a><span class="lineno">12944</span>&#160;        }</div>
+<div class="line"><a name="l12945"></a><span class="lineno">12945</span>&#160;    }</div>
+<div class="line"><a name="l12946"></a><span class="lineno">12946</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
+<div class="line"><a name="l12947"></a><span class="lineno">12947</span>&#160;}</div>
+<div class="line"><a name="l12948"></a><span class="lineno">12948</span>&#160; </div>
+<div class="line"><a name="l12949"></a><span class="lineno">12949</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::MakePoolAllocationsLost(</div>
+<div class="line"><a name="l12950"></a><span class="lineno">12950</span>&#160;    uint32_t currentFrameIndex,</div>
+<div class="line"><a name="l12951"></a><span class="lineno">12951</span>&#160;    <span class="keywordtype">size_t</span>* pLostAllocationCount)</div>
+<div class="line"><a name="l12952"></a><span class="lineno">12952</span>&#160;{</div>
+<div class="line"><a name="l12953"></a><span class="lineno">12953</span>&#160;    VmaMutexLockWrite lock(m_Mutex, m_hAllocator-&gt;m_UseMutex);</div>
+<div class="line"><a name="l12954"></a><span class="lineno">12954</span>&#160;    <span class="keywordtype">size_t</span> lostAllocationCount = 0;</div>
+<div class="line"><a name="l12955"></a><span class="lineno">12955</span>&#160;    <span class="keywordflow">for</span>(uint32_t blockIndex = 0; blockIndex &lt; m_Blocks.size(); ++blockIndex)</div>
 <div class="line"><a name="l12956"></a><span class="lineno">12956</span>&#160;    {</div>
-<div class="line"><a name="l12957"></a><span class="lineno">12957</span>&#160;        *pLostAllocationCount = lostAllocationCount;</div>
-<div class="line"><a name="l12958"></a><span class="lineno">12958</span>&#160;    }</div>
-<div class="line"><a name="l12959"></a><span class="lineno">12959</span>&#160;}</div>
-<div class="line"><a name="l12960"></a><span class="lineno">12960</span>&#160; </div>
-<div class="line"><a name="l12961"></a><span class="lineno">12961</span>&#160;VkResult VmaBlockVector::CheckCorruption()</div>
-<div class="line"><a name="l12962"></a><span class="lineno">12962</span>&#160;{</div>
-<div class="line"><a name="l12963"></a><span class="lineno">12963</span>&#160;    <span class="keywordflow">if</span>(!IsCorruptionDetectionEnabled())</div>
-<div class="line"><a name="l12964"></a><span class="lineno">12964</span>&#160;    {</div>
-<div class="line"><a name="l12965"></a><span class="lineno">12965</span>&#160;        <span class="keywordflow">return</span> VK_ERROR_FEATURE_NOT_PRESENT;</div>
-<div class="line"><a name="l12966"></a><span class="lineno">12966</span>&#160;    }</div>
-<div class="line"><a name="l12967"></a><span class="lineno">12967</span>&#160; </div>
-<div class="line"><a name="l12968"></a><span class="lineno">12968</span>&#160;    VmaMutexLockRead lock(m_Mutex, m_hAllocator-&gt;m_UseMutex);</div>
-<div class="line"><a name="l12969"></a><span class="lineno">12969</span>&#160;    <span class="keywordflow">for</span>(uint32_t blockIndex = 0; blockIndex &lt; m_Blocks.size(); ++blockIndex)</div>
+<div class="line"><a name="l12957"></a><span class="lineno">12957</span>&#160;        VmaDeviceMemoryBlock* <span class="keyword">const</span> pBlock = m_Blocks[blockIndex];</div>
+<div class="line"><a name="l12958"></a><span class="lineno">12958</span>&#160;        VMA_ASSERT(pBlock);</div>
+<div class="line"><a name="l12959"></a><span class="lineno">12959</span>&#160;        lostAllocationCount += pBlock-&gt;m_pMetadata-&gt;MakeAllocationsLost(currentFrameIndex, m_FrameInUseCount);</div>
+<div class="line"><a name="l12960"></a><span class="lineno">12960</span>&#160;    }</div>
+<div class="line"><a name="l12961"></a><span class="lineno">12961</span>&#160;    <span class="keywordflow">if</span>(pLostAllocationCount != VMA_NULL)</div>
+<div class="line"><a name="l12962"></a><span class="lineno">12962</span>&#160;    {</div>
+<div class="line"><a name="l12963"></a><span class="lineno">12963</span>&#160;        *pLostAllocationCount = lostAllocationCount;</div>
+<div class="line"><a name="l12964"></a><span class="lineno">12964</span>&#160;    }</div>
+<div class="line"><a name="l12965"></a><span class="lineno">12965</span>&#160;}</div>
+<div class="line"><a name="l12966"></a><span class="lineno">12966</span>&#160; </div>
+<div class="line"><a name="l12967"></a><span class="lineno">12967</span>&#160;VkResult VmaBlockVector::CheckCorruption()</div>
+<div class="line"><a name="l12968"></a><span class="lineno">12968</span>&#160;{</div>
+<div class="line"><a name="l12969"></a><span class="lineno">12969</span>&#160;    <span class="keywordflow">if</span>(!IsCorruptionDetectionEnabled())</div>
 <div class="line"><a name="l12970"></a><span class="lineno">12970</span>&#160;    {</div>
-<div class="line"><a name="l12971"></a><span class="lineno">12971</span>&#160;        VmaDeviceMemoryBlock* <span class="keyword">const</span> pBlock = m_Blocks[blockIndex];</div>
-<div class="line"><a name="l12972"></a><span class="lineno">12972</span>&#160;        VMA_ASSERT(pBlock);</div>
-<div class="line"><a name="l12973"></a><span class="lineno">12973</span>&#160;        VkResult res = pBlock-&gt;CheckCorruption(m_hAllocator);</div>
-<div class="line"><a name="l12974"></a><span class="lineno">12974</span>&#160;        <span class="keywordflow">if</span>(res != VK_SUCCESS)</div>
-<div class="line"><a name="l12975"></a><span class="lineno">12975</span>&#160;        {</div>
-<div class="line"><a name="l12976"></a><span class="lineno">12976</span>&#160;            <span class="keywordflow">return</span> res;</div>
-<div class="line"><a name="l12977"></a><span class="lineno">12977</span>&#160;        }</div>
-<div class="line"><a name="l12978"></a><span class="lineno">12978</span>&#160;    }</div>
-<div class="line"><a name="l12979"></a><span class="lineno">12979</span>&#160;    <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l12980"></a><span class="lineno">12980</span>&#160;}</div>
-<div class="line"><a name="l12981"></a><span class="lineno">12981</span>&#160; </div>
-<div class="line"><a name="l12982"></a><span class="lineno">12982</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::AddStats(<a class="code" href="struct_vma_stats.html">VmaStats</a>* pStats)</div>
-<div class="line"><a name="l12983"></a><span class="lineno">12983</span>&#160;{</div>
-<div class="line"><a name="l12984"></a><span class="lineno">12984</span>&#160;    <span class="keyword">const</span> uint32_t memTypeIndex = m_MemoryTypeIndex;</div>
-<div class="line"><a name="l12985"></a><span class="lineno">12985</span>&#160;    <span class="keyword">const</span> uint32_t memHeapIndex = m_hAllocator-&gt;MemoryTypeIndexToHeapIndex(memTypeIndex);</div>
-<div class="line"><a name="l12986"></a><span class="lineno">12986</span>&#160; </div>
-<div class="line"><a name="l12987"></a><span class="lineno">12987</span>&#160;    VmaMutexLockRead lock(m_Mutex, m_hAllocator-&gt;m_UseMutex);</div>
-<div class="line"><a name="l12988"></a><span class="lineno">12988</span>&#160; </div>
-<div class="line"><a name="l12989"></a><span class="lineno">12989</span>&#160;    <span class="keywordflow">for</span>(uint32_t blockIndex = 0; blockIndex &lt; m_Blocks.size(); ++blockIndex)</div>
-<div class="line"><a name="l12990"></a><span class="lineno">12990</span>&#160;    {</div>
-<div class="line"><a name="l12991"></a><span class="lineno">12991</span>&#160;        <span class="keyword">const</span> VmaDeviceMemoryBlock* <span class="keyword">const</span> pBlock = m_Blocks[blockIndex];</div>
-<div class="line"><a name="l12992"></a><span class="lineno">12992</span>&#160;        VMA_ASSERT(pBlock);</div>
-<div class="line"><a name="l12993"></a><span class="lineno">12993</span>&#160;        VMA_HEAVY_ASSERT(pBlock-&gt;Validate());</div>
-<div class="line"><a name="l12994"></a><span class="lineno">12994</span>&#160;        <a class="code" href="struct_vma_stat_info.html">VmaStatInfo</a> allocationStatInfo;</div>
-<div class="line"><a name="l12995"></a><span class="lineno">12995</span>&#160;        pBlock-&gt;m_pMetadata-&gt;CalcAllocationStatInfo(allocationStatInfo);</div>
-<div class="line"><a name="l12996"></a><span class="lineno">12996</span>&#160;        VmaAddStatInfo(pStats-&gt;<a class="code" href="struct_vma_stats.html#a2e8f5b3353f2fefef3c27f29e245a1f9">total</a>, allocationStatInfo);</div>
-<div class="line"><a name="l12997"></a><span class="lineno">12997</span>&#160;        VmaAddStatInfo(pStats-&gt;<a class="code" href="struct_vma_stats.html#a13e3caf754be79352c42408756309331">memoryType</a>[memTypeIndex], allocationStatInfo);</div>
-<div class="line"><a name="l12998"></a><span class="lineno">12998</span>&#160;        VmaAddStatInfo(pStats-&gt;<a class="code" href="struct_vma_stats.html#a0e6611508c29a187f0fd14ff1a0329c0">memoryHeap</a>[memHeapIndex], allocationStatInfo);</div>
-<div class="line"><a name="l12999"></a><span class="lineno">12999</span>&#160;    }</div>
-<div class="line"><a name="l13000"></a><span class="lineno">13000</span>&#160;}</div>
-<div class="line"><a name="l13001"></a><span class="lineno">13001</span>&#160; </div>
-<div class="line"><a name="l13003"></a><span class="lineno">13003</span>&#160;<span class="comment">// VmaDefragmentationAlgorithm_Generic members definition</span></div>
-<div class="line"><a name="l13004"></a><span class="lineno">13004</span>&#160; </div>
-<div class="line"><a name="l13005"></a><span class="lineno">13005</span>&#160;VmaDefragmentationAlgorithm_Generic::VmaDefragmentationAlgorithm_Generic(</div>
-<div class="line"><a name="l13006"></a><span class="lineno">13006</span>&#160;    <a class="code" href="struct_vma_allocator.html">VmaAllocator</a> hAllocator,</div>
-<div class="line"><a name="l13007"></a><span class="lineno">13007</span>&#160;    VmaBlockVector* pBlockVector,</div>
-<div class="line"><a name="l13008"></a><span class="lineno">13008</span>&#160;    uint32_t currentFrameIndex,</div>
-<div class="line"><a name="l13009"></a><span class="lineno">13009</span>&#160;    <span class="keywordtype">bool</span> overlappingMoveSupported) :</div>
-<div class="line"><a name="l13010"></a><span class="lineno">13010</span>&#160;    VmaDefragmentationAlgorithm(hAllocator, pBlockVector, currentFrameIndex),</div>
-<div class="line"><a name="l13011"></a><span class="lineno">13011</span>&#160;    m_AllocationCount(0),</div>
-<div class="line"><a name="l13012"></a><span class="lineno">13012</span>&#160;    m_AllAllocations(false),</div>
-<div class="line"><a name="l13013"></a><span class="lineno">13013</span>&#160;    m_BytesMoved(0),</div>
-<div class="line"><a name="l13014"></a><span class="lineno">13014</span>&#160;    m_AllocationsMoved(0),</div>
-<div class="line"><a name="l13015"></a><span class="lineno">13015</span>&#160;    m_Blocks(VmaStlAllocator&lt;BlockInfo*&gt;(hAllocator-&gt;GetAllocationCallbacks()))</div>
-<div class="line"><a name="l13016"></a><span class="lineno">13016</span>&#160;{</div>
-<div class="line"><a name="l13017"></a><span class="lineno">13017</span>&#160;    <span class="comment">// Create block info for each block.</span></div>
-<div class="line"><a name="l13018"></a><span class="lineno">13018</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> blockCount = m_pBlockVector-&gt;m_Blocks.size();</div>
-<div class="line"><a name="l13019"></a><span class="lineno">13019</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; blockIndex &lt; blockCount; ++blockIndex)</div>
-<div class="line"><a name="l13020"></a><span class="lineno">13020</span>&#160;    {</div>
-<div class="line"><a name="l13021"></a><span class="lineno">13021</span>&#160;        BlockInfo* pBlockInfo = vma_new(m_hAllocator, BlockInfo)(m_hAllocator-&gt;GetAllocationCallbacks());</div>
-<div class="line"><a name="l13022"></a><span class="lineno">13022</span>&#160;        pBlockInfo-&gt;m_OriginalBlockIndex = blockIndex;</div>
-<div class="line"><a name="l13023"></a><span class="lineno">13023</span>&#160;        pBlockInfo-&gt;m_pBlock = m_pBlockVector-&gt;m_Blocks[blockIndex];</div>
-<div class="line"><a name="l13024"></a><span class="lineno">13024</span>&#160;        m_Blocks.push_back(pBlockInfo);</div>
-<div class="line"><a name="l13025"></a><span class="lineno">13025</span>&#160;    }</div>
-<div class="line"><a name="l13026"></a><span class="lineno">13026</span>&#160; </div>
-<div class="line"><a name="l13027"></a><span class="lineno">13027</span>&#160;    <span class="comment">// Sort them by m_pBlock pointer value.</span></div>
-<div class="line"><a name="l13028"></a><span class="lineno">13028</span>&#160;    VMA_SORT(m_Blocks.begin(), m_Blocks.end(), BlockPointerLess());</div>
-<div class="line"><a name="l13029"></a><span class="lineno">13029</span>&#160;}</div>
-<div class="line"><a name="l13030"></a><span class="lineno">13030</span>&#160; </div>
-<div class="line"><a name="l13031"></a><span class="lineno">13031</span>&#160;VmaDefragmentationAlgorithm_Generic::~VmaDefragmentationAlgorithm_Generic()</div>
-<div class="line"><a name="l13032"></a><span class="lineno">13032</span>&#160;{</div>
-<div class="line"><a name="l13033"></a><span class="lineno">13033</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = m_Blocks.size(); i--; )</div>
-<div class="line"><a name="l13034"></a><span class="lineno">13034</span>&#160;    {</div>
-<div class="line"><a name="l13035"></a><span class="lineno">13035</span>&#160;        vma_delete(m_hAllocator, m_Blocks[i]);</div>
-<div class="line"><a name="l13036"></a><span class="lineno">13036</span>&#160;    }</div>
-<div class="line"><a name="l13037"></a><span class="lineno">13037</span>&#160;}</div>
-<div class="line"><a name="l13038"></a><span class="lineno">13038</span>&#160; </div>
-<div class="line"><a name="l13039"></a><span class="lineno">13039</span>&#160;<span class="keywordtype">void</span> VmaDefragmentationAlgorithm_Generic::AddAllocation(<a class="code" href="struct_vma_allocation.html">VmaAllocation</a> hAlloc, VkBool32* pChanged)</div>
-<div class="line"><a name="l13040"></a><span class="lineno">13040</span>&#160;{</div>
-<div class="line"><a name="l13041"></a><span class="lineno">13041</span>&#160;    <span class="comment">// Now as we are inside VmaBlockVector::m_Mutex, we can make final check if this allocation was not lost.</span></div>
-<div class="line"><a name="l13042"></a><span class="lineno">13042</span>&#160;    <span class="keywordflow">if</span>(hAlloc-&gt;GetLastUseFrameIndex() != VMA_FRAME_INDEX_LOST)</div>
-<div class="line"><a name="l13043"></a><span class="lineno">13043</span>&#160;    {</div>
-<div class="line"><a name="l13044"></a><span class="lineno">13044</span>&#160;        VmaDeviceMemoryBlock* pBlock = hAlloc-&gt;GetBlock();</div>
-<div class="line"><a name="l13045"></a><span class="lineno">13045</span>&#160;        BlockInfoVector::iterator it = VmaBinaryFindFirstNotLess(m_Blocks.begin(), m_Blocks.end(), pBlock, BlockPointerLess());</div>
-<div class="line"><a name="l13046"></a><span class="lineno">13046</span>&#160;        <span class="keywordflow">if</span>(it != m_Blocks.end() &amp;&amp; (*it)-&gt;m_pBlock == pBlock)</div>
-<div class="line"><a name="l13047"></a><span class="lineno">13047</span>&#160;        {</div>
-<div class="line"><a name="l13048"></a><span class="lineno">13048</span>&#160;            AllocationInfo allocInfo = AllocationInfo(hAlloc, pChanged);</div>
-<div class="line"><a name="l13049"></a><span class="lineno">13049</span>&#160;            (*it)-&gt;m_Allocations.push_back(allocInfo);</div>
-<div class="line"><a name="l13050"></a><span class="lineno">13050</span>&#160;        }</div>
-<div class="line"><a name="l13051"></a><span class="lineno">13051</span>&#160;        <span class="keywordflow">else</span></div>
-<div class="line"><a name="l13052"></a><span class="lineno">13052</span>&#160;        {</div>
-<div class="line"><a name="l13053"></a><span class="lineno">13053</span>&#160;            VMA_ASSERT(0);</div>
-<div class="line"><a name="l13054"></a><span class="lineno">13054</span>&#160;        }</div>
-<div class="line"><a name="l13055"></a><span class="lineno">13055</span>&#160; </div>
-<div class="line"><a name="l13056"></a><span class="lineno">13056</span>&#160;        ++m_AllocationCount;</div>
-<div class="line"><a name="l13057"></a><span class="lineno">13057</span>&#160;    }</div>
-<div class="line"><a name="l13058"></a><span class="lineno">13058</span>&#160;}</div>
-<div class="line"><a name="l13059"></a><span class="lineno">13059</span>&#160; </div>
-<div class="line"><a name="l13060"></a><span class="lineno">13060</span>&#160;VkResult VmaDefragmentationAlgorithm_Generic::DefragmentRound(</div>
-<div class="line"><a name="l13061"></a><span class="lineno">13061</span>&#160;    VmaVector&lt; VmaDefragmentationMove, VmaStlAllocator&lt;VmaDefragmentationMove&gt; &gt;&amp; moves,</div>
-<div class="line"><a name="l13062"></a><span class="lineno">13062</span>&#160;    VkDeviceSize maxBytesToMove,</div>
-<div class="line"><a name="l13063"></a><span class="lineno">13063</span>&#160;    uint32_t maxAllocationsToMove)</div>
-<div class="line"><a name="l13064"></a><span class="lineno">13064</span>&#160;{</div>
-<div class="line"><a name="l13065"></a><span class="lineno">13065</span>&#160;    <span class="keywordflow">if</span>(m_Blocks.empty())</div>
-<div class="line"><a name="l13066"></a><span class="lineno">13066</span>&#160;    {</div>
-<div class="line"><a name="l13067"></a><span class="lineno">13067</span>&#160;        <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l13068"></a><span class="lineno">13068</span>&#160;    }</div>
-<div class="line"><a name="l13069"></a><span class="lineno">13069</span>&#160; </div>
-<div class="line"><a name="l13070"></a><span class="lineno">13070</span>&#160;    <span class="comment">// This is a choice based on research.</span></div>
-<div class="line"><a name="l13071"></a><span class="lineno">13071</span>&#160;    <span class="comment">// Option 1:</span></div>
-<div class="line"><a name="l13072"></a><span class="lineno">13072</span>&#160;    uint32_t strategy = <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a0729e932b7ea170e3a128cad96c5cf6d">VMA_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT</a>;</div>
-<div class="line"><a name="l13073"></a><span class="lineno">13073</span>&#160;    <span class="comment">// Option 2:</span></div>
-<div class="line"><a name="l13074"></a><span class="lineno">13074</span>&#160;    <span class="comment">//uint32_t strategy = VMA_ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT;</span></div>
-<div class="line"><a name="l13075"></a><span class="lineno">13075</span>&#160;    <span class="comment">// Option 3:</span></div>
-<div class="line"><a name="l13076"></a><span class="lineno">13076</span>&#160;    <span class="comment">//uint32_t strategy = VMA_ALLOCATION_CREATE_STRATEGY_MIN_FRAGMENTATION_BIT;</span></div>
-<div class="line"><a name="l13077"></a><span class="lineno">13077</span>&#160; </div>
-<div class="line"><a name="l13078"></a><span class="lineno">13078</span>&#160;    <span class="keywordtype">size_t</span> srcBlockMinIndex = 0;</div>
-<div class="line"><a name="l13079"></a><span class="lineno">13079</span>&#160;    <span class="comment">// When FAST_ALGORITHM, move allocations from only last out of blocks that contain non-movable allocations.</span></div>
-<div class="line"><a name="l13080"></a><span class="lineno">13080</span>&#160;    <span class="comment">/*</span></div>
-<div class="line"><a name="l13081"></a><span class="lineno">13081</span>&#160;<span class="comment">    if(m_AlgorithmFlags &amp; VMA_DEFRAGMENTATION_FAST_ALGORITHM_BIT)</span></div>
-<div class="line"><a name="l13082"></a><span class="lineno">13082</span>&#160;<span class="comment">    {</span></div>
-<div class="line"><a name="l13083"></a><span class="lineno">13083</span>&#160;<span class="comment">        const size_t blocksWithNonMovableCount = CalcBlocksWithNonMovableCount();</span></div>
-<div class="line"><a name="l13084"></a><span class="lineno">13084</span>&#160;<span class="comment">        if(blocksWithNonMovableCount &gt; 0)</span></div>
-<div class="line"><a name="l13085"></a><span class="lineno">13085</span>&#160;<span class="comment">        {</span></div>
-<div class="line"><a name="l13086"></a><span class="lineno">13086</span>&#160;<span class="comment">            srcBlockMinIndex = blocksWithNonMovableCount - 1;</span></div>
-<div class="line"><a name="l13087"></a><span class="lineno">13087</span>&#160;<span class="comment">        }</span></div>
-<div class="line"><a name="l13088"></a><span class="lineno">13088</span>&#160;<span class="comment">    }</span></div>
-<div class="line"><a name="l13089"></a><span class="lineno">13089</span>&#160;<span class="comment">    */</span></div>
-<div class="line"><a name="l13090"></a><span class="lineno">13090</span>&#160; </div>
-<div class="line"><a name="l13091"></a><span class="lineno">13091</span>&#160;    <span class="keywordtype">size_t</span> srcBlockIndex = m_Blocks.size() - 1;</div>
-<div class="line"><a name="l13092"></a><span class="lineno">13092</span>&#160;    <span class="keywordtype">size_t</span> srcAllocIndex = SIZE_MAX;</div>
-<div class="line"><a name="l13093"></a><span class="lineno">13093</span>&#160;    <span class="keywordflow">for</span>(;;)</div>
-<div class="line"><a name="l13094"></a><span class="lineno">13094</span>&#160;    {</div>
-<div class="line"><a name="l13095"></a><span class="lineno">13095</span>&#160;        <span class="comment">// 1. Find next allocation to move.</span></div>
-<div class="line"><a name="l13096"></a><span class="lineno">13096</span>&#160;        <span class="comment">// 1.1. Start from last to first m_Blocks - they are sorted from most &quot;destination&quot; to most &quot;source&quot;.</span></div>
-<div class="line"><a name="l13097"></a><span class="lineno">13097</span>&#160;        <span class="comment">// 1.2. Then start from last to first m_Allocations.</span></div>
-<div class="line"><a name="l13098"></a><span class="lineno">13098</span>&#160;        <span class="keywordflow">while</span>(srcAllocIndex &gt;= m_Blocks[srcBlockIndex]-&gt;m_Allocations.size())</div>
-<div class="line"><a name="l13099"></a><span class="lineno">13099</span>&#160;        {</div>
-<div class="line"><a name="l13100"></a><span class="lineno">13100</span>&#160;            <span class="keywordflow">if</span>(m_Blocks[srcBlockIndex]-&gt;m_Allocations.empty())</div>
-<div class="line"><a name="l13101"></a><span class="lineno">13101</span>&#160;            {</div>
-<div class="line"><a name="l13102"></a><span class="lineno">13102</span>&#160;                <span class="comment">// Finished: no more allocations to process.</span></div>
-<div class="line"><a name="l13103"></a><span class="lineno">13103</span>&#160;                <span class="keywordflow">if</span>(srcBlockIndex == srcBlockMinIndex)</div>
-<div class="line"><a name="l13104"></a><span class="lineno">13104</span>&#160;                {</div>
-<div class="line"><a name="l13105"></a><span class="lineno">13105</span>&#160;                    <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l13106"></a><span class="lineno">13106</span>&#160;                }</div>
-<div class="line"><a name="l13107"></a><span class="lineno">13107</span>&#160;                <span class="keywordflow">else</span></div>
-<div class="line"><a name="l13108"></a><span class="lineno">13108</span>&#160;                {</div>
-<div class="line"><a name="l13109"></a><span class="lineno">13109</span>&#160;                    --srcBlockIndex;</div>
-<div class="line"><a name="l13110"></a><span class="lineno">13110</span>&#160;                    srcAllocIndex = SIZE_MAX;</div>
-<div class="line"><a name="l13111"></a><span class="lineno">13111</span>&#160;                }</div>
-<div class="line"><a name="l13112"></a><span class="lineno">13112</span>&#160;            }</div>
-<div class="line"><a name="l13113"></a><span class="lineno">13113</span>&#160;            <span class="keywordflow">else</span></div>
-<div class="line"><a name="l13114"></a><span class="lineno">13114</span>&#160;            {</div>
-<div class="line"><a name="l13115"></a><span class="lineno">13115</span>&#160;                srcAllocIndex = m_Blocks[srcBlockIndex]-&gt;m_Allocations.size() - 1;</div>
-<div class="line"><a name="l13116"></a><span class="lineno">13116</span>&#160;            }</div>
-<div class="line"><a name="l13117"></a><span class="lineno">13117</span>&#160;        }</div>
-<div class="line"><a name="l13118"></a><span class="lineno">13118</span>&#160;        </div>
-<div class="line"><a name="l13119"></a><span class="lineno">13119</span>&#160;        BlockInfo* pSrcBlockInfo = m_Blocks[srcBlockIndex];</div>
-<div class="line"><a name="l13120"></a><span class="lineno">13120</span>&#160;        AllocationInfo&amp; allocInfo = pSrcBlockInfo-&gt;m_Allocations[srcAllocIndex];</div>
-<div class="line"><a name="l13121"></a><span class="lineno">13121</span>&#160; </div>
-<div class="line"><a name="l13122"></a><span class="lineno">13122</span>&#160;        <span class="keyword">const</span> VkDeviceSize size = allocInfo.m_hAllocation-&gt;GetSize();</div>
-<div class="line"><a name="l13123"></a><span class="lineno">13123</span>&#160;        <span class="keyword">const</span> VkDeviceSize srcOffset = allocInfo.m_hAllocation-&gt;GetOffset();</div>
-<div class="line"><a name="l13124"></a><span class="lineno">13124</span>&#160;        <span class="keyword">const</span> VkDeviceSize alignment = allocInfo.m_hAllocation-&gt;GetAlignment();</div>
-<div class="line"><a name="l13125"></a><span class="lineno">13125</span>&#160;        <span class="keyword">const</span> VmaSuballocationType suballocType = allocInfo.m_hAllocation-&gt;GetSuballocationType();</div>
-<div class="line"><a name="l13126"></a><span class="lineno">13126</span>&#160; </div>
-<div class="line"><a name="l13127"></a><span class="lineno">13127</span>&#160;        <span class="comment">// 2. Try to find new place for this allocation in preceding or current block.</span></div>
-<div class="line"><a name="l13128"></a><span class="lineno">13128</span>&#160;        <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> dstBlockIndex = 0; dstBlockIndex &lt;= srcBlockIndex; ++dstBlockIndex)</div>
-<div class="line"><a name="l13129"></a><span class="lineno">13129</span>&#160;        {</div>
-<div class="line"><a name="l13130"></a><span class="lineno">13130</span>&#160;            BlockInfo* pDstBlockInfo = m_Blocks[dstBlockIndex];</div>
-<div class="line"><a name="l13131"></a><span class="lineno">13131</span>&#160;            VmaAllocationRequest dstAllocRequest;</div>
-<div class="line"><a name="l13132"></a><span class="lineno">13132</span>&#160;            <span class="keywordflow">if</span>(pDstBlockInfo-&gt;m_pBlock-&gt;m_pMetadata-&gt;CreateAllocationRequest(</div>
-<div class="line"><a name="l13133"></a><span class="lineno">13133</span>&#160;                m_CurrentFrameIndex,</div>
-<div class="line"><a name="l13134"></a><span class="lineno">13134</span>&#160;                m_pBlockVector-&gt;GetFrameInUseCount(),</div>
-<div class="line"><a name="l13135"></a><span class="lineno">13135</span>&#160;                m_pBlockVector-&gt;GetBufferImageGranularity(),</div>
-<div class="line"><a name="l13136"></a><span class="lineno">13136</span>&#160;                size,</div>
-<div class="line"><a name="l13137"></a><span class="lineno">13137</span>&#160;                alignment,</div>
-<div class="line"><a name="l13138"></a><span class="lineno">13138</span>&#160;                <span class="keyword">false</span>, <span class="comment">// upperAddress</span></div>
-<div class="line"><a name="l13139"></a><span class="lineno">13139</span>&#160;                suballocType,</div>
-<div class="line"><a name="l13140"></a><span class="lineno">13140</span>&#160;                <span class="keyword">false</span>, <span class="comment">// canMakeOtherLost</span></div>
-<div class="line"><a name="l13141"></a><span class="lineno">13141</span>&#160;                strategy,</div>
-<div class="line"><a name="l13142"></a><span class="lineno">13142</span>&#160;                &amp;dstAllocRequest) &amp;&amp;</div>
-<div class="line"><a name="l13143"></a><span class="lineno">13143</span>&#160;            MoveMakesSense(</div>
-<div class="line"><a name="l13144"></a><span class="lineno">13144</span>&#160;                dstBlockIndex, dstAllocRequest.offset, srcBlockIndex, srcOffset))</div>
-<div class="line"><a name="l13145"></a><span class="lineno">13145</span>&#160;            {</div>
-<div class="line"><a name="l13146"></a><span class="lineno">13146</span>&#160;                VMA_ASSERT(dstAllocRequest.itemsToMakeLostCount == 0);</div>
-<div class="line"><a name="l13147"></a><span class="lineno">13147</span>&#160; </div>
-<div class="line"><a name="l13148"></a><span class="lineno">13148</span>&#160;                <span class="comment">// Reached limit on number of allocations or bytes to move.</span></div>
-<div class="line"><a name="l13149"></a><span class="lineno">13149</span>&#160;                <span class="keywordflow">if</span>((m_AllocationsMoved + 1 &gt; maxAllocationsToMove) ||</div>
-<div class="line"><a name="l13150"></a><span class="lineno">13150</span>&#160;                    (m_BytesMoved + size &gt; maxBytesToMove))</div>
-<div class="line"><a name="l13151"></a><span class="lineno">13151</span>&#160;                {</div>
-<div class="line"><a name="l13152"></a><span class="lineno">13152</span>&#160;                    <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l13153"></a><span class="lineno">13153</span>&#160;                }</div>
-<div class="line"><a name="l13154"></a><span class="lineno">13154</span>&#160; </div>
-<div class="line"><a name="l13155"></a><span class="lineno">13155</span>&#160;                VmaDefragmentationMove move;</div>
-<div class="line"><a name="l13156"></a><span class="lineno">13156</span>&#160;                move.srcBlockIndex = pSrcBlockInfo-&gt;m_OriginalBlockIndex;</div>
-<div class="line"><a name="l13157"></a><span class="lineno">13157</span>&#160;                move.dstBlockIndex = pDstBlockInfo-&gt;m_OriginalBlockIndex;</div>
-<div class="line"><a name="l13158"></a><span class="lineno">13158</span>&#160;                move.srcOffset = srcOffset;</div>
-<div class="line"><a name="l13159"></a><span class="lineno">13159</span>&#160;                move.dstOffset = dstAllocRequest.offset;</div>
-<div class="line"><a name="l13160"></a><span class="lineno">13160</span>&#160;                move.size = size;</div>
-<div class="line"><a name="l13161"></a><span class="lineno">13161</span>&#160;                moves.push_back(move);</div>
-<div class="line"><a name="l13162"></a><span class="lineno">13162</span>&#160; </div>
-<div class="line"><a name="l13163"></a><span class="lineno">13163</span>&#160;                pDstBlockInfo-&gt;m_pBlock-&gt;m_pMetadata-&gt;Alloc(</div>
-<div class="line"><a name="l13164"></a><span class="lineno">13164</span>&#160;                    dstAllocRequest,</div>
-<div class="line"><a name="l13165"></a><span class="lineno">13165</span>&#160;                    suballocType,</div>
-<div class="line"><a name="l13166"></a><span class="lineno">13166</span>&#160;                    size,</div>
-<div class="line"><a name="l13167"></a><span class="lineno">13167</span>&#160;                    allocInfo.m_hAllocation);</div>
-<div class="line"><a name="l13168"></a><span class="lineno">13168</span>&#160;                pSrcBlockInfo-&gt;m_pBlock-&gt;m_pMetadata-&gt;FreeAtOffset(srcOffset);</div>
-<div class="line"><a name="l13169"></a><span class="lineno">13169</span>&#160;                </div>
-<div class="line"><a name="l13170"></a><span class="lineno">13170</span>&#160;                allocInfo.m_hAllocation-&gt;ChangeBlockAllocation(m_hAllocator, pDstBlockInfo-&gt;m_pBlock, dstAllocRequest.offset);</div>
-<div class="line"><a name="l13171"></a><span class="lineno">13171</span>&#160; </div>
-<div class="line"><a name="l13172"></a><span class="lineno">13172</span>&#160;                <span class="keywordflow">if</span>(allocInfo.m_pChanged != VMA_NULL)</div>
-<div class="line"><a name="l13173"></a><span class="lineno">13173</span>&#160;                {</div>
-<div class="line"><a name="l13174"></a><span class="lineno">13174</span>&#160;                    *allocInfo.m_pChanged = VK_TRUE;</div>
-<div class="line"><a name="l13175"></a><span class="lineno">13175</span>&#160;                }</div>
-<div class="line"><a name="l13176"></a><span class="lineno">13176</span>&#160; </div>
-<div class="line"><a name="l13177"></a><span class="lineno">13177</span>&#160;                ++m_AllocationsMoved;</div>
-<div class="line"><a name="l13178"></a><span class="lineno">13178</span>&#160;                m_BytesMoved += size;</div>
-<div class="line"><a name="l13179"></a><span class="lineno">13179</span>&#160; </div>
-<div class="line"><a name="l13180"></a><span class="lineno">13180</span>&#160;                VmaVectorRemove(pSrcBlockInfo-&gt;m_Allocations, srcAllocIndex);</div>
-<div class="line"><a name="l13181"></a><span class="lineno">13181</span>&#160; </div>
-<div class="line"><a name="l13182"></a><span class="lineno">13182</span>&#160;                <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l13183"></a><span class="lineno">13183</span>&#160;            }</div>
-<div class="line"><a name="l13184"></a><span class="lineno">13184</span>&#160;        }</div>
+<div class="line"><a name="l12971"></a><span class="lineno">12971</span>&#160;        <span class="keywordflow">return</span> VK_ERROR_FEATURE_NOT_PRESENT;</div>
+<div class="line"><a name="l12972"></a><span class="lineno">12972</span>&#160;    }</div>
+<div class="line"><a name="l12973"></a><span class="lineno">12973</span>&#160; </div>
+<div class="line"><a name="l12974"></a><span class="lineno">12974</span>&#160;    VmaMutexLockRead lock(m_Mutex, m_hAllocator-&gt;m_UseMutex);</div>
+<div class="line"><a name="l12975"></a><span class="lineno">12975</span>&#160;    <span class="keywordflow">for</span>(uint32_t blockIndex = 0; blockIndex &lt; m_Blocks.size(); ++blockIndex)</div>
+<div class="line"><a name="l12976"></a><span class="lineno">12976</span>&#160;    {</div>
+<div class="line"><a name="l12977"></a><span class="lineno">12977</span>&#160;        VmaDeviceMemoryBlock* <span class="keyword">const</span> pBlock = m_Blocks[blockIndex];</div>
+<div class="line"><a name="l12978"></a><span class="lineno">12978</span>&#160;        VMA_ASSERT(pBlock);</div>
+<div class="line"><a name="l12979"></a><span class="lineno">12979</span>&#160;        VkResult res = pBlock-&gt;CheckCorruption(m_hAllocator);</div>
+<div class="line"><a name="l12980"></a><span class="lineno">12980</span>&#160;        <span class="keywordflow">if</span>(res != VK_SUCCESS)</div>
+<div class="line"><a name="l12981"></a><span class="lineno">12981</span>&#160;        {</div>
+<div class="line"><a name="l12982"></a><span class="lineno">12982</span>&#160;            <span class="keywordflow">return</span> res;</div>
+<div class="line"><a name="l12983"></a><span class="lineno">12983</span>&#160;        }</div>
+<div class="line"><a name="l12984"></a><span class="lineno">12984</span>&#160;    }</div>
+<div class="line"><a name="l12985"></a><span class="lineno">12985</span>&#160;    <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l12986"></a><span class="lineno">12986</span>&#160;}</div>
+<div class="line"><a name="l12987"></a><span class="lineno">12987</span>&#160; </div>
+<div class="line"><a name="l12988"></a><span class="lineno">12988</span>&#160;<span class="keywordtype">void</span> VmaBlockVector::AddStats(<a class="code" href="struct_vma_stats.html">VmaStats</a>* pStats)</div>
+<div class="line"><a name="l12989"></a><span class="lineno">12989</span>&#160;{</div>
+<div class="line"><a name="l12990"></a><span class="lineno">12990</span>&#160;    <span class="keyword">const</span> uint32_t memTypeIndex = m_MemoryTypeIndex;</div>
+<div class="line"><a name="l12991"></a><span class="lineno">12991</span>&#160;    <span class="keyword">const</span> uint32_t memHeapIndex = m_hAllocator-&gt;MemoryTypeIndexToHeapIndex(memTypeIndex);</div>
+<div class="line"><a name="l12992"></a><span class="lineno">12992</span>&#160; </div>
+<div class="line"><a name="l12993"></a><span class="lineno">12993</span>&#160;    VmaMutexLockRead lock(m_Mutex, m_hAllocator-&gt;m_UseMutex);</div>
+<div class="line"><a name="l12994"></a><span class="lineno">12994</span>&#160; </div>
+<div class="line"><a name="l12995"></a><span class="lineno">12995</span>&#160;    <span class="keywordflow">for</span>(uint32_t blockIndex = 0; blockIndex &lt; m_Blocks.size(); ++blockIndex)</div>
+<div class="line"><a name="l12996"></a><span class="lineno">12996</span>&#160;    {</div>
+<div class="line"><a name="l12997"></a><span class="lineno">12997</span>&#160;        <span class="keyword">const</span> VmaDeviceMemoryBlock* <span class="keyword">const</span> pBlock = m_Blocks[blockIndex];</div>
+<div class="line"><a name="l12998"></a><span class="lineno">12998</span>&#160;        VMA_ASSERT(pBlock);</div>
+<div class="line"><a name="l12999"></a><span class="lineno">12999</span>&#160;        VMA_HEAVY_ASSERT(pBlock-&gt;Validate());</div>
+<div class="line"><a name="l13000"></a><span class="lineno">13000</span>&#160;        <a class="code" href="struct_vma_stat_info.html">VmaStatInfo</a> allocationStatInfo;</div>
+<div class="line"><a name="l13001"></a><span class="lineno">13001</span>&#160;        pBlock-&gt;m_pMetadata-&gt;CalcAllocationStatInfo(allocationStatInfo);</div>
+<div class="line"><a name="l13002"></a><span class="lineno">13002</span>&#160;        VmaAddStatInfo(pStats-&gt;<a class="code" href="struct_vma_stats.html#a2e8f5b3353f2fefef3c27f29e245a1f9">total</a>, allocationStatInfo);</div>
+<div class="line"><a name="l13003"></a><span class="lineno">13003</span>&#160;        VmaAddStatInfo(pStats-&gt;<a class="code" href="struct_vma_stats.html#a13e3caf754be79352c42408756309331">memoryType</a>[memTypeIndex], allocationStatInfo);</div>
+<div class="line"><a name="l13004"></a><span class="lineno">13004</span>&#160;        VmaAddStatInfo(pStats-&gt;<a class="code" href="struct_vma_stats.html#a0e6611508c29a187f0fd14ff1a0329c0">memoryHeap</a>[memHeapIndex], allocationStatInfo);</div>
+<div class="line"><a name="l13005"></a><span class="lineno">13005</span>&#160;    }</div>
+<div class="line"><a name="l13006"></a><span class="lineno">13006</span>&#160;}</div>
+<div class="line"><a name="l13007"></a><span class="lineno">13007</span>&#160; </div>
+<div class="line"><a name="l13009"></a><span class="lineno">13009</span>&#160;<span class="comment">// VmaDefragmentationAlgorithm_Generic members definition</span></div>
+<div class="line"><a name="l13010"></a><span class="lineno">13010</span>&#160; </div>
+<div class="line"><a name="l13011"></a><span class="lineno">13011</span>&#160;VmaDefragmentationAlgorithm_Generic::VmaDefragmentationAlgorithm_Generic(</div>
+<div class="line"><a name="l13012"></a><span class="lineno">13012</span>&#160;    <a class="code" href="struct_vma_allocator.html">VmaAllocator</a> hAllocator,</div>
+<div class="line"><a name="l13013"></a><span class="lineno">13013</span>&#160;    VmaBlockVector* pBlockVector,</div>
+<div class="line"><a name="l13014"></a><span class="lineno">13014</span>&#160;    uint32_t currentFrameIndex,</div>
+<div class="line"><a name="l13015"></a><span class="lineno">13015</span>&#160;    <span class="keywordtype">bool</span> overlappingMoveSupported) :</div>
+<div class="line"><a name="l13016"></a><span class="lineno">13016</span>&#160;    VmaDefragmentationAlgorithm(hAllocator, pBlockVector, currentFrameIndex),</div>
+<div class="line"><a name="l13017"></a><span class="lineno">13017</span>&#160;    m_AllocationCount(0),</div>
+<div class="line"><a name="l13018"></a><span class="lineno">13018</span>&#160;    m_AllAllocations(false),</div>
+<div class="line"><a name="l13019"></a><span class="lineno">13019</span>&#160;    m_BytesMoved(0),</div>
+<div class="line"><a name="l13020"></a><span class="lineno">13020</span>&#160;    m_AllocationsMoved(0),</div>
+<div class="line"><a name="l13021"></a><span class="lineno">13021</span>&#160;    m_Blocks(VmaStlAllocator&lt;BlockInfo*&gt;(hAllocator-&gt;GetAllocationCallbacks()))</div>
+<div class="line"><a name="l13022"></a><span class="lineno">13022</span>&#160;{</div>
+<div class="line"><a name="l13023"></a><span class="lineno">13023</span>&#160;    <span class="comment">// Create block info for each block.</span></div>
+<div class="line"><a name="l13024"></a><span class="lineno">13024</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> blockCount = m_pBlockVector-&gt;m_Blocks.size();</div>
+<div class="line"><a name="l13025"></a><span class="lineno">13025</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; blockIndex &lt; blockCount; ++blockIndex)</div>
+<div class="line"><a name="l13026"></a><span class="lineno">13026</span>&#160;    {</div>
+<div class="line"><a name="l13027"></a><span class="lineno">13027</span>&#160;        BlockInfo* pBlockInfo = vma_new(m_hAllocator, BlockInfo)(m_hAllocator-&gt;GetAllocationCallbacks());</div>
+<div class="line"><a name="l13028"></a><span class="lineno">13028</span>&#160;        pBlockInfo-&gt;m_OriginalBlockIndex = blockIndex;</div>
+<div class="line"><a name="l13029"></a><span class="lineno">13029</span>&#160;        pBlockInfo-&gt;m_pBlock = m_pBlockVector-&gt;m_Blocks[blockIndex];</div>
+<div class="line"><a name="l13030"></a><span class="lineno">13030</span>&#160;        m_Blocks.push_back(pBlockInfo);</div>
+<div class="line"><a name="l13031"></a><span class="lineno">13031</span>&#160;    }</div>
+<div class="line"><a name="l13032"></a><span class="lineno">13032</span>&#160; </div>
+<div class="line"><a name="l13033"></a><span class="lineno">13033</span>&#160;    <span class="comment">// Sort them by m_pBlock pointer value.</span></div>
+<div class="line"><a name="l13034"></a><span class="lineno">13034</span>&#160;    VMA_SORT(m_Blocks.begin(), m_Blocks.end(), BlockPointerLess());</div>
+<div class="line"><a name="l13035"></a><span class="lineno">13035</span>&#160;}</div>
+<div class="line"><a name="l13036"></a><span class="lineno">13036</span>&#160; </div>
+<div class="line"><a name="l13037"></a><span class="lineno">13037</span>&#160;VmaDefragmentationAlgorithm_Generic::~VmaDefragmentationAlgorithm_Generic()</div>
+<div class="line"><a name="l13038"></a><span class="lineno">13038</span>&#160;{</div>
+<div class="line"><a name="l13039"></a><span class="lineno">13039</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = m_Blocks.size(); i--; )</div>
+<div class="line"><a name="l13040"></a><span class="lineno">13040</span>&#160;    {</div>
+<div class="line"><a name="l13041"></a><span class="lineno">13041</span>&#160;        vma_delete(m_hAllocator, m_Blocks[i]);</div>
+<div class="line"><a name="l13042"></a><span class="lineno">13042</span>&#160;    }</div>
+<div class="line"><a name="l13043"></a><span class="lineno">13043</span>&#160;}</div>
+<div class="line"><a name="l13044"></a><span class="lineno">13044</span>&#160; </div>
+<div class="line"><a name="l13045"></a><span class="lineno">13045</span>&#160;<span class="keywordtype">void</span> VmaDefragmentationAlgorithm_Generic::AddAllocation(<a class="code" href="struct_vma_allocation.html">VmaAllocation</a> hAlloc, VkBool32* pChanged)</div>
+<div class="line"><a name="l13046"></a><span class="lineno">13046</span>&#160;{</div>
+<div class="line"><a name="l13047"></a><span class="lineno">13047</span>&#160;    <span class="comment">// Now as we are inside VmaBlockVector::m_Mutex, we can make final check if this allocation was not lost.</span></div>
+<div class="line"><a name="l13048"></a><span class="lineno">13048</span>&#160;    <span class="keywordflow">if</span>(hAlloc-&gt;GetLastUseFrameIndex() != VMA_FRAME_INDEX_LOST)</div>
+<div class="line"><a name="l13049"></a><span class="lineno">13049</span>&#160;    {</div>
+<div class="line"><a name="l13050"></a><span class="lineno">13050</span>&#160;        VmaDeviceMemoryBlock* pBlock = hAlloc-&gt;GetBlock();</div>
+<div class="line"><a name="l13051"></a><span class="lineno">13051</span>&#160;        BlockInfoVector::iterator it = VmaBinaryFindFirstNotLess(m_Blocks.begin(), m_Blocks.end(), pBlock, BlockPointerLess());</div>
+<div class="line"><a name="l13052"></a><span class="lineno">13052</span>&#160;        <span class="keywordflow">if</span>(it != m_Blocks.end() &amp;&amp; (*it)-&gt;m_pBlock == pBlock)</div>
+<div class="line"><a name="l13053"></a><span class="lineno">13053</span>&#160;        {</div>
+<div class="line"><a name="l13054"></a><span class="lineno">13054</span>&#160;            AllocationInfo allocInfo = AllocationInfo(hAlloc, pChanged);</div>
+<div class="line"><a name="l13055"></a><span class="lineno">13055</span>&#160;            (*it)-&gt;m_Allocations.push_back(allocInfo);</div>
+<div class="line"><a name="l13056"></a><span class="lineno">13056</span>&#160;        }</div>
+<div class="line"><a name="l13057"></a><span class="lineno">13057</span>&#160;        <span class="keywordflow">else</span></div>
+<div class="line"><a name="l13058"></a><span class="lineno">13058</span>&#160;        {</div>
+<div class="line"><a name="l13059"></a><span class="lineno">13059</span>&#160;            VMA_ASSERT(0);</div>
+<div class="line"><a name="l13060"></a><span class="lineno">13060</span>&#160;        }</div>
+<div class="line"><a name="l13061"></a><span class="lineno">13061</span>&#160; </div>
+<div class="line"><a name="l13062"></a><span class="lineno">13062</span>&#160;        ++m_AllocationCount;</div>
+<div class="line"><a name="l13063"></a><span class="lineno">13063</span>&#160;    }</div>
+<div class="line"><a name="l13064"></a><span class="lineno">13064</span>&#160;}</div>
+<div class="line"><a name="l13065"></a><span class="lineno">13065</span>&#160; </div>
+<div class="line"><a name="l13066"></a><span class="lineno">13066</span>&#160;VkResult VmaDefragmentationAlgorithm_Generic::DefragmentRound(</div>
+<div class="line"><a name="l13067"></a><span class="lineno">13067</span>&#160;    VmaVector&lt; VmaDefragmentationMove, VmaStlAllocator&lt;VmaDefragmentationMove&gt; &gt;&amp; moves,</div>
+<div class="line"><a name="l13068"></a><span class="lineno">13068</span>&#160;    VkDeviceSize maxBytesToMove,</div>
+<div class="line"><a name="l13069"></a><span class="lineno">13069</span>&#160;    uint32_t maxAllocationsToMove)</div>
+<div class="line"><a name="l13070"></a><span class="lineno">13070</span>&#160;{</div>
+<div class="line"><a name="l13071"></a><span class="lineno">13071</span>&#160;    <span class="keywordflow">if</span>(m_Blocks.empty())</div>
+<div class="line"><a name="l13072"></a><span class="lineno">13072</span>&#160;    {</div>
+<div class="line"><a name="l13073"></a><span class="lineno">13073</span>&#160;        <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l13074"></a><span class="lineno">13074</span>&#160;    }</div>
+<div class="line"><a name="l13075"></a><span class="lineno">13075</span>&#160; </div>
+<div class="line"><a name="l13076"></a><span class="lineno">13076</span>&#160;    <span class="comment">// This is a choice based on research.</span></div>
+<div class="line"><a name="l13077"></a><span class="lineno">13077</span>&#160;    <span class="comment">// Option 1:</span></div>
+<div class="line"><a name="l13078"></a><span class="lineno">13078</span>&#160;    uint32_t strategy = <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a0729e932b7ea170e3a128cad96c5cf6d">VMA_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT</a>;</div>
+<div class="line"><a name="l13079"></a><span class="lineno">13079</span>&#160;    <span class="comment">// Option 2:</span></div>
+<div class="line"><a name="l13080"></a><span class="lineno">13080</span>&#160;    <span class="comment">//uint32_t strategy = VMA_ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT;</span></div>
+<div class="line"><a name="l13081"></a><span class="lineno">13081</span>&#160;    <span class="comment">// Option 3:</span></div>
+<div class="line"><a name="l13082"></a><span class="lineno">13082</span>&#160;    <span class="comment">//uint32_t strategy = VMA_ALLOCATION_CREATE_STRATEGY_MIN_FRAGMENTATION_BIT;</span></div>
+<div class="line"><a name="l13083"></a><span class="lineno">13083</span>&#160; </div>
+<div class="line"><a name="l13084"></a><span class="lineno">13084</span>&#160;    <span class="keywordtype">size_t</span> srcBlockMinIndex = 0;</div>
+<div class="line"><a name="l13085"></a><span class="lineno">13085</span>&#160;    <span class="comment">// When FAST_ALGORITHM, move allocations from only last out of blocks that contain non-movable allocations.</span></div>
+<div class="line"><a name="l13086"></a><span class="lineno">13086</span>&#160;    <span class="comment">/*</span></div>
+<div class="line"><a name="l13087"></a><span class="lineno">13087</span>&#160;<span class="comment">    if(m_AlgorithmFlags &amp; VMA_DEFRAGMENTATION_FAST_ALGORITHM_BIT)</span></div>
+<div class="line"><a name="l13088"></a><span class="lineno">13088</span>&#160;<span class="comment">    {</span></div>
+<div class="line"><a name="l13089"></a><span class="lineno">13089</span>&#160;<span class="comment">        const size_t blocksWithNonMovableCount = CalcBlocksWithNonMovableCount();</span></div>
+<div class="line"><a name="l13090"></a><span class="lineno">13090</span>&#160;<span class="comment">        if(blocksWithNonMovableCount &gt; 0)</span></div>
+<div class="line"><a name="l13091"></a><span class="lineno">13091</span>&#160;<span class="comment">        {</span></div>
+<div class="line"><a name="l13092"></a><span class="lineno">13092</span>&#160;<span class="comment">            srcBlockMinIndex = blocksWithNonMovableCount - 1;</span></div>
+<div class="line"><a name="l13093"></a><span class="lineno">13093</span>&#160;<span class="comment">        }</span></div>
+<div class="line"><a name="l13094"></a><span class="lineno">13094</span>&#160;<span class="comment">    }</span></div>
+<div class="line"><a name="l13095"></a><span class="lineno">13095</span>&#160;<span class="comment">    */</span></div>
+<div class="line"><a name="l13096"></a><span class="lineno">13096</span>&#160; </div>
+<div class="line"><a name="l13097"></a><span class="lineno">13097</span>&#160;    <span class="keywordtype">size_t</span> srcBlockIndex = m_Blocks.size() - 1;</div>
+<div class="line"><a name="l13098"></a><span class="lineno">13098</span>&#160;    <span class="keywordtype">size_t</span> srcAllocIndex = SIZE_MAX;</div>
+<div class="line"><a name="l13099"></a><span class="lineno">13099</span>&#160;    <span class="keywordflow">for</span>(;;)</div>
+<div class="line"><a name="l13100"></a><span class="lineno">13100</span>&#160;    {</div>
+<div class="line"><a name="l13101"></a><span class="lineno">13101</span>&#160;        <span class="comment">// 1. Find next allocation to move.</span></div>
+<div class="line"><a name="l13102"></a><span class="lineno">13102</span>&#160;        <span class="comment">// 1.1. Start from last to first m_Blocks - they are sorted from most &quot;destination&quot; to most &quot;source&quot;.</span></div>
+<div class="line"><a name="l13103"></a><span class="lineno">13103</span>&#160;        <span class="comment">// 1.2. Then start from last to first m_Allocations.</span></div>
+<div class="line"><a name="l13104"></a><span class="lineno">13104</span>&#160;        <span class="keywordflow">while</span>(srcAllocIndex &gt;= m_Blocks[srcBlockIndex]-&gt;m_Allocations.size())</div>
+<div class="line"><a name="l13105"></a><span class="lineno">13105</span>&#160;        {</div>
+<div class="line"><a name="l13106"></a><span class="lineno">13106</span>&#160;            <span class="keywordflow">if</span>(m_Blocks[srcBlockIndex]-&gt;m_Allocations.empty())</div>
+<div class="line"><a name="l13107"></a><span class="lineno">13107</span>&#160;            {</div>
+<div class="line"><a name="l13108"></a><span class="lineno">13108</span>&#160;                <span class="comment">// Finished: no more allocations to process.</span></div>
+<div class="line"><a name="l13109"></a><span class="lineno">13109</span>&#160;                <span class="keywordflow">if</span>(srcBlockIndex == srcBlockMinIndex)</div>
+<div class="line"><a name="l13110"></a><span class="lineno">13110</span>&#160;                {</div>
+<div class="line"><a name="l13111"></a><span class="lineno">13111</span>&#160;                    <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l13112"></a><span class="lineno">13112</span>&#160;                }</div>
+<div class="line"><a name="l13113"></a><span class="lineno">13113</span>&#160;                <span class="keywordflow">else</span></div>
+<div class="line"><a name="l13114"></a><span class="lineno">13114</span>&#160;                {</div>
+<div class="line"><a name="l13115"></a><span class="lineno">13115</span>&#160;                    --srcBlockIndex;</div>
+<div class="line"><a name="l13116"></a><span class="lineno">13116</span>&#160;                    srcAllocIndex = SIZE_MAX;</div>
+<div class="line"><a name="l13117"></a><span class="lineno">13117</span>&#160;                }</div>
+<div class="line"><a name="l13118"></a><span class="lineno">13118</span>&#160;            }</div>
+<div class="line"><a name="l13119"></a><span class="lineno">13119</span>&#160;            <span class="keywordflow">else</span></div>
+<div class="line"><a name="l13120"></a><span class="lineno">13120</span>&#160;            {</div>
+<div class="line"><a name="l13121"></a><span class="lineno">13121</span>&#160;                srcAllocIndex = m_Blocks[srcBlockIndex]-&gt;m_Allocations.size() - 1;</div>
+<div class="line"><a name="l13122"></a><span class="lineno">13122</span>&#160;            }</div>
+<div class="line"><a name="l13123"></a><span class="lineno">13123</span>&#160;        }</div>
+<div class="line"><a name="l13124"></a><span class="lineno">13124</span>&#160;        </div>
+<div class="line"><a name="l13125"></a><span class="lineno">13125</span>&#160;        BlockInfo* pSrcBlockInfo = m_Blocks[srcBlockIndex];</div>
+<div class="line"><a name="l13126"></a><span class="lineno">13126</span>&#160;        AllocationInfo&amp; allocInfo = pSrcBlockInfo-&gt;m_Allocations[srcAllocIndex];</div>
+<div class="line"><a name="l13127"></a><span class="lineno">13127</span>&#160; </div>
+<div class="line"><a name="l13128"></a><span class="lineno">13128</span>&#160;        <span class="keyword">const</span> VkDeviceSize size = allocInfo.m_hAllocation-&gt;GetSize();</div>
+<div class="line"><a name="l13129"></a><span class="lineno">13129</span>&#160;        <span class="keyword">const</span> VkDeviceSize srcOffset = allocInfo.m_hAllocation-&gt;GetOffset();</div>
+<div class="line"><a name="l13130"></a><span class="lineno">13130</span>&#160;        <span class="keyword">const</span> VkDeviceSize alignment = allocInfo.m_hAllocation-&gt;GetAlignment();</div>
+<div class="line"><a name="l13131"></a><span class="lineno">13131</span>&#160;        <span class="keyword">const</span> VmaSuballocationType suballocType = allocInfo.m_hAllocation-&gt;GetSuballocationType();</div>
+<div class="line"><a name="l13132"></a><span class="lineno">13132</span>&#160; </div>
+<div class="line"><a name="l13133"></a><span class="lineno">13133</span>&#160;        <span class="comment">// 2. Try to find new place for this allocation in preceding or current block.</span></div>
+<div class="line"><a name="l13134"></a><span class="lineno">13134</span>&#160;        <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> dstBlockIndex = 0; dstBlockIndex &lt;= srcBlockIndex; ++dstBlockIndex)</div>
+<div class="line"><a name="l13135"></a><span class="lineno">13135</span>&#160;        {</div>
+<div class="line"><a name="l13136"></a><span class="lineno">13136</span>&#160;            BlockInfo* pDstBlockInfo = m_Blocks[dstBlockIndex];</div>
+<div class="line"><a name="l13137"></a><span class="lineno">13137</span>&#160;            VmaAllocationRequest dstAllocRequest;</div>
+<div class="line"><a name="l13138"></a><span class="lineno">13138</span>&#160;            <span class="keywordflow">if</span>(pDstBlockInfo-&gt;m_pBlock-&gt;m_pMetadata-&gt;CreateAllocationRequest(</div>
+<div class="line"><a name="l13139"></a><span class="lineno">13139</span>&#160;                m_CurrentFrameIndex,</div>
+<div class="line"><a name="l13140"></a><span class="lineno">13140</span>&#160;                m_pBlockVector-&gt;GetFrameInUseCount(),</div>
+<div class="line"><a name="l13141"></a><span class="lineno">13141</span>&#160;                m_pBlockVector-&gt;GetBufferImageGranularity(),</div>
+<div class="line"><a name="l13142"></a><span class="lineno">13142</span>&#160;                size,</div>
+<div class="line"><a name="l13143"></a><span class="lineno">13143</span>&#160;                alignment,</div>
+<div class="line"><a name="l13144"></a><span class="lineno">13144</span>&#160;                <span class="keyword">false</span>, <span class="comment">// upperAddress</span></div>
+<div class="line"><a name="l13145"></a><span class="lineno">13145</span>&#160;                suballocType,</div>
+<div class="line"><a name="l13146"></a><span class="lineno">13146</span>&#160;                <span class="keyword">false</span>, <span class="comment">// canMakeOtherLost</span></div>
+<div class="line"><a name="l13147"></a><span class="lineno">13147</span>&#160;                strategy,</div>
+<div class="line"><a name="l13148"></a><span class="lineno">13148</span>&#160;                &amp;dstAllocRequest) &amp;&amp;</div>
+<div class="line"><a name="l13149"></a><span class="lineno">13149</span>&#160;            MoveMakesSense(</div>
+<div class="line"><a name="l13150"></a><span class="lineno">13150</span>&#160;                dstBlockIndex, dstAllocRequest.offset, srcBlockIndex, srcOffset))</div>
+<div class="line"><a name="l13151"></a><span class="lineno">13151</span>&#160;            {</div>
+<div class="line"><a name="l13152"></a><span class="lineno">13152</span>&#160;                VMA_ASSERT(dstAllocRequest.itemsToMakeLostCount == 0);</div>
+<div class="line"><a name="l13153"></a><span class="lineno">13153</span>&#160; </div>
+<div class="line"><a name="l13154"></a><span class="lineno">13154</span>&#160;                <span class="comment">// Reached limit on number of allocations or bytes to move.</span></div>
+<div class="line"><a name="l13155"></a><span class="lineno">13155</span>&#160;                <span class="keywordflow">if</span>((m_AllocationsMoved + 1 &gt; maxAllocationsToMove) ||</div>
+<div class="line"><a name="l13156"></a><span class="lineno">13156</span>&#160;                    (m_BytesMoved + size &gt; maxBytesToMove))</div>
+<div class="line"><a name="l13157"></a><span class="lineno">13157</span>&#160;                {</div>
+<div class="line"><a name="l13158"></a><span class="lineno">13158</span>&#160;                    <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l13159"></a><span class="lineno">13159</span>&#160;                }</div>
+<div class="line"><a name="l13160"></a><span class="lineno">13160</span>&#160; </div>
+<div class="line"><a name="l13161"></a><span class="lineno">13161</span>&#160;                VmaDefragmentationMove move;</div>
+<div class="line"><a name="l13162"></a><span class="lineno">13162</span>&#160;                move.srcBlockIndex = pSrcBlockInfo-&gt;m_OriginalBlockIndex;</div>
+<div class="line"><a name="l13163"></a><span class="lineno">13163</span>&#160;                move.dstBlockIndex = pDstBlockInfo-&gt;m_OriginalBlockIndex;</div>
+<div class="line"><a name="l13164"></a><span class="lineno">13164</span>&#160;                move.srcOffset = srcOffset;</div>
+<div class="line"><a name="l13165"></a><span class="lineno">13165</span>&#160;                move.dstOffset = dstAllocRequest.offset;</div>
+<div class="line"><a name="l13166"></a><span class="lineno">13166</span>&#160;                move.size = size;</div>
+<div class="line"><a name="l13167"></a><span class="lineno">13167</span>&#160;                moves.push_back(move);</div>
+<div class="line"><a name="l13168"></a><span class="lineno">13168</span>&#160; </div>
+<div class="line"><a name="l13169"></a><span class="lineno">13169</span>&#160;                pDstBlockInfo-&gt;m_pBlock-&gt;m_pMetadata-&gt;Alloc(</div>
+<div class="line"><a name="l13170"></a><span class="lineno">13170</span>&#160;                    dstAllocRequest,</div>
+<div class="line"><a name="l13171"></a><span class="lineno">13171</span>&#160;                    suballocType,</div>
+<div class="line"><a name="l13172"></a><span class="lineno">13172</span>&#160;                    size,</div>
+<div class="line"><a name="l13173"></a><span class="lineno">13173</span>&#160;                    allocInfo.m_hAllocation);</div>
+<div class="line"><a name="l13174"></a><span class="lineno">13174</span>&#160;                pSrcBlockInfo-&gt;m_pBlock-&gt;m_pMetadata-&gt;FreeAtOffset(srcOffset);</div>
+<div class="line"><a name="l13175"></a><span class="lineno">13175</span>&#160;                </div>
+<div class="line"><a name="l13176"></a><span class="lineno">13176</span>&#160;                allocInfo.m_hAllocation-&gt;ChangeBlockAllocation(m_hAllocator, pDstBlockInfo-&gt;m_pBlock, dstAllocRequest.offset);</div>
+<div class="line"><a name="l13177"></a><span class="lineno">13177</span>&#160; </div>
+<div class="line"><a name="l13178"></a><span class="lineno">13178</span>&#160;                <span class="keywordflow">if</span>(allocInfo.m_pChanged != VMA_NULL)</div>
+<div class="line"><a name="l13179"></a><span class="lineno">13179</span>&#160;                {</div>
+<div class="line"><a name="l13180"></a><span class="lineno">13180</span>&#160;                    *allocInfo.m_pChanged = VK_TRUE;</div>
+<div class="line"><a name="l13181"></a><span class="lineno">13181</span>&#160;                }</div>
+<div class="line"><a name="l13182"></a><span class="lineno">13182</span>&#160; </div>
+<div class="line"><a name="l13183"></a><span class="lineno">13183</span>&#160;                ++m_AllocationsMoved;</div>
+<div class="line"><a name="l13184"></a><span class="lineno">13184</span>&#160;                m_BytesMoved += size;</div>
 <div class="line"><a name="l13185"></a><span class="lineno">13185</span>&#160; </div>
-<div class="line"><a name="l13186"></a><span class="lineno">13186</span>&#160;        <span class="comment">// If not processed, this allocInfo remains in pBlockInfo-&gt;m_Allocations for next round.</span></div>
+<div class="line"><a name="l13186"></a><span class="lineno">13186</span>&#160;                VmaVectorRemove(pSrcBlockInfo-&gt;m_Allocations, srcAllocIndex);</div>
 <div class="line"><a name="l13187"></a><span class="lineno">13187</span>&#160; </div>
-<div class="line"><a name="l13188"></a><span class="lineno">13188</span>&#160;        <span class="keywordflow">if</span>(srcAllocIndex &gt; 0)</div>
-<div class="line"><a name="l13189"></a><span class="lineno">13189</span>&#160;        {</div>
-<div class="line"><a name="l13190"></a><span class="lineno">13190</span>&#160;            --srcAllocIndex;</div>
-<div class="line"><a name="l13191"></a><span class="lineno">13191</span>&#160;        }</div>
-<div class="line"><a name="l13192"></a><span class="lineno">13192</span>&#160;        <span class="keywordflow">else</span></div>
-<div class="line"><a name="l13193"></a><span class="lineno">13193</span>&#160;        {</div>
-<div class="line"><a name="l13194"></a><span class="lineno">13194</span>&#160;            <span class="keywordflow">if</span>(srcBlockIndex &gt; 0)</div>
-<div class="line"><a name="l13195"></a><span class="lineno">13195</span>&#160;            {</div>
-<div class="line"><a name="l13196"></a><span class="lineno">13196</span>&#160;                --srcBlockIndex;</div>
-<div class="line"><a name="l13197"></a><span class="lineno">13197</span>&#160;                srcAllocIndex = SIZE_MAX;</div>
-<div class="line"><a name="l13198"></a><span class="lineno">13198</span>&#160;            }</div>
-<div class="line"><a name="l13199"></a><span class="lineno">13199</span>&#160;            <span class="keywordflow">else</span></div>
-<div class="line"><a name="l13200"></a><span class="lineno">13200</span>&#160;            {</div>
-<div class="line"><a name="l13201"></a><span class="lineno">13201</span>&#160;                <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l13202"></a><span class="lineno">13202</span>&#160;            }</div>
-<div class="line"><a name="l13203"></a><span class="lineno">13203</span>&#160;        }</div>
-<div class="line"><a name="l13204"></a><span class="lineno">13204</span>&#160;    }</div>
-<div class="line"><a name="l13205"></a><span class="lineno">13205</span>&#160;}</div>
-<div class="line"><a name="l13206"></a><span class="lineno">13206</span>&#160; </div>
-<div class="line"><a name="l13207"></a><span class="lineno">13207</span>&#160;<span class="keywordtype">size_t</span> VmaDefragmentationAlgorithm_Generic::CalcBlocksWithNonMovableCount()<span class="keyword"> const</span></div>
-<div class="line"><a name="l13208"></a><span class="lineno">13208</span>&#160;<span class="keyword"></span>{</div>
-<div class="line"><a name="l13209"></a><span class="lineno">13209</span>&#160;    <span class="keywordtype">size_t</span> result = 0;</div>
-<div class="line"><a name="l13210"></a><span class="lineno">13210</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 0; i &lt; m_Blocks.size(); ++i)</div>
-<div class="line"><a name="l13211"></a><span class="lineno">13211</span>&#160;    {</div>
-<div class="line"><a name="l13212"></a><span class="lineno">13212</span>&#160;        <span class="keywordflow">if</span>(m_Blocks[i]-&gt;m_HasNonMovableAllocations)</div>
-<div class="line"><a name="l13213"></a><span class="lineno">13213</span>&#160;        {</div>
-<div class="line"><a name="l13214"></a><span class="lineno">13214</span>&#160;            ++result;</div>
-<div class="line"><a name="l13215"></a><span class="lineno">13215</span>&#160;        }</div>
-<div class="line"><a name="l13216"></a><span class="lineno">13216</span>&#160;    }</div>
-<div class="line"><a name="l13217"></a><span class="lineno">13217</span>&#160;    <span class="keywordflow">return</span> result;</div>
-<div class="line"><a name="l13218"></a><span class="lineno">13218</span>&#160;}</div>
-<div class="line"><a name="l13219"></a><span class="lineno">13219</span>&#160; </div>
-<div class="line"><a name="l13220"></a><span class="lineno">13220</span>&#160;VkResult VmaDefragmentationAlgorithm_Generic::Defragment(</div>
-<div class="line"><a name="l13221"></a><span class="lineno">13221</span>&#160;    VmaVector&lt; VmaDefragmentationMove, VmaStlAllocator&lt;VmaDefragmentationMove&gt; &gt;&amp; moves,</div>
-<div class="line"><a name="l13222"></a><span class="lineno">13222</span>&#160;    VkDeviceSize maxBytesToMove,</div>
-<div class="line"><a name="l13223"></a><span class="lineno">13223</span>&#160;    uint32_t maxAllocationsToMove)</div>
-<div class="line"><a name="l13224"></a><span class="lineno">13224</span>&#160;{</div>
-<div class="line"><a name="l13225"></a><span class="lineno">13225</span>&#160;    <span class="keywordflow">if</span>(!m_AllAllocations &amp;&amp; m_AllocationCount == 0)</div>
-<div class="line"><a name="l13226"></a><span class="lineno">13226</span>&#160;    {</div>
-<div class="line"><a name="l13227"></a><span class="lineno">13227</span>&#160;        <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l13228"></a><span class="lineno">13228</span>&#160;    }</div>
-<div class="line"><a name="l13229"></a><span class="lineno">13229</span>&#160; </div>
-<div class="line"><a name="l13230"></a><span class="lineno">13230</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> blockCount = m_Blocks.size();</div>
-<div class="line"><a name="l13231"></a><span class="lineno">13231</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; blockIndex &lt; blockCount; ++blockIndex)</div>
+<div class="line"><a name="l13188"></a><span class="lineno">13188</span>&#160;                <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l13189"></a><span class="lineno">13189</span>&#160;            }</div>
+<div class="line"><a name="l13190"></a><span class="lineno">13190</span>&#160;        }</div>
+<div class="line"><a name="l13191"></a><span class="lineno">13191</span>&#160; </div>
+<div class="line"><a name="l13192"></a><span class="lineno">13192</span>&#160;        <span class="comment">// If not processed, this allocInfo remains in pBlockInfo-&gt;m_Allocations for next round.</span></div>
+<div class="line"><a name="l13193"></a><span class="lineno">13193</span>&#160; </div>
+<div class="line"><a name="l13194"></a><span class="lineno">13194</span>&#160;        <span class="keywordflow">if</span>(srcAllocIndex &gt; 0)</div>
+<div class="line"><a name="l13195"></a><span class="lineno">13195</span>&#160;        {</div>
+<div class="line"><a name="l13196"></a><span class="lineno">13196</span>&#160;            --srcAllocIndex;</div>
+<div class="line"><a name="l13197"></a><span class="lineno">13197</span>&#160;        }</div>
+<div class="line"><a name="l13198"></a><span class="lineno">13198</span>&#160;        <span class="keywordflow">else</span></div>
+<div class="line"><a name="l13199"></a><span class="lineno">13199</span>&#160;        {</div>
+<div class="line"><a name="l13200"></a><span class="lineno">13200</span>&#160;            <span class="keywordflow">if</span>(srcBlockIndex &gt; 0)</div>
+<div class="line"><a name="l13201"></a><span class="lineno">13201</span>&#160;            {</div>
+<div class="line"><a name="l13202"></a><span class="lineno">13202</span>&#160;                --srcBlockIndex;</div>
+<div class="line"><a name="l13203"></a><span class="lineno">13203</span>&#160;                srcAllocIndex = SIZE_MAX;</div>
+<div class="line"><a name="l13204"></a><span class="lineno">13204</span>&#160;            }</div>
+<div class="line"><a name="l13205"></a><span class="lineno">13205</span>&#160;            <span class="keywordflow">else</span></div>
+<div class="line"><a name="l13206"></a><span class="lineno">13206</span>&#160;            {</div>
+<div class="line"><a name="l13207"></a><span class="lineno">13207</span>&#160;                <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l13208"></a><span class="lineno">13208</span>&#160;            }</div>
+<div class="line"><a name="l13209"></a><span class="lineno">13209</span>&#160;        }</div>
+<div class="line"><a name="l13210"></a><span class="lineno">13210</span>&#160;    }</div>
+<div class="line"><a name="l13211"></a><span class="lineno">13211</span>&#160;}</div>
+<div class="line"><a name="l13212"></a><span class="lineno">13212</span>&#160; </div>
+<div class="line"><a name="l13213"></a><span class="lineno">13213</span>&#160;<span class="keywordtype">size_t</span> VmaDefragmentationAlgorithm_Generic::CalcBlocksWithNonMovableCount()<span class="keyword"> const</span></div>
+<div class="line"><a name="l13214"></a><span class="lineno">13214</span>&#160;<span class="keyword"></span>{</div>
+<div class="line"><a name="l13215"></a><span class="lineno">13215</span>&#160;    <span class="keywordtype">size_t</span> result = 0;</div>
+<div class="line"><a name="l13216"></a><span class="lineno">13216</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 0; i &lt; m_Blocks.size(); ++i)</div>
+<div class="line"><a name="l13217"></a><span class="lineno">13217</span>&#160;    {</div>
+<div class="line"><a name="l13218"></a><span class="lineno">13218</span>&#160;        <span class="keywordflow">if</span>(m_Blocks[i]-&gt;m_HasNonMovableAllocations)</div>
+<div class="line"><a name="l13219"></a><span class="lineno">13219</span>&#160;        {</div>
+<div class="line"><a name="l13220"></a><span class="lineno">13220</span>&#160;            ++result;</div>
+<div class="line"><a name="l13221"></a><span class="lineno">13221</span>&#160;        }</div>
+<div class="line"><a name="l13222"></a><span class="lineno">13222</span>&#160;    }</div>
+<div class="line"><a name="l13223"></a><span class="lineno">13223</span>&#160;    <span class="keywordflow">return</span> result;</div>
+<div class="line"><a name="l13224"></a><span class="lineno">13224</span>&#160;}</div>
+<div class="line"><a name="l13225"></a><span class="lineno">13225</span>&#160; </div>
+<div class="line"><a name="l13226"></a><span class="lineno">13226</span>&#160;VkResult VmaDefragmentationAlgorithm_Generic::Defragment(</div>
+<div class="line"><a name="l13227"></a><span class="lineno">13227</span>&#160;    VmaVector&lt; VmaDefragmentationMove, VmaStlAllocator&lt;VmaDefragmentationMove&gt; &gt;&amp; moves,</div>
+<div class="line"><a name="l13228"></a><span class="lineno">13228</span>&#160;    VkDeviceSize maxBytesToMove,</div>
+<div class="line"><a name="l13229"></a><span class="lineno">13229</span>&#160;    uint32_t maxAllocationsToMove)</div>
+<div class="line"><a name="l13230"></a><span class="lineno">13230</span>&#160;{</div>
+<div class="line"><a name="l13231"></a><span class="lineno">13231</span>&#160;    <span class="keywordflow">if</span>(!m_AllAllocations &amp;&amp; m_AllocationCount == 0)</div>
 <div class="line"><a name="l13232"></a><span class="lineno">13232</span>&#160;    {</div>
-<div class="line"><a name="l13233"></a><span class="lineno">13233</span>&#160;        BlockInfo* pBlockInfo = m_Blocks[blockIndex];</div>
-<div class="line"><a name="l13234"></a><span class="lineno">13234</span>&#160; </div>
-<div class="line"><a name="l13235"></a><span class="lineno">13235</span>&#160;        <span class="keywordflow">if</span>(m_AllAllocations)</div>
-<div class="line"><a name="l13236"></a><span class="lineno">13236</span>&#160;        {</div>
-<div class="line"><a name="l13237"></a><span class="lineno">13237</span>&#160;            VmaBlockMetadata_Generic* pMetadata = (VmaBlockMetadata_Generic*)pBlockInfo-&gt;m_pBlock-&gt;m_pMetadata;</div>
-<div class="line"><a name="l13238"></a><span class="lineno">13238</span>&#160;            <span class="keywordflow">for</span>(VmaSuballocationList::const_iterator it = pMetadata-&gt;m_Suballocations.begin();</div>
-<div class="line"><a name="l13239"></a><span class="lineno">13239</span>&#160;                it != pMetadata-&gt;m_Suballocations.end();</div>
-<div class="line"><a name="l13240"></a><span class="lineno">13240</span>&#160;                ++it)</div>
-<div class="line"><a name="l13241"></a><span class="lineno">13241</span>&#160;            {</div>
-<div class="line"><a name="l13242"></a><span class="lineno">13242</span>&#160;                <span class="keywordflow">if</span>(it-&gt;type != VMA_SUBALLOCATION_TYPE_FREE)</div>
-<div class="line"><a name="l13243"></a><span class="lineno">13243</span>&#160;                {</div>
-<div class="line"><a name="l13244"></a><span class="lineno">13244</span>&#160;                    AllocationInfo allocInfo = AllocationInfo(it-&gt;hAllocation, VMA_NULL);</div>
-<div class="line"><a name="l13245"></a><span class="lineno">13245</span>&#160;                    pBlockInfo-&gt;m_Allocations.push_back(allocInfo);</div>
-<div class="line"><a name="l13246"></a><span class="lineno">13246</span>&#160;                }</div>
-<div class="line"><a name="l13247"></a><span class="lineno">13247</span>&#160;            }</div>
-<div class="line"><a name="l13248"></a><span class="lineno">13248</span>&#160;        }</div>
-<div class="line"><a name="l13249"></a><span class="lineno">13249</span>&#160; </div>
-<div class="line"><a name="l13250"></a><span class="lineno">13250</span>&#160;        pBlockInfo-&gt;CalcHasNonMovableAllocations();</div>
-<div class="line"><a name="l13251"></a><span class="lineno">13251</span>&#160;        </div>
-<div class="line"><a name="l13252"></a><span class="lineno">13252</span>&#160;        <span class="comment">// This is a choice based on research.</span></div>
-<div class="line"><a name="l13253"></a><span class="lineno">13253</span>&#160;        <span class="comment">// Option 1:</span></div>
-<div class="line"><a name="l13254"></a><span class="lineno">13254</span>&#160;        pBlockInfo-&gt;SortAllocationsByOffsetDescending();</div>
-<div class="line"><a name="l13255"></a><span class="lineno">13255</span>&#160;        <span class="comment">// Option 2:</span></div>
-<div class="line"><a name="l13256"></a><span class="lineno">13256</span>&#160;        <span class="comment">//pBlockInfo-&gt;SortAllocationsBySizeDescending();</span></div>
-<div class="line"><a name="l13257"></a><span class="lineno">13257</span>&#160;    }</div>
-<div class="line"><a name="l13258"></a><span class="lineno">13258</span>&#160; </div>
-<div class="line"><a name="l13259"></a><span class="lineno">13259</span>&#160;    <span class="comment">// Sort m_Blocks this time by the main criterium, from most &quot;destination&quot; to most &quot;source&quot; blocks.</span></div>
-<div class="line"><a name="l13260"></a><span class="lineno">13260</span>&#160;    VMA_SORT(m_Blocks.begin(), m_Blocks.end(), BlockInfoCompareMoveDestination());</div>
-<div class="line"><a name="l13261"></a><span class="lineno">13261</span>&#160; </div>
-<div class="line"><a name="l13262"></a><span class="lineno">13262</span>&#160;    <span class="comment">// This is a choice based on research.</span></div>
-<div class="line"><a name="l13263"></a><span class="lineno">13263</span>&#160;    <span class="keyword">const</span> uint32_t roundCount = 2;</div>
+<div class="line"><a name="l13233"></a><span class="lineno">13233</span>&#160;        <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l13234"></a><span class="lineno">13234</span>&#160;    }</div>
+<div class="line"><a name="l13235"></a><span class="lineno">13235</span>&#160; </div>
+<div class="line"><a name="l13236"></a><span class="lineno">13236</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> blockCount = m_Blocks.size();</div>
+<div class="line"><a name="l13237"></a><span class="lineno">13237</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; blockIndex &lt; blockCount; ++blockIndex)</div>
+<div class="line"><a name="l13238"></a><span class="lineno">13238</span>&#160;    {</div>
+<div class="line"><a name="l13239"></a><span class="lineno">13239</span>&#160;        BlockInfo* pBlockInfo = m_Blocks[blockIndex];</div>
+<div class="line"><a name="l13240"></a><span class="lineno">13240</span>&#160; </div>
+<div class="line"><a name="l13241"></a><span class="lineno">13241</span>&#160;        <span class="keywordflow">if</span>(m_AllAllocations)</div>
+<div class="line"><a name="l13242"></a><span class="lineno">13242</span>&#160;        {</div>
+<div class="line"><a name="l13243"></a><span class="lineno">13243</span>&#160;            VmaBlockMetadata_Generic* pMetadata = (VmaBlockMetadata_Generic*)pBlockInfo-&gt;m_pBlock-&gt;m_pMetadata;</div>
+<div class="line"><a name="l13244"></a><span class="lineno">13244</span>&#160;            <span class="keywordflow">for</span>(VmaSuballocationList::const_iterator it = pMetadata-&gt;m_Suballocations.begin();</div>
+<div class="line"><a name="l13245"></a><span class="lineno">13245</span>&#160;                it != pMetadata-&gt;m_Suballocations.end();</div>
+<div class="line"><a name="l13246"></a><span class="lineno">13246</span>&#160;                ++it)</div>
+<div class="line"><a name="l13247"></a><span class="lineno">13247</span>&#160;            {</div>
+<div class="line"><a name="l13248"></a><span class="lineno">13248</span>&#160;                <span class="keywordflow">if</span>(it-&gt;type != VMA_SUBALLOCATION_TYPE_FREE)</div>
+<div class="line"><a name="l13249"></a><span class="lineno">13249</span>&#160;                {</div>
+<div class="line"><a name="l13250"></a><span class="lineno">13250</span>&#160;                    AllocationInfo allocInfo = AllocationInfo(it-&gt;hAllocation, VMA_NULL);</div>
+<div class="line"><a name="l13251"></a><span class="lineno">13251</span>&#160;                    pBlockInfo-&gt;m_Allocations.push_back(allocInfo);</div>
+<div class="line"><a name="l13252"></a><span class="lineno">13252</span>&#160;                }</div>
+<div class="line"><a name="l13253"></a><span class="lineno">13253</span>&#160;            }</div>
+<div class="line"><a name="l13254"></a><span class="lineno">13254</span>&#160;        }</div>
+<div class="line"><a name="l13255"></a><span class="lineno">13255</span>&#160; </div>
+<div class="line"><a name="l13256"></a><span class="lineno">13256</span>&#160;        pBlockInfo-&gt;CalcHasNonMovableAllocations();</div>
+<div class="line"><a name="l13257"></a><span class="lineno">13257</span>&#160;        </div>
+<div class="line"><a name="l13258"></a><span class="lineno">13258</span>&#160;        <span class="comment">// This is a choice based on research.</span></div>
+<div class="line"><a name="l13259"></a><span class="lineno">13259</span>&#160;        <span class="comment">// Option 1:</span></div>
+<div class="line"><a name="l13260"></a><span class="lineno">13260</span>&#160;        pBlockInfo-&gt;SortAllocationsByOffsetDescending();</div>
+<div class="line"><a name="l13261"></a><span class="lineno">13261</span>&#160;        <span class="comment">// Option 2:</span></div>
+<div class="line"><a name="l13262"></a><span class="lineno">13262</span>&#160;        <span class="comment">//pBlockInfo-&gt;SortAllocationsBySizeDescending();</span></div>
+<div class="line"><a name="l13263"></a><span class="lineno">13263</span>&#160;    }</div>
 <div class="line"><a name="l13264"></a><span class="lineno">13264</span>&#160; </div>
-<div class="line"><a name="l13265"></a><span class="lineno">13265</span>&#160;    <span class="comment">// Execute defragmentation rounds (the main part).</span></div>
-<div class="line"><a name="l13266"></a><span class="lineno">13266</span>&#160;    VkResult result = VK_SUCCESS;</div>
-<div class="line"><a name="l13267"></a><span class="lineno">13267</span>&#160;    <span class="keywordflow">for</span>(uint32_t round = 0; (round &lt; roundCount) &amp;&amp; (result == VK_SUCCESS); ++round)</div>
-<div class="line"><a name="l13268"></a><span class="lineno">13268</span>&#160;    {</div>
-<div class="line"><a name="l13269"></a><span class="lineno">13269</span>&#160;        result = DefragmentRound(moves, maxBytesToMove, maxAllocationsToMove);</div>
-<div class="line"><a name="l13270"></a><span class="lineno">13270</span>&#160;    }</div>
-<div class="line"><a name="l13271"></a><span class="lineno">13271</span>&#160; </div>
-<div class="line"><a name="l13272"></a><span class="lineno">13272</span>&#160;    <span class="keywordflow">return</span> result;</div>
-<div class="line"><a name="l13273"></a><span class="lineno">13273</span>&#160;}</div>
-<div class="line"><a name="l13274"></a><span class="lineno">13274</span>&#160; </div>
-<div class="line"><a name="l13275"></a><span class="lineno">13275</span>&#160;<span class="keywordtype">bool</span> VmaDefragmentationAlgorithm_Generic::MoveMakesSense(</div>
-<div class="line"><a name="l13276"></a><span class="lineno">13276</span>&#160;        <span class="keywordtype">size_t</span> dstBlockIndex, VkDeviceSize dstOffset,</div>
-<div class="line"><a name="l13277"></a><span class="lineno">13277</span>&#160;        <span class="keywordtype">size_t</span> srcBlockIndex, VkDeviceSize srcOffset)</div>
-<div class="line"><a name="l13278"></a><span class="lineno">13278</span>&#160;{</div>
-<div class="line"><a name="l13279"></a><span class="lineno">13279</span>&#160;    <span class="keywordflow">if</span>(dstBlockIndex &lt; srcBlockIndex)</div>
-<div class="line"><a name="l13280"></a><span class="lineno">13280</span>&#160;    {</div>
-<div class="line"><a name="l13281"></a><span class="lineno">13281</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
-<div class="line"><a name="l13282"></a><span class="lineno">13282</span>&#160;    }</div>
-<div class="line"><a name="l13283"></a><span class="lineno">13283</span>&#160;    <span class="keywordflow">if</span>(dstBlockIndex &gt; srcBlockIndex)</div>
-<div class="line"><a name="l13284"></a><span class="lineno">13284</span>&#160;    {</div>
-<div class="line"><a name="l13285"></a><span class="lineno">13285</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
-<div class="line"><a name="l13286"></a><span class="lineno">13286</span>&#160;    }</div>
-<div class="line"><a name="l13287"></a><span class="lineno">13287</span>&#160;    <span class="keywordflow">if</span>(dstOffset &lt; srcOffset)</div>
-<div class="line"><a name="l13288"></a><span class="lineno">13288</span>&#160;    {</div>
-<div class="line"><a name="l13289"></a><span class="lineno">13289</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
-<div class="line"><a name="l13290"></a><span class="lineno">13290</span>&#160;    }</div>
-<div class="line"><a name="l13291"></a><span class="lineno">13291</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
-<div class="line"><a name="l13292"></a><span class="lineno">13292</span>&#160;}</div>
-<div class="line"><a name="l13293"></a><span class="lineno">13293</span>&#160; </div>
-<div class="line"><a name="l13295"></a><span class="lineno">13295</span>&#160;<span class="comment">// VmaDefragmentationAlgorithm_Fast</span></div>
-<div class="line"><a name="l13296"></a><span class="lineno">13296</span>&#160; </div>
-<div class="line"><a name="l13297"></a><span class="lineno">13297</span>&#160;VmaDefragmentationAlgorithm_Fast::VmaDefragmentationAlgorithm_Fast(</div>
-<div class="line"><a name="l13298"></a><span class="lineno">13298</span>&#160;    <a class="code" href="struct_vma_allocator.html">VmaAllocator</a> hAllocator,</div>
-<div class="line"><a name="l13299"></a><span class="lineno">13299</span>&#160;    VmaBlockVector* pBlockVector,</div>
-<div class="line"><a name="l13300"></a><span class="lineno">13300</span>&#160;    uint32_t currentFrameIndex,</div>
-<div class="line"><a name="l13301"></a><span class="lineno">13301</span>&#160;    <span class="keywordtype">bool</span> overlappingMoveSupported) :</div>
-<div class="line"><a name="l13302"></a><span class="lineno">13302</span>&#160;    VmaDefragmentationAlgorithm(hAllocator, pBlockVector, currentFrameIndex),</div>
-<div class="line"><a name="l13303"></a><span class="lineno">13303</span>&#160;    m_OverlappingMoveSupported(overlappingMoveSupported),</div>
-<div class="line"><a name="l13304"></a><span class="lineno">13304</span>&#160;    m_AllocationCount(0),</div>
-<div class="line"><a name="l13305"></a><span class="lineno">13305</span>&#160;    m_AllAllocations(false),</div>
-<div class="line"><a name="l13306"></a><span class="lineno">13306</span>&#160;    m_BytesMoved(0),</div>
-<div class="line"><a name="l13307"></a><span class="lineno">13307</span>&#160;    m_AllocationsMoved(0),</div>
-<div class="line"><a name="l13308"></a><span class="lineno">13308</span>&#160;    m_BlockInfos(VmaStlAllocator&lt;BlockInfo&gt;(hAllocator-&gt;GetAllocationCallbacks()))</div>
-<div class="line"><a name="l13309"></a><span class="lineno">13309</span>&#160;{</div>
-<div class="line"><a name="l13310"></a><span class="lineno">13310</span>&#160;    VMA_ASSERT(VMA_DEBUG_MARGIN == 0);</div>
-<div class="line"><a name="l13311"></a><span class="lineno">13311</span>&#160; </div>
-<div class="line"><a name="l13312"></a><span class="lineno">13312</span>&#160;}</div>
-<div class="line"><a name="l13313"></a><span class="lineno">13313</span>&#160; </div>
-<div class="line"><a name="l13314"></a><span class="lineno">13314</span>&#160;VmaDefragmentationAlgorithm_Fast::~VmaDefragmentationAlgorithm_Fast()</div>
+<div class="line"><a name="l13265"></a><span class="lineno">13265</span>&#160;    <span class="comment">// Sort m_Blocks this time by the main criterium, from most &quot;destination&quot; to most &quot;source&quot; blocks.</span></div>
+<div class="line"><a name="l13266"></a><span class="lineno">13266</span>&#160;    VMA_SORT(m_Blocks.begin(), m_Blocks.end(), BlockInfoCompareMoveDestination());</div>
+<div class="line"><a name="l13267"></a><span class="lineno">13267</span>&#160; </div>
+<div class="line"><a name="l13268"></a><span class="lineno">13268</span>&#160;    <span class="comment">// This is a choice based on research.</span></div>
+<div class="line"><a name="l13269"></a><span class="lineno">13269</span>&#160;    <span class="keyword">const</span> uint32_t roundCount = 2;</div>
+<div class="line"><a name="l13270"></a><span class="lineno">13270</span>&#160; </div>
+<div class="line"><a name="l13271"></a><span class="lineno">13271</span>&#160;    <span class="comment">// Execute defragmentation rounds (the main part).</span></div>
+<div class="line"><a name="l13272"></a><span class="lineno">13272</span>&#160;    VkResult result = VK_SUCCESS;</div>
+<div class="line"><a name="l13273"></a><span class="lineno">13273</span>&#160;    <span class="keywordflow">for</span>(uint32_t round = 0; (round &lt; roundCount) &amp;&amp; (result == VK_SUCCESS); ++round)</div>
+<div class="line"><a name="l13274"></a><span class="lineno">13274</span>&#160;    {</div>
+<div class="line"><a name="l13275"></a><span class="lineno">13275</span>&#160;        result = DefragmentRound(moves, maxBytesToMove, maxAllocationsToMove);</div>
+<div class="line"><a name="l13276"></a><span class="lineno">13276</span>&#160;    }</div>
+<div class="line"><a name="l13277"></a><span class="lineno">13277</span>&#160; </div>
+<div class="line"><a name="l13278"></a><span class="lineno">13278</span>&#160;    <span class="keywordflow">return</span> result;</div>
+<div class="line"><a name="l13279"></a><span class="lineno">13279</span>&#160;}</div>
+<div class="line"><a name="l13280"></a><span class="lineno">13280</span>&#160; </div>
+<div class="line"><a name="l13281"></a><span class="lineno">13281</span>&#160;<span class="keywordtype">bool</span> VmaDefragmentationAlgorithm_Generic::MoveMakesSense(</div>
+<div class="line"><a name="l13282"></a><span class="lineno">13282</span>&#160;        <span class="keywordtype">size_t</span> dstBlockIndex, VkDeviceSize dstOffset,</div>
+<div class="line"><a name="l13283"></a><span class="lineno">13283</span>&#160;        <span class="keywordtype">size_t</span> srcBlockIndex, VkDeviceSize srcOffset)</div>
+<div class="line"><a name="l13284"></a><span class="lineno">13284</span>&#160;{</div>
+<div class="line"><a name="l13285"></a><span class="lineno">13285</span>&#160;    <span class="keywordflow">if</span>(dstBlockIndex &lt; srcBlockIndex)</div>
+<div class="line"><a name="l13286"></a><span class="lineno">13286</span>&#160;    {</div>
+<div class="line"><a name="l13287"></a><span class="lineno">13287</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
+<div class="line"><a name="l13288"></a><span class="lineno">13288</span>&#160;    }</div>
+<div class="line"><a name="l13289"></a><span class="lineno">13289</span>&#160;    <span class="keywordflow">if</span>(dstBlockIndex &gt; srcBlockIndex)</div>
+<div class="line"><a name="l13290"></a><span class="lineno">13290</span>&#160;    {</div>
+<div class="line"><a name="l13291"></a><span class="lineno">13291</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
+<div class="line"><a name="l13292"></a><span class="lineno">13292</span>&#160;    }</div>
+<div class="line"><a name="l13293"></a><span class="lineno">13293</span>&#160;    <span class="keywordflow">if</span>(dstOffset &lt; srcOffset)</div>
+<div class="line"><a name="l13294"></a><span class="lineno">13294</span>&#160;    {</div>
+<div class="line"><a name="l13295"></a><span class="lineno">13295</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
+<div class="line"><a name="l13296"></a><span class="lineno">13296</span>&#160;    }</div>
+<div class="line"><a name="l13297"></a><span class="lineno">13297</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
+<div class="line"><a name="l13298"></a><span class="lineno">13298</span>&#160;}</div>
+<div class="line"><a name="l13299"></a><span class="lineno">13299</span>&#160; </div>
+<div class="line"><a name="l13301"></a><span class="lineno">13301</span>&#160;<span class="comment">// VmaDefragmentationAlgorithm_Fast</span></div>
+<div class="line"><a name="l13302"></a><span class="lineno">13302</span>&#160; </div>
+<div class="line"><a name="l13303"></a><span class="lineno">13303</span>&#160;VmaDefragmentationAlgorithm_Fast::VmaDefragmentationAlgorithm_Fast(</div>
+<div class="line"><a name="l13304"></a><span class="lineno">13304</span>&#160;    <a class="code" href="struct_vma_allocator.html">VmaAllocator</a> hAllocator,</div>
+<div class="line"><a name="l13305"></a><span class="lineno">13305</span>&#160;    VmaBlockVector* pBlockVector,</div>
+<div class="line"><a name="l13306"></a><span class="lineno">13306</span>&#160;    uint32_t currentFrameIndex,</div>
+<div class="line"><a name="l13307"></a><span class="lineno">13307</span>&#160;    <span class="keywordtype">bool</span> overlappingMoveSupported) :</div>
+<div class="line"><a name="l13308"></a><span class="lineno">13308</span>&#160;    VmaDefragmentationAlgorithm(hAllocator, pBlockVector, currentFrameIndex),</div>
+<div class="line"><a name="l13309"></a><span class="lineno">13309</span>&#160;    m_OverlappingMoveSupported(overlappingMoveSupported),</div>
+<div class="line"><a name="l13310"></a><span class="lineno">13310</span>&#160;    m_AllocationCount(0),</div>
+<div class="line"><a name="l13311"></a><span class="lineno">13311</span>&#160;    m_AllAllocations(false),</div>
+<div class="line"><a name="l13312"></a><span class="lineno">13312</span>&#160;    m_BytesMoved(0),</div>
+<div class="line"><a name="l13313"></a><span class="lineno">13313</span>&#160;    m_AllocationsMoved(0),</div>
+<div class="line"><a name="l13314"></a><span class="lineno">13314</span>&#160;    m_BlockInfos(VmaStlAllocator&lt;BlockInfo&gt;(hAllocator-&gt;GetAllocationCallbacks()))</div>
 <div class="line"><a name="l13315"></a><span class="lineno">13315</span>&#160;{</div>
-<div class="line"><a name="l13316"></a><span class="lineno">13316</span>&#160;}</div>
+<div class="line"><a name="l13316"></a><span class="lineno">13316</span>&#160;    VMA_ASSERT(VMA_DEBUG_MARGIN == 0);</div>
 <div class="line"><a name="l13317"></a><span class="lineno">13317</span>&#160; </div>
-<div class="line"><a name="l13318"></a><span class="lineno">13318</span>&#160;VkResult VmaDefragmentationAlgorithm_Fast::Defragment(</div>
-<div class="line"><a name="l13319"></a><span class="lineno">13319</span>&#160;    VmaVector&lt; VmaDefragmentationMove, VmaStlAllocator&lt;VmaDefragmentationMove&gt; &gt;&amp; moves,</div>
-<div class="line"><a name="l13320"></a><span class="lineno">13320</span>&#160;    VkDeviceSize maxBytesToMove,</div>
-<div class="line"><a name="l13321"></a><span class="lineno">13321</span>&#160;    uint32_t maxAllocationsToMove)</div>
-<div class="line"><a name="l13322"></a><span class="lineno">13322</span>&#160;{</div>
-<div class="line"><a name="l13323"></a><span class="lineno">13323</span>&#160;    VMA_ASSERT(m_AllAllocations || m_pBlockVector-&gt;CalcAllocationCount() == m_AllocationCount);</div>
-<div class="line"><a name="l13324"></a><span class="lineno">13324</span>&#160; </div>
-<div class="line"><a name="l13325"></a><span class="lineno">13325</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> blockCount = m_pBlockVector-&gt;GetBlockCount();</div>
-<div class="line"><a name="l13326"></a><span class="lineno">13326</span>&#160;    <span class="keywordflow">if</span>(blockCount == 0 || maxBytesToMove == 0 || maxAllocationsToMove == 0)</div>
-<div class="line"><a name="l13327"></a><span class="lineno">13327</span>&#160;    {</div>
-<div class="line"><a name="l13328"></a><span class="lineno">13328</span>&#160;        <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l13329"></a><span class="lineno">13329</span>&#160;    }</div>
+<div class="line"><a name="l13318"></a><span class="lineno">13318</span>&#160;}</div>
+<div class="line"><a name="l13319"></a><span class="lineno">13319</span>&#160; </div>
+<div class="line"><a name="l13320"></a><span class="lineno">13320</span>&#160;VmaDefragmentationAlgorithm_Fast::~VmaDefragmentationAlgorithm_Fast()</div>
+<div class="line"><a name="l13321"></a><span class="lineno">13321</span>&#160;{</div>
+<div class="line"><a name="l13322"></a><span class="lineno">13322</span>&#160;}</div>
+<div class="line"><a name="l13323"></a><span class="lineno">13323</span>&#160; </div>
+<div class="line"><a name="l13324"></a><span class="lineno">13324</span>&#160;VkResult VmaDefragmentationAlgorithm_Fast::Defragment(</div>
+<div class="line"><a name="l13325"></a><span class="lineno">13325</span>&#160;    VmaVector&lt; VmaDefragmentationMove, VmaStlAllocator&lt;VmaDefragmentationMove&gt; &gt;&amp; moves,</div>
+<div class="line"><a name="l13326"></a><span class="lineno">13326</span>&#160;    VkDeviceSize maxBytesToMove,</div>
+<div class="line"><a name="l13327"></a><span class="lineno">13327</span>&#160;    uint32_t maxAllocationsToMove)</div>
+<div class="line"><a name="l13328"></a><span class="lineno">13328</span>&#160;{</div>
+<div class="line"><a name="l13329"></a><span class="lineno">13329</span>&#160;    VMA_ASSERT(m_AllAllocations || m_pBlockVector-&gt;CalcAllocationCount() == m_AllocationCount);</div>
 <div class="line"><a name="l13330"></a><span class="lineno">13330</span>&#160; </div>
-<div class="line"><a name="l13331"></a><span class="lineno">13331</span>&#160;    PreprocessMetadata();</div>
-<div class="line"><a name="l13332"></a><span class="lineno">13332</span>&#160; </div>
-<div class="line"><a name="l13333"></a><span class="lineno">13333</span>&#160;    <span class="comment">// Sort blocks in order from most destination.</span></div>
-<div class="line"><a name="l13334"></a><span class="lineno">13334</span>&#160; </div>
-<div class="line"><a name="l13335"></a><span class="lineno">13335</span>&#160;    m_BlockInfos.resize(blockCount);</div>
-<div class="line"><a name="l13336"></a><span class="lineno">13336</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 0; i &lt; blockCount; ++i)</div>
-<div class="line"><a name="l13337"></a><span class="lineno">13337</span>&#160;    {</div>
-<div class="line"><a name="l13338"></a><span class="lineno">13338</span>&#160;        m_BlockInfos[i].origBlockIndex = i;</div>
-<div class="line"><a name="l13339"></a><span class="lineno">13339</span>&#160;    }</div>
+<div class="line"><a name="l13331"></a><span class="lineno">13331</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> blockCount = m_pBlockVector-&gt;GetBlockCount();</div>
+<div class="line"><a name="l13332"></a><span class="lineno">13332</span>&#160;    <span class="keywordflow">if</span>(blockCount == 0 || maxBytesToMove == 0 || maxAllocationsToMove == 0)</div>
+<div class="line"><a name="l13333"></a><span class="lineno">13333</span>&#160;    {</div>
+<div class="line"><a name="l13334"></a><span class="lineno">13334</span>&#160;        <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l13335"></a><span class="lineno">13335</span>&#160;    }</div>
+<div class="line"><a name="l13336"></a><span class="lineno">13336</span>&#160; </div>
+<div class="line"><a name="l13337"></a><span class="lineno">13337</span>&#160;    PreprocessMetadata();</div>
+<div class="line"><a name="l13338"></a><span class="lineno">13338</span>&#160; </div>
+<div class="line"><a name="l13339"></a><span class="lineno">13339</span>&#160;    <span class="comment">// Sort blocks in order from most destination.</span></div>
 <div class="line"><a name="l13340"></a><span class="lineno">13340</span>&#160; </div>
-<div class="line"><a name="l13341"></a><span class="lineno">13341</span>&#160;    VMA_SORT(m_BlockInfos.begin(), m_BlockInfos.end(), [<span class="keyword">this</span>](<span class="keyword">const</span> BlockInfo&amp; lhs, <span class="keyword">const</span> BlockInfo&amp; rhs) -&gt; <span class="keywordtype">bool</span> {</div>
-<div class="line"><a name="l13342"></a><span class="lineno">13342</span>&#160;        <span class="keywordflow">return</span> m_pBlockVector-&gt;GetBlock(lhs.origBlockIndex)-&gt;m_pMetadata-&gt;GetSumFreeSize() &lt;</div>
-<div class="line"><a name="l13343"></a><span class="lineno">13343</span>&#160;            m_pBlockVector-&gt;GetBlock(rhs.origBlockIndex)-&gt;m_pMetadata-&gt;GetSumFreeSize();</div>
-<div class="line"><a name="l13344"></a><span class="lineno">13344</span>&#160;    });</div>
-<div class="line"><a name="l13345"></a><span class="lineno">13345</span>&#160; </div>
-<div class="line"><a name="l13346"></a><span class="lineno">13346</span>&#160;    <span class="comment">// THE MAIN ALGORITHM</span></div>
-<div class="line"><a name="l13347"></a><span class="lineno">13347</span>&#160; </div>
-<div class="line"><a name="l13348"></a><span class="lineno">13348</span>&#160;    FreeSpaceDatabase freeSpaceDb;</div>
-<div class="line"><a name="l13349"></a><span class="lineno">13349</span>&#160; </div>
-<div class="line"><a name="l13350"></a><span class="lineno">13350</span>&#160;    <span class="keywordtype">size_t</span> dstBlockInfoIndex = 0;</div>
-<div class="line"><a name="l13351"></a><span class="lineno">13351</span>&#160;    <span class="keywordtype">size_t</span> dstOrigBlockIndex = m_BlockInfos[dstBlockInfoIndex].origBlockIndex;</div>
-<div class="line"><a name="l13352"></a><span class="lineno">13352</span>&#160;    VmaDeviceMemoryBlock* pDstBlock = m_pBlockVector-&gt;GetBlock(dstOrigBlockIndex);</div>
-<div class="line"><a name="l13353"></a><span class="lineno">13353</span>&#160;    VmaBlockMetadata_Generic* pDstMetadata = (VmaBlockMetadata_Generic*)pDstBlock-&gt;m_pMetadata;</div>
-<div class="line"><a name="l13354"></a><span class="lineno">13354</span>&#160;    VkDeviceSize dstBlockSize = pDstMetadata-&gt;GetSize();</div>
-<div class="line"><a name="l13355"></a><span class="lineno">13355</span>&#160;    VkDeviceSize dstOffset = 0;</div>
-<div class="line"><a name="l13356"></a><span class="lineno">13356</span>&#160; </div>
-<div class="line"><a name="l13357"></a><span class="lineno">13357</span>&#160;    <span class="keywordtype">bool</span> end = <span class="keyword">false</span>;</div>
-<div class="line"><a name="l13358"></a><span class="lineno">13358</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> srcBlockInfoIndex = 0; !end &amp;&amp; srcBlockInfoIndex &lt; blockCount; ++srcBlockInfoIndex)</div>
-<div class="line"><a name="l13359"></a><span class="lineno">13359</span>&#160;    {</div>
-<div class="line"><a name="l13360"></a><span class="lineno">13360</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">size_t</span> srcOrigBlockIndex = m_BlockInfos[srcBlockInfoIndex].origBlockIndex;</div>
-<div class="line"><a name="l13361"></a><span class="lineno">13361</span>&#160;        VmaDeviceMemoryBlock* <span class="keyword">const</span> pSrcBlock = m_pBlockVector-&gt;GetBlock(srcOrigBlockIndex);</div>
-<div class="line"><a name="l13362"></a><span class="lineno">13362</span>&#160;        VmaBlockMetadata_Generic* <span class="keyword">const</span> pSrcMetadata = (VmaBlockMetadata_Generic*)pSrcBlock-&gt;m_pMetadata;</div>
-<div class="line"><a name="l13363"></a><span class="lineno">13363</span>&#160;        <span class="keywordflow">for</span>(VmaSuballocationList::iterator srcSuballocIt = pSrcMetadata-&gt;m_Suballocations.begin();</div>
-<div class="line"><a name="l13364"></a><span class="lineno">13364</span>&#160;            !end &amp;&amp; srcSuballocIt != pSrcMetadata-&gt;m_Suballocations.end(); )</div>
-<div class="line"><a name="l13365"></a><span class="lineno">13365</span>&#160;        {</div>
-<div class="line"><a name="l13366"></a><span class="lineno">13366</span>&#160;            VmaAllocation_T* <span class="keyword">const</span> pAlloc = srcSuballocIt-&gt;hAllocation;</div>
-<div class="line"><a name="l13367"></a><span class="lineno">13367</span>&#160;            <span class="keyword">const</span> VkDeviceSize srcAllocAlignment = pAlloc-&gt;GetAlignment();</div>
-<div class="line"><a name="l13368"></a><span class="lineno">13368</span>&#160;            <span class="keyword">const</span> VkDeviceSize srcAllocSize = srcSuballocIt-&gt;size;</div>
-<div class="line"><a name="l13369"></a><span class="lineno">13369</span>&#160;            <span class="keywordflow">if</span>(m_AllocationsMoved == maxAllocationsToMove ||</div>
-<div class="line"><a name="l13370"></a><span class="lineno">13370</span>&#160;                m_BytesMoved + srcAllocSize &gt; maxBytesToMove)</div>
-<div class="line"><a name="l13371"></a><span class="lineno">13371</span>&#160;            {</div>
-<div class="line"><a name="l13372"></a><span class="lineno">13372</span>&#160;                end = <span class="keyword">true</span>;</div>
-<div class="line"><a name="l13373"></a><span class="lineno">13373</span>&#160;                <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l13374"></a><span class="lineno">13374</span>&#160;            }</div>
-<div class="line"><a name="l13375"></a><span class="lineno">13375</span>&#160;            <span class="keyword">const</span> VkDeviceSize srcAllocOffset = srcSuballocIt-&gt;offset;</div>
-<div class="line"><a name="l13376"></a><span class="lineno">13376</span>&#160; </div>
-<div class="line"><a name="l13377"></a><span class="lineno">13377</span>&#160;            <span class="comment">// Try to place it in one of free spaces from the database.</span></div>
-<div class="line"><a name="l13378"></a><span class="lineno">13378</span>&#160;            <span class="keywordtype">size_t</span> freeSpaceInfoIndex;</div>
-<div class="line"><a name="l13379"></a><span class="lineno">13379</span>&#160;            VkDeviceSize dstAllocOffset;</div>
-<div class="line"><a name="l13380"></a><span class="lineno">13380</span>&#160;            <span class="keywordflow">if</span>(freeSpaceDb.Fetch(srcAllocAlignment, srcAllocSize,</div>
-<div class="line"><a name="l13381"></a><span class="lineno">13381</span>&#160;                freeSpaceInfoIndex, dstAllocOffset))</div>
-<div class="line"><a name="l13382"></a><span class="lineno">13382</span>&#160;            {</div>
-<div class="line"><a name="l13383"></a><span class="lineno">13383</span>&#160;                <span class="keywordtype">size_t</span> freeSpaceOrigBlockIndex = m_BlockInfos[freeSpaceInfoIndex].origBlockIndex;</div>
-<div class="line"><a name="l13384"></a><span class="lineno">13384</span>&#160;                VmaDeviceMemoryBlock* pFreeSpaceBlock = m_pBlockVector-&gt;GetBlock(freeSpaceOrigBlockIndex);</div>
-<div class="line"><a name="l13385"></a><span class="lineno">13385</span>&#160;                VmaBlockMetadata_Generic* pFreeSpaceMetadata = (VmaBlockMetadata_Generic*)pFreeSpaceBlock-&gt;m_pMetadata;</div>
-<div class="line"><a name="l13386"></a><span class="lineno">13386</span>&#160; </div>
-<div class="line"><a name="l13387"></a><span class="lineno">13387</span>&#160;                <span class="comment">// Same block</span></div>
-<div class="line"><a name="l13388"></a><span class="lineno">13388</span>&#160;                <span class="keywordflow">if</span>(freeSpaceInfoIndex == srcBlockInfoIndex)</div>
-<div class="line"><a name="l13389"></a><span class="lineno">13389</span>&#160;                {</div>
-<div class="line"><a name="l13390"></a><span class="lineno">13390</span>&#160;                    VMA_ASSERT(dstAllocOffset &lt;= srcAllocOffset);</div>
-<div class="line"><a name="l13391"></a><span class="lineno">13391</span>&#160; </div>
-<div class="line"><a name="l13392"></a><span class="lineno">13392</span>&#160;                    <span class="comment">// MOVE OPTION 1: Move the allocation inside the same block by decreasing offset.</span></div>
-<div class="line"><a name="l13393"></a><span class="lineno">13393</span>&#160; </div>
-<div class="line"><a name="l13394"></a><span class="lineno">13394</span>&#160;                    VmaSuballocation suballoc = *srcSuballocIt;</div>
-<div class="line"><a name="l13395"></a><span class="lineno">13395</span>&#160;                    suballoc.offset = dstAllocOffset;</div>
-<div class="line"><a name="l13396"></a><span class="lineno">13396</span>&#160;                    suballoc.hAllocation-&gt;ChangeOffset(dstAllocOffset);</div>
-<div class="line"><a name="l13397"></a><span class="lineno">13397</span>&#160;                    m_BytesMoved += srcAllocSize;</div>
-<div class="line"><a name="l13398"></a><span class="lineno">13398</span>&#160;                    ++m_AllocationsMoved;</div>
-<div class="line"><a name="l13399"></a><span class="lineno">13399</span>&#160;                    </div>
-<div class="line"><a name="l13400"></a><span class="lineno">13400</span>&#160;                    VmaSuballocationList::iterator nextSuballocIt = srcSuballocIt;</div>
-<div class="line"><a name="l13401"></a><span class="lineno">13401</span>&#160;                    ++nextSuballocIt;</div>
-<div class="line"><a name="l13402"></a><span class="lineno">13402</span>&#160;                    pSrcMetadata-&gt;m_Suballocations.erase(srcSuballocIt);</div>
-<div class="line"><a name="l13403"></a><span class="lineno">13403</span>&#160;                    srcSuballocIt = nextSuballocIt;</div>
-<div class="line"><a name="l13404"></a><span class="lineno">13404</span>&#160; </div>
-<div class="line"><a name="l13405"></a><span class="lineno">13405</span>&#160;                    InsertSuballoc(pFreeSpaceMetadata, suballoc);</div>
-<div class="line"><a name="l13406"></a><span class="lineno">13406</span>&#160; </div>
-<div class="line"><a name="l13407"></a><span class="lineno">13407</span>&#160;                    VmaDefragmentationMove move = {</div>
-<div class="line"><a name="l13408"></a><span class="lineno">13408</span>&#160;                        srcOrigBlockIndex, freeSpaceOrigBlockIndex,</div>
-<div class="line"><a name="l13409"></a><span class="lineno">13409</span>&#160;                        srcAllocOffset, dstAllocOffset,</div>
-<div class="line"><a name="l13410"></a><span class="lineno">13410</span>&#160;                        srcAllocSize };</div>
-<div class="line"><a name="l13411"></a><span class="lineno">13411</span>&#160;                    moves.push_back(move);</div>
-<div class="line"><a name="l13412"></a><span class="lineno">13412</span>&#160;                }</div>
-<div class="line"><a name="l13413"></a><span class="lineno">13413</span>&#160;                <span class="comment">// Different block</span></div>
-<div class="line"><a name="l13414"></a><span class="lineno">13414</span>&#160;                <span class="keywordflow">else</span></div>
-<div class="line"><a name="l13415"></a><span class="lineno">13415</span>&#160;                {</div>
-<div class="line"><a name="l13416"></a><span class="lineno">13416</span>&#160;                    <span class="comment">// MOVE OPTION 2: Move the allocation to a different block.</span></div>
-<div class="line"><a name="l13417"></a><span class="lineno">13417</span>&#160; </div>
-<div class="line"><a name="l13418"></a><span class="lineno">13418</span>&#160;                    VMA_ASSERT(freeSpaceInfoIndex &lt; srcBlockInfoIndex);</div>
-<div class="line"><a name="l13419"></a><span class="lineno">13419</span>&#160; </div>
-<div class="line"><a name="l13420"></a><span class="lineno">13420</span>&#160;                    VmaSuballocation suballoc = *srcSuballocIt;</div>
-<div class="line"><a name="l13421"></a><span class="lineno">13421</span>&#160;                    suballoc.offset = dstAllocOffset;</div>
-<div class="line"><a name="l13422"></a><span class="lineno">13422</span>&#160;                    suballoc.hAllocation-&gt;ChangeBlockAllocation(m_hAllocator, pFreeSpaceBlock, dstAllocOffset);</div>
-<div class="line"><a name="l13423"></a><span class="lineno">13423</span>&#160;                    m_BytesMoved += srcAllocSize;</div>
-<div class="line"><a name="l13424"></a><span class="lineno">13424</span>&#160;                    ++m_AllocationsMoved;</div>
+<div class="line"><a name="l13341"></a><span class="lineno">13341</span>&#160;    m_BlockInfos.resize(blockCount);</div>
+<div class="line"><a name="l13342"></a><span class="lineno">13342</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 0; i &lt; blockCount; ++i)</div>
+<div class="line"><a name="l13343"></a><span class="lineno">13343</span>&#160;    {</div>
+<div class="line"><a name="l13344"></a><span class="lineno">13344</span>&#160;        m_BlockInfos[i].origBlockIndex = i;</div>
+<div class="line"><a name="l13345"></a><span class="lineno">13345</span>&#160;    }</div>
+<div class="line"><a name="l13346"></a><span class="lineno">13346</span>&#160; </div>
+<div class="line"><a name="l13347"></a><span class="lineno">13347</span>&#160;    VMA_SORT(m_BlockInfos.begin(), m_BlockInfos.end(), [<span class="keyword">this</span>](<span class="keyword">const</span> BlockInfo&amp; lhs, <span class="keyword">const</span> BlockInfo&amp; rhs) -&gt; <span class="keywordtype">bool</span> {</div>
+<div class="line"><a name="l13348"></a><span class="lineno">13348</span>&#160;        <span class="keywordflow">return</span> m_pBlockVector-&gt;GetBlock(lhs.origBlockIndex)-&gt;m_pMetadata-&gt;GetSumFreeSize() &lt;</div>
+<div class="line"><a name="l13349"></a><span class="lineno">13349</span>&#160;            m_pBlockVector-&gt;GetBlock(rhs.origBlockIndex)-&gt;m_pMetadata-&gt;GetSumFreeSize();</div>
+<div class="line"><a name="l13350"></a><span class="lineno">13350</span>&#160;    });</div>
+<div class="line"><a name="l13351"></a><span class="lineno">13351</span>&#160; </div>
+<div class="line"><a name="l13352"></a><span class="lineno">13352</span>&#160;    <span class="comment">// THE MAIN ALGORITHM</span></div>
+<div class="line"><a name="l13353"></a><span class="lineno">13353</span>&#160; </div>
+<div class="line"><a name="l13354"></a><span class="lineno">13354</span>&#160;    FreeSpaceDatabase freeSpaceDb;</div>
+<div class="line"><a name="l13355"></a><span class="lineno">13355</span>&#160; </div>
+<div class="line"><a name="l13356"></a><span class="lineno">13356</span>&#160;    <span class="keywordtype">size_t</span> dstBlockInfoIndex = 0;</div>
+<div class="line"><a name="l13357"></a><span class="lineno">13357</span>&#160;    <span class="keywordtype">size_t</span> dstOrigBlockIndex = m_BlockInfos[dstBlockInfoIndex].origBlockIndex;</div>
+<div class="line"><a name="l13358"></a><span class="lineno">13358</span>&#160;    VmaDeviceMemoryBlock* pDstBlock = m_pBlockVector-&gt;GetBlock(dstOrigBlockIndex);</div>
+<div class="line"><a name="l13359"></a><span class="lineno">13359</span>&#160;    VmaBlockMetadata_Generic* pDstMetadata = (VmaBlockMetadata_Generic*)pDstBlock-&gt;m_pMetadata;</div>
+<div class="line"><a name="l13360"></a><span class="lineno">13360</span>&#160;    VkDeviceSize dstBlockSize = pDstMetadata-&gt;GetSize();</div>
+<div class="line"><a name="l13361"></a><span class="lineno">13361</span>&#160;    VkDeviceSize dstOffset = 0;</div>
+<div class="line"><a name="l13362"></a><span class="lineno">13362</span>&#160; </div>
+<div class="line"><a name="l13363"></a><span class="lineno">13363</span>&#160;    <span class="keywordtype">bool</span> end = <span class="keyword">false</span>;</div>
+<div class="line"><a name="l13364"></a><span class="lineno">13364</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> srcBlockInfoIndex = 0; !end &amp;&amp; srcBlockInfoIndex &lt; blockCount; ++srcBlockInfoIndex)</div>
+<div class="line"><a name="l13365"></a><span class="lineno">13365</span>&#160;    {</div>
+<div class="line"><a name="l13366"></a><span class="lineno">13366</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">size_t</span> srcOrigBlockIndex = m_BlockInfos[srcBlockInfoIndex].origBlockIndex;</div>
+<div class="line"><a name="l13367"></a><span class="lineno">13367</span>&#160;        VmaDeviceMemoryBlock* <span class="keyword">const</span> pSrcBlock = m_pBlockVector-&gt;GetBlock(srcOrigBlockIndex);</div>
+<div class="line"><a name="l13368"></a><span class="lineno">13368</span>&#160;        VmaBlockMetadata_Generic* <span class="keyword">const</span> pSrcMetadata = (VmaBlockMetadata_Generic*)pSrcBlock-&gt;m_pMetadata;</div>
+<div class="line"><a name="l13369"></a><span class="lineno">13369</span>&#160;        <span class="keywordflow">for</span>(VmaSuballocationList::iterator srcSuballocIt = pSrcMetadata-&gt;m_Suballocations.begin();</div>
+<div class="line"><a name="l13370"></a><span class="lineno">13370</span>&#160;            !end &amp;&amp; srcSuballocIt != pSrcMetadata-&gt;m_Suballocations.end(); )</div>
+<div class="line"><a name="l13371"></a><span class="lineno">13371</span>&#160;        {</div>
+<div class="line"><a name="l13372"></a><span class="lineno">13372</span>&#160;            VmaAllocation_T* <span class="keyword">const</span> pAlloc = srcSuballocIt-&gt;hAllocation;</div>
+<div class="line"><a name="l13373"></a><span class="lineno">13373</span>&#160;            <span class="keyword">const</span> VkDeviceSize srcAllocAlignment = pAlloc-&gt;GetAlignment();</div>
+<div class="line"><a name="l13374"></a><span class="lineno">13374</span>&#160;            <span class="keyword">const</span> VkDeviceSize srcAllocSize = srcSuballocIt-&gt;size;</div>
+<div class="line"><a name="l13375"></a><span class="lineno">13375</span>&#160;            <span class="keywordflow">if</span>(m_AllocationsMoved == maxAllocationsToMove ||</div>
+<div class="line"><a name="l13376"></a><span class="lineno">13376</span>&#160;                m_BytesMoved + srcAllocSize &gt; maxBytesToMove)</div>
+<div class="line"><a name="l13377"></a><span class="lineno">13377</span>&#160;            {</div>
+<div class="line"><a name="l13378"></a><span class="lineno">13378</span>&#160;                end = <span class="keyword">true</span>;</div>
+<div class="line"><a name="l13379"></a><span class="lineno">13379</span>&#160;                <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l13380"></a><span class="lineno">13380</span>&#160;            }</div>
+<div class="line"><a name="l13381"></a><span class="lineno">13381</span>&#160;            <span class="keyword">const</span> VkDeviceSize srcAllocOffset = srcSuballocIt-&gt;offset;</div>
+<div class="line"><a name="l13382"></a><span class="lineno">13382</span>&#160; </div>
+<div class="line"><a name="l13383"></a><span class="lineno">13383</span>&#160;            <span class="comment">// Try to place it in one of free spaces from the database.</span></div>
+<div class="line"><a name="l13384"></a><span class="lineno">13384</span>&#160;            <span class="keywordtype">size_t</span> freeSpaceInfoIndex;</div>
+<div class="line"><a name="l13385"></a><span class="lineno">13385</span>&#160;            VkDeviceSize dstAllocOffset;</div>
+<div class="line"><a name="l13386"></a><span class="lineno">13386</span>&#160;            <span class="keywordflow">if</span>(freeSpaceDb.Fetch(srcAllocAlignment, srcAllocSize,</div>
+<div class="line"><a name="l13387"></a><span class="lineno">13387</span>&#160;                freeSpaceInfoIndex, dstAllocOffset))</div>
+<div class="line"><a name="l13388"></a><span class="lineno">13388</span>&#160;            {</div>
+<div class="line"><a name="l13389"></a><span class="lineno">13389</span>&#160;                <span class="keywordtype">size_t</span> freeSpaceOrigBlockIndex = m_BlockInfos[freeSpaceInfoIndex].origBlockIndex;</div>
+<div class="line"><a name="l13390"></a><span class="lineno">13390</span>&#160;                VmaDeviceMemoryBlock* pFreeSpaceBlock = m_pBlockVector-&gt;GetBlock(freeSpaceOrigBlockIndex);</div>
+<div class="line"><a name="l13391"></a><span class="lineno">13391</span>&#160;                VmaBlockMetadata_Generic* pFreeSpaceMetadata = (VmaBlockMetadata_Generic*)pFreeSpaceBlock-&gt;m_pMetadata;</div>
+<div class="line"><a name="l13392"></a><span class="lineno">13392</span>&#160; </div>
+<div class="line"><a name="l13393"></a><span class="lineno">13393</span>&#160;                <span class="comment">// Same block</span></div>
+<div class="line"><a name="l13394"></a><span class="lineno">13394</span>&#160;                <span class="keywordflow">if</span>(freeSpaceInfoIndex == srcBlockInfoIndex)</div>
+<div class="line"><a name="l13395"></a><span class="lineno">13395</span>&#160;                {</div>
+<div class="line"><a name="l13396"></a><span class="lineno">13396</span>&#160;                    VMA_ASSERT(dstAllocOffset &lt;= srcAllocOffset);</div>
+<div class="line"><a name="l13397"></a><span class="lineno">13397</span>&#160; </div>
+<div class="line"><a name="l13398"></a><span class="lineno">13398</span>&#160;                    <span class="comment">// MOVE OPTION 1: Move the allocation inside the same block by decreasing offset.</span></div>
+<div class="line"><a name="l13399"></a><span class="lineno">13399</span>&#160; </div>
+<div class="line"><a name="l13400"></a><span class="lineno">13400</span>&#160;                    VmaSuballocation suballoc = *srcSuballocIt;</div>
+<div class="line"><a name="l13401"></a><span class="lineno">13401</span>&#160;                    suballoc.offset = dstAllocOffset;</div>
+<div class="line"><a name="l13402"></a><span class="lineno">13402</span>&#160;                    suballoc.hAllocation-&gt;ChangeOffset(dstAllocOffset);</div>
+<div class="line"><a name="l13403"></a><span class="lineno">13403</span>&#160;                    m_BytesMoved += srcAllocSize;</div>
+<div class="line"><a name="l13404"></a><span class="lineno">13404</span>&#160;                    ++m_AllocationsMoved;</div>
+<div class="line"><a name="l13405"></a><span class="lineno">13405</span>&#160;                    </div>
+<div class="line"><a name="l13406"></a><span class="lineno">13406</span>&#160;                    VmaSuballocationList::iterator nextSuballocIt = srcSuballocIt;</div>
+<div class="line"><a name="l13407"></a><span class="lineno">13407</span>&#160;                    ++nextSuballocIt;</div>
+<div class="line"><a name="l13408"></a><span class="lineno">13408</span>&#160;                    pSrcMetadata-&gt;m_Suballocations.erase(srcSuballocIt);</div>
+<div class="line"><a name="l13409"></a><span class="lineno">13409</span>&#160;                    srcSuballocIt = nextSuballocIt;</div>
+<div class="line"><a name="l13410"></a><span class="lineno">13410</span>&#160; </div>
+<div class="line"><a name="l13411"></a><span class="lineno">13411</span>&#160;                    InsertSuballoc(pFreeSpaceMetadata, suballoc);</div>
+<div class="line"><a name="l13412"></a><span class="lineno">13412</span>&#160; </div>
+<div class="line"><a name="l13413"></a><span class="lineno">13413</span>&#160;                    VmaDefragmentationMove move = {</div>
+<div class="line"><a name="l13414"></a><span class="lineno">13414</span>&#160;                        srcOrigBlockIndex, freeSpaceOrigBlockIndex,</div>
+<div class="line"><a name="l13415"></a><span class="lineno">13415</span>&#160;                        srcAllocOffset, dstAllocOffset,</div>
+<div class="line"><a name="l13416"></a><span class="lineno">13416</span>&#160;                        srcAllocSize };</div>
+<div class="line"><a name="l13417"></a><span class="lineno">13417</span>&#160;                    moves.push_back(move);</div>
+<div class="line"><a name="l13418"></a><span class="lineno">13418</span>&#160;                }</div>
+<div class="line"><a name="l13419"></a><span class="lineno">13419</span>&#160;                <span class="comment">// Different block</span></div>
+<div class="line"><a name="l13420"></a><span class="lineno">13420</span>&#160;                <span class="keywordflow">else</span></div>
+<div class="line"><a name="l13421"></a><span class="lineno">13421</span>&#160;                {</div>
+<div class="line"><a name="l13422"></a><span class="lineno">13422</span>&#160;                    <span class="comment">// MOVE OPTION 2: Move the allocation to a different block.</span></div>
+<div class="line"><a name="l13423"></a><span class="lineno">13423</span>&#160; </div>
+<div class="line"><a name="l13424"></a><span class="lineno">13424</span>&#160;                    VMA_ASSERT(freeSpaceInfoIndex &lt; srcBlockInfoIndex);</div>
 <div class="line"><a name="l13425"></a><span class="lineno">13425</span>&#160; </div>
-<div class="line"><a name="l13426"></a><span class="lineno">13426</span>&#160;                    VmaSuballocationList::iterator nextSuballocIt = srcSuballocIt;</div>
-<div class="line"><a name="l13427"></a><span class="lineno">13427</span>&#160;                    ++nextSuballocIt;</div>
-<div class="line"><a name="l13428"></a><span class="lineno">13428</span>&#160;                    pSrcMetadata-&gt;m_Suballocations.erase(srcSuballocIt);</div>
-<div class="line"><a name="l13429"></a><span class="lineno">13429</span>&#160;                    srcSuballocIt = nextSuballocIt;</div>
-<div class="line"><a name="l13430"></a><span class="lineno">13430</span>&#160; </div>
-<div class="line"><a name="l13431"></a><span class="lineno">13431</span>&#160;                    InsertSuballoc(pFreeSpaceMetadata, suballoc);</div>
-<div class="line"><a name="l13432"></a><span class="lineno">13432</span>&#160; </div>
-<div class="line"><a name="l13433"></a><span class="lineno">13433</span>&#160;                    VmaDefragmentationMove move = {</div>
-<div class="line"><a name="l13434"></a><span class="lineno">13434</span>&#160;                        srcOrigBlockIndex, freeSpaceOrigBlockIndex,</div>
-<div class="line"><a name="l13435"></a><span class="lineno">13435</span>&#160;                        srcAllocOffset, dstAllocOffset,</div>
-<div class="line"><a name="l13436"></a><span class="lineno">13436</span>&#160;                        srcAllocSize };</div>
-<div class="line"><a name="l13437"></a><span class="lineno">13437</span>&#160;                    moves.push_back(move);</div>
-<div class="line"><a name="l13438"></a><span class="lineno">13438</span>&#160;                }</div>
-<div class="line"><a name="l13439"></a><span class="lineno">13439</span>&#160;            }</div>
-<div class="line"><a name="l13440"></a><span class="lineno">13440</span>&#160;            <span class="keywordflow">else</span></div>
-<div class="line"><a name="l13441"></a><span class="lineno">13441</span>&#160;            {</div>
-<div class="line"><a name="l13442"></a><span class="lineno">13442</span>&#160;                dstAllocOffset = VmaAlignUp(dstOffset, srcAllocAlignment);</div>
-<div class="line"><a name="l13443"></a><span class="lineno">13443</span>&#160; </div>
-<div class="line"><a name="l13444"></a><span class="lineno">13444</span>&#160;                <span class="comment">// If the allocation doesn&#39;t fit before the end of dstBlock, forward to next block.</span></div>
-<div class="line"><a name="l13445"></a><span class="lineno">13445</span>&#160;                <span class="keywordflow">while</span>(dstBlockInfoIndex &lt; srcBlockInfoIndex &amp;&amp;</div>
-<div class="line"><a name="l13446"></a><span class="lineno">13446</span>&#160;                    dstAllocOffset + srcAllocSize &gt; dstBlockSize)</div>
-<div class="line"><a name="l13447"></a><span class="lineno">13447</span>&#160;                {</div>
-<div class="line"><a name="l13448"></a><span class="lineno">13448</span>&#160;                    <span class="comment">// But before that, register remaining free space at the end of dst block.</span></div>
-<div class="line"><a name="l13449"></a><span class="lineno">13449</span>&#160;                    freeSpaceDb.Register(dstBlockInfoIndex, dstOffset, dstBlockSize - dstOffset);</div>
-<div class="line"><a name="l13450"></a><span class="lineno">13450</span>&#160; </div>
-<div class="line"><a name="l13451"></a><span class="lineno">13451</span>&#160;                    ++dstBlockInfoIndex;</div>
-<div class="line"><a name="l13452"></a><span class="lineno">13452</span>&#160;                    dstOrigBlockIndex = m_BlockInfos[dstBlockInfoIndex].origBlockIndex;</div>
-<div class="line"><a name="l13453"></a><span class="lineno">13453</span>&#160;                    pDstBlock = m_pBlockVector-&gt;GetBlock(dstOrigBlockIndex);</div>
-<div class="line"><a name="l13454"></a><span class="lineno">13454</span>&#160;                    pDstMetadata = (VmaBlockMetadata_Generic*)pDstBlock-&gt;m_pMetadata;</div>
-<div class="line"><a name="l13455"></a><span class="lineno">13455</span>&#160;                    dstBlockSize = pDstMetadata-&gt;GetSize();</div>
-<div class="line"><a name="l13456"></a><span class="lineno">13456</span>&#160;                    dstOffset = 0;</div>
-<div class="line"><a name="l13457"></a><span class="lineno">13457</span>&#160;                    dstAllocOffset = 0;</div>
-<div class="line"><a name="l13458"></a><span class="lineno">13458</span>&#160;                }</div>
-<div class="line"><a name="l13459"></a><span class="lineno">13459</span>&#160; </div>
-<div class="line"><a name="l13460"></a><span class="lineno">13460</span>&#160;                <span class="comment">// Same block</span></div>
-<div class="line"><a name="l13461"></a><span class="lineno">13461</span>&#160;                <span class="keywordflow">if</span>(dstBlockInfoIndex == srcBlockInfoIndex)</div>
-<div class="line"><a name="l13462"></a><span class="lineno">13462</span>&#160;                {</div>
-<div class="line"><a name="l13463"></a><span class="lineno">13463</span>&#160;                    VMA_ASSERT(dstAllocOffset &lt;= srcAllocOffset);</div>
-<div class="line"><a name="l13464"></a><span class="lineno">13464</span>&#160; </div>
-<div class="line"><a name="l13465"></a><span class="lineno">13465</span>&#160;                    <span class="keyword">const</span> <span class="keywordtype">bool</span> overlap = dstAllocOffset + srcAllocSize &gt; srcAllocOffset;</div>
-<div class="line"><a name="l13466"></a><span class="lineno">13466</span>&#160; </div>
-<div class="line"><a name="l13467"></a><span class="lineno">13467</span>&#160;                    <span class="keywordtype">bool</span> skipOver = overlap;</div>
-<div class="line"><a name="l13468"></a><span class="lineno">13468</span>&#160;                    <span class="keywordflow">if</span>(overlap &amp;&amp; m_OverlappingMoveSupported &amp;&amp; dstAllocOffset &lt; srcAllocOffset)</div>
-<div class="line"><a name="l13469"></a><span class="lineno">13469</span>&#160;                    {</div>
-<div class="line"><a name="l13470"></a><span class="lineno">13470</span>&#160;                        <span class="comment">// If destination and source place overlap, skip if it would move it</span></div>
-<div class="line"><a name="l13471"></a><span class="lineno">13471</span>&#160;                        <span class="comment">// by only &lt; 1/64 of its size.</span></div>
-<div class="line"><a name="l13472"></a><span class="lineno">13472</span>&#160;                        skipOver = (srcAllocOffset - dstAllocOffset) * 64 &lt; srcAllocSize;</div>
-<div class="line"><a name="l13473"></a><span class="lineno">13473</span>&#160;                    }</div>
-<div class="line"><a name="l13474"></a><span class="lineno">13474</span>&#160; </div>
-<div class="line"><a name="l13475"></a><span class="lineno">13475</span>&#160;                    <span class="keywordflow">if</span>(skipOver)</div>
-<div class="line"><a name="l13476"></a><span class="lineno">13476</span>&#160;                    {</div>
-<div class="line"><a name="l13477"></a><span class="lineno">13477</span>&#160;                        freeSpaceDb.Register(dstBlockInfoIndex, dstOffset, srcAllocOffset - dstOffset);</div>
-<div class="line"><a name="l13478"></a><span class="lineno">13478</span>&#160; </div>
-<div class="line"><a name="l13479"></a><span class="lineno">13479</span>&#160;                        dstOffset = srcAllocOffset + srcAllocSize;</div>
-<div class="line"><a name="l13480"></a><span class="lineno">13480</span>&#160;                        ++srcSuballocIt;</div>
-<div class="line"><a name="l13481"></a><span class="lineno">13481</span>&#160;                    }</div>
-<div class="line"><a name="l13482"></a><span class="lineno">13482</span>&#160;                    <span class="comment">// MOVE OPTION 1: Move the allocation inside the same block by decreasing offset.</span></div>
-<div class="line"><a name="l13483"></a><span class="lineno">13483</span>&#160;                    <span class="keywordflow">else</span></div>
-<div class="line"><a name="l13484"></a><span class="lineno">13484</span>&#160;                    {</div>
-<div class="line"><a name="l13485"></a><span class="lineno">13485</span>&#160;                        srcSuballocIt-&gt;offset = dstAllocOffset;</div>
-<div class="line"><a name="l13486"></a><span class="lineno">13486</span>&#160;                        srcSuballocIt-&gt;hAllocation-&gt;ChangeOffset(dstAllocOffset);</div>
-<div class="line"><a name="l13487"></a><span class="lineno">13487</span>&#160;                        dstOffset = dstAllocOffset + srcAllocSize;</div>
-<div class="line"><a name="l13488"></a><span class="lineno">13488</span>&#160;                        m_BytesMoved += srcAllocSize;</div>
-<div class="line"><a name="l13489"></a><span class="lineno">13489</span>&#160;                        ++m_AllocationsMoved;</div>
-<div class="line"><a name="l13490"></a><span class="lineno">13490</span>&#160;                        ++srcSuballocIt;</div>
-<div class="line"><a name="l13491"></a><span class="lineno">13491</span>&#160;                        VmaDefragmentationMove move = {</div>
-<div class="line"><a name="l13492"></a><span class="lineno">13492</span>&#160;                            srcOrigBlockIndex, dstOrigBlockIndex,</div>
-<div class="line"><a name="l13493"></a><span class="lineno">13493</span>&#160;                            srcAllocOffset, dstAllocOffset,</div>
-<div class="line"><a name="l13494"></a><span class="lineno">13494</span>&#160;                            srcAllocSize };</div>
-<div class="line"><a name="l13495"></a><span class="lineno">13495</span>&#160;                        moves.push_back(move);</div>
-<div class="line"><a name="l13496"></a><span class="lineno">13496</span>&#160;                    }</div>
-<div class="line"><a name="l13497"></a><span class="lineno">13497</span>&#160;                }</div>
-<div class="line"><a name="l13498"></a><span class="lineno">13498</span>&#160;                <span class="comment">// Different block</span></div>
-<div class="line"><a name="l13499"></a><span class="lineno">13499</span>&#160;                <span class="keywordflow">else</span></div>
-<div class="line"><a name="l13500"></a><span class="lineno">13500</span>&#160;                {</div>
-<div class="line"><a name="l13501"></a><span class="lineno">13501</span>&#160;                    <span class="comment">// MOVE OPTION 2: Move the allocation to a different block.</span></div>
-<div class="line"><a name="l13502"></a><span class="lineno">13502</span>&#160; </div>
-<div class="line"><a name="l13503"></a><span class="lineno">13503</span>&#160;                    VMA_ASSERT(dstBlockInfoIndex &lt; srcBlockInfoIndex);</div>
-<div class="line"><a name="l13504"></a><span class="lineno">13504</span>&#160;                    VMA_ASSERT(dstAllocOffset + srcAllocSize &lt;= dstBlockSize);</div>
-<div class="line"><a name="l13505"></a><span class="lineno">13505</span>&#160; </div>
-<div class="line"><a name="l13506"></a><span class="lineno">13506</span>&#160;                    VmaSuballocation suballoc = *srcSuballocIt;</div>
-<div class="line"><a name="l13507"></a><span class="lineno">13507</span>&#160;                    suballoc.offset = dstAllocOffset;</div>
-<div class="line"><a name="l13508"></a><span class="lineno">13508</span>&#160;                    suballoc.hAllocation-&gt;ChangeBlockAllocation(m_hAllocator, pDstBlock, dstAllocOffset);</div>
-<div class="line"><a name="l13509"></a><span class="lineno">13509</span>&#160;                    dstOffset = dstAllocOffset + srcAllocSize;</div>
-<div class="line"><a name="l13510"></a><span class="lineno">13510</span>&#160;                    m_BytesMoved += srcAllocSize;</div>
-<div class="line"><a name="l13511"></a><span class="lineno">13511</span>&#160;                    ++m_AllocationsMoved;</div>
-<div class="line"><a name="l13512"></a><span class="lineno">13512</span>&#160; </div>
-<div class="line"><a name="l13513"></a><span class="lineno">13513</span>&#160;                    VmaSuballocationList::iterator nextSuballocIt = srcSuballocIt;</div>
-<div class="line"><a name="l13514"></a><span class="lineno">13514</span>&#160;                    ++nextSuballocIt;</div>
-<div class="line"><a name="l13515"></a><span class="lineno">13515</span>&#160;                    pSrcMetadata-&gt;m_Suballocations.erase(srcSuballocIt);</div>
-<div class="line"><a name="l13516"></a><span class="lineno">13516</span>&#160;                    srcSuballocIt = nextSuballocIt;</div>
-<div class="line"><a name="l13517"></a><span class="lineno">13517</span>&#160; </div>
-<div class="line"><a name="l13518"></a><span class="lineno">13518</span>&#160;                    pDstMetadata-&gt;m_Suballocations.push_back(suballoc);</div>
-<div class="line"><a name="l13519"></a><span class="lineno">13519</span>&#160; </div>
-<div class="line"><a name="l13520"></a><span class="lineno">13520</span>&#160;                    VmaDefragmentationMove move = {</div>
-<div class="line"><a name="l13521"></a><span class="lineno">13521</span>&#160;                        srcOrigBlockIndex, dstOrigBlockIndex,</div>
-<div class="line"><a name="l13522"></a><span class="lineno">13522</span>&#160;                        srcAllocOffset, dstAllocOffset,</div>
-<div class="line"><a name="l13523"></a><span class="lineno">13523</span>&#160;                        srcAllocSize };</div>
-<div class="line"><a name="l13524"></a><span class="lineno">13524</span>&#160;                    moves.push_back(move);</div>
-<div class="line"><a name="l13525"></a><span class="lineno">13525</span>&#160;                }</div>
-<div class="line"><a name="l13526"></a><span class="lineno">13526</span>&#160;            }</div>
-<div class="line"><a name="l13527"></a><span class="lineno">13527</span>&#160;        }</div>
-<div class="line"><a name="l13528"></a><span class="lineno">13528</span>&#160;    }</div>
-<div class="line"><a name="l13529"></a><span class="lineno">13529</span>&#160; </div>
-<div class="line"><a name="l13530"></a><span class="lineno">13530</span>&#160;    m_BlockInfos.clear();</div>
-<div class="line"><a name="l13531"></a><span class="lineno">13531</span>&#160;    </div>
-<div class="line"><a name="l13532"></a><span class="lineno">13532</span>&#160;    PostprocessMetadata();</div>
-<div class="line"><a name="l13533"></a><span class="lineno">13533</span>&#160; </div>
-<div class="line"><a name="l13534"></a><span class="lineno">13534</span>&#160;    <span class="keywordflow">return</span> VK_SUCCESS;</div>
-<div class="line"><a name="l13535"></a><span class="lineno">13535</span>&#160;}</div>
-<div class="line"><a name="l13536"></a><span class="lineno">13536</span>&#160; </div>
-<div class="line"><a name="l13537"></a><span class="lineno">13537</span>&#160;<span class="keywordtype">void</span> VmaDefragmentationAlgorithm_Fast::PreprocessMetadata()</div>
-<div class="line"><a name="l13538"></a><span class="lineno">13538</span>&#160;{</div>
-<div class="line"><a name="l13539"></a><span class="lineno">13539</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> blockCount = m_pBlockVector-&gt;GetBlockCount();</div>
-<div class="line"><a name="l13540"></a><span class="lineno">13540</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; blockIndex &lt; blockCount; ++blockIndex)</div>
-<div class="line"><a name="l13541"></a><span class="lineno">13541</span>&#160;    {</div>
-<div class="line"><a name="l13542"></a><span class="lineno">13542</span>&#160;        VmaBlockMetadata_Generic* <span class="keyword">const</span> pMetadata =</div>
-<div class="line"><a name="l13543"></a><span class="lineno">13543</span>&#160;            (VmaBlockMetadata_Generic*)m_pBlockVector-&gt;GetBlock(blockIndex)-&gt;m_pMetadata;</div>
-<div class="line"><a name="l13544"></a><span class="lineno">13544</span>&#160;        pMetadata-&gt;m_FreeCount = 0;</div>
-<div class="line"><a name="l13545"></a><span class="lineno">13545</span>&#160;        pMetadata-&gt;m_SumFreeSize = pMetadata-&gt;GetSize();</div>
-<div class="line"><a name="l13546"></a><span class="lineno">13546</span>&#160;        pMetadata-&gt;m_FreeSuballocationsBySize.clear();</div>
-<div class="line"><a name="l13547"></a><span class="lineno">13547</span>&#160;        <span class="keywordflow">for</span>(VmaSuballocationList::iterator it = pMetadata-&gt;m_Suballocations.begin();</div>
-<div class="line"><a name="l13548"></a><span class="lineno">13548</span>&#160;            it != pMetadata-&gt;m_Suballocations.end(); )</div>
-<div class="line"><a name="l13549"></a><span class="lineno">13549</span>&#160;        {</div>
-<div class="line"><a name="l13550"></a><span class="lineno">13550</span>&#160;            <span class="keywordflow">if</span>(it-&gt;type == VMA_SUBALLOCATION_TYPE_FREE)</div>
-<div class="line"><a name="l13551"></a><span class="lineno">13551</span>&#160;            {</div>
-<div class="line"><a name="l13552"></a><span class="lineno">13552</span>&#160;                VmaSuballocationList::iterator nextIt = it;</div>
-<div class="line"><a name="l13553"></a><span class="lineno">13553</span>&#160;                ++nextIt;</div>
-<div class="line"><a name="l13554"></a><span class="lineno">13554</span>&#160;                pMetadata-&gt;m_Suballocations.erase(it);</div>
-<div class="line"><a name="l13555"></a><span class="lineno">13555</span>&#160;                it = nextIt;</div>
-<div class="line"><a name="l13556"></a><span class="lineno">13556</span>&#160;            }</div>
-<div class="line"><a name="l13557"></a><span class="lineno">13557</span>&#160;            <span class="keywordflow">else</span></div>
-<div class="line"><a name="l13558"></a><span class="lineno">13558</span>&#160;            {</div>
-<div class="line"><a name="l13559"></a><span class="lineno">13559</span>&#160;                ++it;</div>
-<div class="line"><a name="l13560"></a><span class="lineno">13560</span>&#160;            }</div>
-<div class="line"><a name="l13561"></a><span class="lineno">13561</span>&#160;        }</div>
-<div class="line"><a name="l13562"></a><span class="lineno">13562</span>&#160;    }</div>
-<div class="line"><a name="l13563"></a><span class="lineno">13563</span>&#160;}</div>
-<div class="line"><a name="l13564"></a><span class="lineno">13564</span>&#160; </div>
-<div class="line"><a name="l13565"></a><span class="lineno">13565</span>&#160;<span class="keywordtype">void</span> VmaDefragmentationAlgorithm_Fast::PostprocessMetadata()</div>
-<div class="line"><a name="l13566"></a><span class="lineno">13566</span>&#160;{</div>
-<div class="line"><a name="l13567"></a><span class="lineno">13567</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> blockCount = m_pBlockVector-&gt;GetBlockCount();</div>
-<div class="line"><a name="l13568"></a><span class="lineno">13568</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; blockIndex &lt; blockCount; ++blockIndex)</div>
-<div class="line"><a name="l13569"></a><span class="lineno">13569</span>&#160;    {</div>
-<div class="line"><a name="l13570"></a><span class="lineno">13570</span>&#160;        VmaBlockMetadata_Generic* <span class="keyword">const</span> pMetadata =</div>
-<div class="line"><a name="l13571"></a><span class="lineno">13571</span>&#160;            (VmaBlockMetadata_Generic*)m_pBlockVector-&gt;GetBlock(blockIndex)-&gt;m_pMetadata;</div>
-<div class="line"><a name="l13572"></a><span class="lineno">13572</span>&#160;        <span class="keyword">const</span> VkDeviceSize blockSize = pMetadata-&gt;GetSize();</div>
-<div class="line"><a name="l13573"></a><span class="lineno">13573</span>&#160;        </div>
-<div class="line"><a name="l13574"></a><span class="lineno">13574</span>&#160;        <span class="comment">// No allocations in this block - entire area is free.</span></div>
-<div class="line"><a name="l13575"></a><span class="lineno">13575</span>&#160;        <span class="keywordflow">if</span>(pMetadata-&gt;m_Suballocations.empty())</div>
-<div class="line"><a name="l13576"></a><span class="lineno">13576</span>&#160;        {</div>
-<div class="line"><a name="l13577"></a><span class="lineno">13577</span>&#160;            pMetadata-&gt;m_FreeCount = 1;</div>
-<div class="line"><a name="l13578"></a><span class="lineno">13578</span>&#160;            <span class="comment">//pMetadata-&gt;m_SumFreeSize is already set to blockSize.</span></div>
-<div class="line"><a name="l13579"></a><span class="lineno">13579</span>&#160;            VmaSuballocation suballoc = {</div>
-<div class="line"><a name="l13580"></a><span class="lineno">13580</span>&#160;                0, <span class="comment">// offset</span></div>
-<div class="line"><a name="l13581"></a><span class="lineno">13581</span>&#160;                blockSize, <span class="comment">// size</span></div>
-<div class="line"><a name="l13582"></a><span class="lineno">13582</span>&#160;                VMA_NULL, <span class="comment">// hAllocation</span></div>
-<div class="line"><a name="l13583"></a><span class="lineno">13583</span>&#160;                VMA_SUBALLOCATION_TYPE_FREE };</div>
-<div class="line"><a name="l13584"></a><span class="lineno">13584</span>&#160;            pMetadata-&gt;m_Suballocations.push_back(suballoc);</div>
-<div class="line"><a name="l13585"></a><span class="lineno">13585</span>&#160;            pMetadata-&gt;RegisterFreeSuballocation(pMetadata-&gt;m_Suballocations.begin());</div>
-<div class="line"><a name="l13586"></a><span class="lineno">13586</span>&#160;        }</div>
-<div class="line"><a name="l13587"></a><span class="lineno">13587</span>&#160;        <span class="comment">// There are some allocations in this block.</span></div>
-<div class="line"><a name="l13588"></a><span class="lineno">13588</span>&#160;        <span class="keywordflow">else</span></div>
-<div class="line"><a name="l13589"></a><span class="lineno">13589</span>&#160;        {</div>
-<div class="line"><a name="l13590"></a><span class="lineno">13590</span>&#160;            VkDeviceSize offset = 0;</div>
-<div class="line"><a name="l13591"></a><span class="lineno">13591</span>&#160;            VmaSuballocationList::iterator it;</div>
-<div class="line"><a name="l13592"></a><span class="lineno">13592</span>&#160;            <span class="keywordflow">for</span>(it = pMetadata-&gt;m_Suballocations.begin();</div>
-<div class="line"><a name="l13593"></a><span class="lineno">13593</span>&#160;                it != pMetadata-&gt;m_Suballocations.end();</div>
-<div class="line"><a name="l13594"></a><span class="lineno">13594</span>&#160;                ++it)</div>
-<div class="line"><a name="l13595"></a><span class="lineno">13595</span>&#160;            {</div>
-<div class="line"><a name="l13596"></a><span class="lineno">13596</span>&#160;                VMA_ASSERT(it-&gt;type != VMA_SUBALLOCATION_TYPE_FREE);</div>
-<div class="line"><a name="l13597"></a><span class="lineno">13597</span>&#160;                VMA_ASSERT(it-&gt;offset &gt;= offset);</div>
-<div class="line"><a name="l13598"></a><span class="lineno">13598</span>&#160; </div>
-<div class="line"><a name="l13599"></a><span class="lineno">13599</span>&#160;                <span class="comment">// Need to insert preceding free space.</span></div>
-<div class="line"><a name="l13600"></a><span class="lineno">13600</span>&#160;                <span class="keywordflow">if</span>(it-&gt;offset &gt; offset)</div>
-<div class="line"><a name="l13601"></a><span class="lineno">13601</span>&#160;                {</div>
-<div class="line"><a name="l13602"></a><span class="lineno">13602</span>&#160;                    ++pMetadata-&gt;m_FreeCount;</div>
-<div class="line"><a name="l13603"></a><span class="lineno">13603</span>&#160;                    <span class="keyword">const</span> VkDeviceSize freeSize = it-&gt;offset - offset;</div>
-<div class="line"><a name="l13604"></a><span class="lineno">13604</span>&#160;                    VmaSuballocation suballoc = {</div>
-<div class="line"><a name="l13605"></a><span class="lineno">13605</span>&#160;                        offset, <span class="comment">// offset</span></div>
-<div class="line"><a name="l13606"></a><span class="lineno">13606</span>&#160;                        freeSize, <span class="comment">// size</span></div>
-<div class="line"><a name="l13607"></a><span class="lineno">13607</span>&#160;                        VMA_NULL, <span class="comment">// hAllocation</span></div>
-<div class="line"><a name="l13608"></a><span class="lineno">13608</span>&#160;                        VMA_SUBALLOCATION_TYPE_FREE };</div>
-<div class="line"><a name="l13609"></a><span class="lineno">13609</span>&#160;                    VmaSuballocationList::iterator precedingFreeIt = pMetadata-&gt;m_Suballocations.insert(it, suballoc);</div>
-<div class="line"><a name="l13610"></a><span class="lineno">13610</span>&#160;                    <span class="keywordflow">if</span>(freeSize &gt;= VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER)</div>
-<div class="line"><a name="l13611"></a><span class="lineno">13611</span>&#160;                    {</div>
-<div class="line"><a name="l13612"></a><span class="lineno">13612</span>&#160;                        pMetadata-&gt;m_FreeSuballocationsBySize.push_back(precedingFreeIt);</div>
-<div class="line"><a name="l13613"></a><span class="lineno">13613</span>&#160;                    }</div>
-<div class="line"><a name="l13614"></a><span class="lineno">13614</span>&#160;                }</div>
-<div class="line"><a name="l13615"></a><span class="lineno">13615</span>&#160; </div>
-<div class="line"><a name="l13616"></a><span class="lineno">13616</span>&#160;                pMetadata-&gt;m_SumFreeSize -= it-&gt;size;</div>
-<div class="line"><a name="l13617"></a><span class="lineno">13617</span>&#160;                offset = it-&gt;offset + it-&gt;size;</div>
-<div class="line"><a name="l13618"></a><span class="lineno">13618</span>&#160;            }</div>
-<div class="line"><a name="l13619"></a><span class="lineno">13619</span>&#160; </div>
-<div class="line"><a name="l13620"></a><span class="lineno">13620</span>&#160;            <span class="comment">// Need to insert trailing free space.</span></div>
-<div class="line"><a name="l13621"></a><span class="lineno">13621</span>&#160;            <span class="keywordflow">if</span>(offset &lt; blockSize)</div>
-<div class="line"><a name="l13622"></a><span class="lineno">13622</span>&#160;            {</div>
-<div class="line"><a name="l13623"></a><span class="lineno">13623</span>&#160;                ++pMetadata-&gt;m_FreeCount;</div>
-<div class="line"><a name="l13624"></a><span class="lineno">13624</span>&#160;                <span class="keyword">const</span> VkDeviceSize freeSize = blockSize - offset;</div>
-<div class="line"><a name="l13625"></a><span class="lineno">13625</span>&#160;                VmaSuballocation suballoc = {</div>
-<div class="line"><a name="l13626"></a><span class="lineno">13626</span>&#160;                    offset, <span class="comment">// offset</span></div>
-<div class="line"><a name="l13627"></a><span class="lineno">13627</span>&#160;                    freeSize, <span class="comment">// size</span></div>
-<div class="line"><a name="l13628"></a><span class="lineno">13628</span>&#160;                    VMA_NULL, <span class="comment">// hAllocation</span></div>
-<div class="line"><a name="l13629"></a><span class="lineno">13629</span>&#160;                    VMA_SUBALLOCATION_TYPE_FREE };</div>
-<div class="line"><a name="l13630"></a><span class="lineno">13630</span>&#160;                VMA_ASSERT(it == pMetadata-&gt;m_Suballocations.end());</div>
-<div class="line"><a name="l13631"></a><span class="lineno">13631</span>&#160;                VmaSuballocationList::iterator trailingFreeIt = pMetadata-&gt;m_Suballocations.insert(it, suballoc);</div>
-<div class="line"><a name="l13632"></a><span class="lineno">13632</span>&#160;                <span class="keywordflow">if</span>(freeSize &gt; VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER)</div>
-<div class="line"><a name="l13633"></a><span class="lineno">13633</span>&#160;                {</div>
-<div class="line"><a name="l13634"></a><span class="lineno">13634</span>&#160;                    pMetadata-&gt;m_FreeSuballocationsBySize.push_back(trailingFreeIt);</div>
-<div class="line"><a name="l13635"></a><span class="lineno">13635</span>&#160;                }</div>
-<div class="line"><a name="l13636"></a><span class="lineno">13636</span>&#160;            }</div>
-<div class="line"><a name="l13637"></a><span class="lineno">13637</span>&#160; </div>
-<div class="line"><a name="l13638"></a><span class="lineno">13638</span>&#160;            VMA_SORT(</div>
-<div class="line"><a name="l13639"></a><span class="lineno">13639</span>&#160;                pMetadata-&gt;m_FreeSuballocationsBySize.begin(),</div>
-<div class="line"><a name="l13640"></a><span class="lineno">13640</span>&#160;                pMetadata-&gt;m_FreeSuballocationsBySize.end(),</div>
-<div class="line"><a name="l13641"></a><span class="lineno">13641</span>&#160;                VmaSuballocationItemSizeLess());</div>
-<div class="line"><a name="l13642"></a><span class="lineno">13642</span>&#160;        }</div>
+<div class="line"><a name="l13426"></a><span class="lineno">13426</span>&#160;                    VmaSuballocation suballoc = *srcSuballocIt;</div>
+<div class="line"><a name="l13427"></a><span class="lineno">13427</span>&#160;                    suballoc.offset = dstAllocOffset;</div>
+<div class="line"><a name="l13428"></a><span class="lineno">13428</span>&#160;                    suballoc.hAllocation-&gt;ChangeBlockAllocation(m_hAllocator, pFreeSpaceBlock, dstAllocOffset);</div>
+<div class="line"><a name="l13429"></a><span class="lineno">13429</span>&#160;                    m_BytesMoved += srcAllocSize;</div>
+<div class="line"><a name="l13430"></a><span class="lineno">13430</span>&#160;                    ++m_AllocationsMoved;</div>
+<div class="line"><a name="l13431"></a><span class="lineno">13431</span>&#160; </div>
+<div class="line"><a name="l13432"></a><span class="lineno">13432</span>&#160;                    VmaSuballocationList::iterator nextSuballocIt = srcSuballocIt;</div>
+<div class="line"><a name="l13433"></a><span class="lineno">13433</span>&#160;                    ++nextSuballocIt;</div>
+<div class="line"><a name="l13434"></a><span class="lineno">13434</span>&#160;                    pSrcMetadata-&gt;m_Suballocations.erase(srcSuballocIt);</div>
+<div class="line"><a name="l13435"></a><span class="lineno">13435</span>&#160;                    srcSuballocIt = nextSuballocIt;</div>
+<div class="line"><a name="l13436"></a><span class="lineno">13436</span>&#160; </div>
+<div class="line"><a name="l13437"></a><span class="lineno">13437</span>&#160;                    InsertSuballoc(pFreeSpaceMetadata, suballoc);</div>
+<div class="line"><a name="l13438"></a><span class="lineno">13438</span>&#160; </div>
+<div class="line"><a name="l13439"></a><span class="lineno">13439</span>&#160;                    VmaDefragmentationMove move = {</div>
+<div class="line"><a name="l13440"></a><span class="lineno">13440</span>&#160;                        srcOrigBlockIndex, freeSpaceOrigBlockIndex,</div>
+<div class="line"><a name="l13441"></a><span class="lineno">13441</span>&#160;                        srcAllocOffset, dstAllocOffset,</div>
+<div class="line"><a name="l13442"></a><span class="lineno">13442</span>&#160;                        srcAllocSize };</div>
+<div class="line"><a name="l13443"></a><span class="lineno">13443</span>&#160;                    moves.push_back(move);</div>
+<div class="line"><a name="l13444"></a><span class="lineno">13444</span>&#160;                }</div>
+<div class="line"><a name="l13445"></a><span class="lineno">13445</span>&#160;            }</div>
+<div class="line"><a name="l13446"></a><span class="lineno">13446</span>&#160;            <span class="keywordflow">else</span></div>
+<div class="line"><a name="l13447"></a><span class="lineno">13447</span>&#160;            {</div>
+<div class="line"><a name="l13448"></a><span class="lineno">13448</span>&#160;                dstAllocOffset = VmaAlignUp(dstOffset, srcAllocAlignment);</div>
+<div class="line"><a name="l13449"></a><span class="lineno">13449</span>&#160; </div>
+<div class="line"><a name="l13450"></a><span class="lineno">13450</span>&#160;                <span class="comment">// If the allocation doesn&#39;t fit before the end of dstBlock, forward to next block.</span></div>
+<div class="line"><a name="l13451"></a><span class="lineno">13451</span>&#160;                <span class="keywordflow">while</span>(dstBlockInfoIndex &lt; srcBlockInfoIndex &amp;&amp;</div>
+<div class="line"><a name="l13452"></a><span class="lineno">13452</span>&#160;                    dstAllocOffset + srcAllocSize &gt; dstBlockSize)</div>
+<div class="line"><a name="l13453"></a><span class="lineno">13453</span>&#160;                {</div>
+<div class="line"><a name="l13454"></a><span class="lineno">13454</span>&#160;                    <span class="comment">// But before that, register remaining free space at the end of dst block.</span></div>
+<div class="line"><a name="l13455"></a><span class="lineno">13455</span>&#160;                    freeSpaceDb.Register(dstBlockInfoIndex, dstOffset, dstBlockSize - dstOffset);</div>
+<div class="line"><a name="l13456"></a><span class="lineno">13456</span>&#160; </div>
+<div class="line"><a name="l13457"></a><span class="lineno">13457</span>&#160;                    ++dstBlockInfoIndex;</div>
+<div class="line"><a name="l13458"></a><span class="lineno">13458</span>&#160;                    dstOrigBlockIndex = m_BlockInfos[dstBlockInfoIndex].origBlockIndex;</div>
+<div class="line"><a name="l13459"></a><span class="lineno">13459</span>&#160;                    pDstBlock = m_pBlockVector-&gt;GetBlock(dstOrigBlockIndex);</div>
+<div class="line"><a name="l13460"></a><span class="lineno">13460</span>&#160;                    pDstMetadata = (VmaBlockMetadata_Generic*)pDstBlock-&gt;m_pMetadata;</div>
+<div class="line"><a name="l13461"></a><span class="lineno">13461</span>&#160;                    dstBlockSize = pDstMetadata-&gt;GetSize();</div>
+<div class="line"><a name="l13462"></a><span class="lineno">13462</span>&#160;                    dstOffset = 0;</div>
+<div class="line"><a name="l13463"></a><span class="lineno">13463</span>&#160;                    dstAllocOffset = 0;</div>
+<div class="line"><a name="l13464"></a><span class="lineno">13464</span>&#160;                }</div>
+<div class="line"><a name="l13465"></a><span class="lineno">13465</span>&#160; </div>
+<div class="line"><a name="l13466"></a><span class="lineno">13466</span>&#160;                <span class="comment">// Same block</span></div>
+<div class="line"><a name="l13467"></a><span class="lineno">13467</span>&#160;                <span class="keywordflow">if</span>(dstBlockInfoIndex == srcBlockInfoIndex)</div>
+<div class="line"><a name="l13468"></a><span class="lineno">13468</span>&#160;                {</div>
+<div class="line"><a name="l13469"></a><span class="lineno">13469</span>&#160;                    VMA_ASSERT(dstAllocOffset &lt;= srcAllocOffset);</div>
+<div class="line"><a name="l13470"></a><span class="lineno">13470</span>&#160; </div>
+<div class="line"><a name="l13471"></a><span class="lineno">13471</span>&#160;                    <span class="keyword">const</span> <span class="keywordtype">bool</span> overlap = dstAllocOffset + srcAllocSize &gt; srcAllocOffset;</div>
+<div class="line"><a name="l13472"></a><span class="lineno">13472</span>&#160; </div>
+<div class="line"><a name="l13473"></a><span class="lineno">13473</span>&#160;                    <span class="keywordtype">bool</span> skipOver = overlap;</div>
+<div class="line"><a name="l13474"></a><span class="lineno">13474</span>&#160;                    <span class="keywordflow">if</span>(overlap &amp;&amp; m_OverlappingMoveSupported &amp;&amp; dstAllocOffset &lt; srcAllocOffset)</div>
+<div class="line"><a name="l13475"></a><span class="lineno">13475</span>&#160;                    {</div>
+<div class="line"><a name="l13476"></a><span class="lineno">13476</span>&#160;                        <span class="comment">// If destination and source place overlap, skip if it would move it</span></div>
+<div class="line"><a name="l13477"></a><span class="lineno">13477</span>&#160;                        <span class="comment">// by only &lt; 1/64 of its size.</span></div>
+<div class="line"><a name="l13478"></a><span class="lineno">13478</span>&#160;                        skipOver = (srcAllocOffset - dstAllocOffset) * 64 &lt; srcAllocSize;</div>
+<div class="line"><a name="l13479"></a><span class="lineno">13479</span>&#160;                    }</div>
+<div class="line"><a name="l13480"></a><span class="lineno">13480</span>&#160; </div>
+<div class="line"><a name="l13481"></a><span class="lineno">13481</span>&#160;                    <span class="keywordflow">if</span>(skipOver)</div>
+<div class="line"><a name="l13482"></a><span class="lineno">13482</span>&#160;                    {</div>
+<div class="line"><a name="l13483"></a><span class="lineno">13483</span>&#160;                        freeSpaceDb.Register(dstBlockInfoIndex, dstOffset, srcAllocOffset - dstOffset);</div>
+<div class="line"><a name="l13484"></a><span class="lineno">13484</span>&#160; </div>
+<div class="line"><a name="l13485"></a><span class="lineno">13485</span>&#160;                        dstOffset = srcAllocOffset + srcAllocSize;</div>
+<div class="line"><a name="l13486"></a><span class="lineno">13486</span>&#160;                        ++srcSuballocIt;</div>
+<div class="line"><a name="l13487"></a><span class="lineno">13487</span>&#160;                    }</div>
+<div class="line"><a name="l13488"></a><span class="lineno">13488</span>&#160;                    <span class="comment">// MOVE OPTION 1: Move the allocation inside the same block by decreasing offset.</span></div>
+<div class="line"><a name="l13489"></a><span class="lineno">13489</span>&#160;                    <span class="keywordflow">else</span></div>
+<div class="line"><a name="l13490"></a><span class="lineno">13490</span>&#160;                    {</div>
+<div class="line"><a name="l13491"></a><span class="lineno">13491</span>&#160;                        srcSuballocIt-&gt;offset = dstAllocOffset;</div>
+<div class="line"><a name="l13492"></a><span class="lineno">13492</span>&#160;                        srcSuballocIt-&gt;hAllocation-&gt;ChangeOffset(dstAllocOffset);</div>
+<div class="line"><a name="l13493"></a><span class="lineno">13493</span>&#160;                        dstOffset = dstAllocOffset + srcAllocSize;</div>
+<div class="line"><a name="l13494"></a><span class="lineno">13494</span>&#160;                        m_BytesMoved += srcAllocSize;</div>
+<div class="line"><a name="l13495"></a><span class="lineno">13495</span>&#160;                        ++m_AllocationsMoved;</div>
+<div class="line"><a name="l13496"></a><span class="lineno">13496</span>&#160;                        ++srcSuballocIt;</div>
+<div class="line"><a name="l13497"></a><span class="lineno">13497</span>&#160;                        VmaDefragmentationMove move = {</div>
+<div class="line"><a name="l13498"></a><span class="lineno">13498</span>&#160;                            srcOrigBlockIndex, dstOrigBlockIndex,</div>
+<div class="line"><a name="l13499"></a><span class="lineno">13499</span>&#160;                            srcAllocOffset, dstAllocOffset,</div>
+<div class="line"><a name="l13500"></a><span class="lineno">13500</span>&#160;                            srcAllocSize };</div>
+<div class="line"><a name="l13501"></a><span class="lineno">13501</span>&#160;                        moves.push_back(move);</div>
+<div class="line"><a name="l13502"></a><span class="lineno">13502</span>&#160;                    }</div>
+<div class="line"><a name="l13503"></a><span class="lineno">13503</span>&#160;                }</div>
+<div class="line"><a name="l13504"></a><span class="lineno">13504</span>&#160;                <span class="comment">// Different block</span></div>
+<div class="line"><a name="l13505"></a><span class="lineno">13505</span>&#160;                <span class="keywordflow">else</span></div>
+<div class="line"><a name="l13506"></a><span class="lineno">13506</span>&#160;                {</div>
+<div class="line"><a name="l13507"></a><span class="lineno">13507</span>&#160;                    <span class="comment">// MOVE OPTION 2: Move the allocation to a different block.</span></div>
+<div class="line"><a name="l13508"></a><span class="lineno">13508</span>&#160; </div>
+<div class="line"><a name="l13509"></a><span class="lineno">13509</span>&#160;                    VMA_ASSERT(dstBlockInfoIndex &lt; srcBlockInfoIndex);</div>
+<div class="line"><a name="l13510"></a><span class="lineno">13510</span>&#160;                    VMA_ASSERT(dstAllocOffset + srcAllocSize &lt;= dstBlockSize);</div>
+<div class="line"><a name="l13511"></a><span class="lineno">13511</span>&#160; </div>
+<div class="line"><a name="l13512"></a><span class="lineno">13512</span>&#160;                    VmaSuballocation suballoc = *srcSuballocIt;</div>
+<div class="line"><a name="l13513"></a><span class="lineno">13513</span>&#160;                    suballoc.offset = dstAllocOffset;</div>
+<div class="line"><a name="l13514"></a><span class="lineno">13514</span>&#160;                    suballoc.hAllocation-&gt;ChangeBlockAllocation(m_hAllocator, pDstBlock, dstAllocOffset);</div>
+<div class="line"><a name="l13515"></a><span class="lineno">13515</span>&#160;                    dstOffset = dstAllocOffset + srcAllocSize;</div>
+<div class="line"><a name="l13516"></a><span class="lineno">13516</span>&#160;                    m_BytesMoved += srcAllocSize;</div>
+<div class="line"><a name="l13517"></a><span class="lineno">13517</span>&#160;                    ++m_AllocationsMoved;</div>
+<div class="line"><a name="l13518"></a><span class="lineno">13518</span>&#160; </div>
+<div class="line"><a name="l13519"></a><span class="lineno">13519</span>&#160;                    VmaSuballocationList::iterator nextSuballocIt = srcSuballocIt;</div>
+<div class="line"><a name="l13520"></a><span class="lineno">13520</span>&#160;                    ++nextSuballocIt;</div>
+<div class="line"><a name="l13521"></a><span class="lineno">13521</span>&#160;                    pSrcMetadata-&gt;m_Suballocations.erase(srcSuballocIt);</div>
+<div class="line"><a name="l13522"></a><span class="lineno">13522</span>&#160;                    srcSuballocIt = nextSuballocIt;</div>
+<div class="line"><a name="l13523"></a><span class="lineno">13523</span>&#160; </div>
+<div class="line"><a name="l13524"></a><span class="lineno">13524</span>&#160;                    pDstMetadata-&gt;m_Suballocations.push_back(suballoc);</div>
+<div class="line"><a name="l13525"></a><span class="lineno">13525</span>&#160; </div>
+<div class="line"><a name="l13526"></a><span class="lineno">13526</span>&#160;                    VmaDefragmentationMove move = {</div>
+<div class="line"><a name="l13527"></a><span class="lineno">13527</span>&#160;                        srcOrigBlockIndex, dstOrigBlockIndex,</div>
+<div class="line"><a name="l13528"></a><span class="lineno">13528</span>&#160;                        srcAllocOffset, dstAllocOffset,</div>
+<div class="line"><a name="l13529"></a><span class="lineno">13529</span>&#160;                        srcAllocSize };</div>
+<div class="line"><a name="l13530"></a><span class="lineno">13530</span>&#160;                    moves.push_back(move);</div>
+<div class="line"><a name="l13531"></a><span class="lineno">13531</span>&#160;                }</div>
+<div class="line"><a name="l13532"></a><span class="lineno">13532</span>&#160;            }</div>
+<div class="line"><a name="l13533"></a><span class="lineno">13533</span>&#160;        }</div>
+<div class="line"><a name="l13534"></a><span class="lineno">13534</span>&#160;    }</div>
+<div class="line"><a name="l13535"></a><span class="lineno">13535</span>&#160; </div>
+<div class="line"><a name="l13536"></a><span class="lineno">13536</span>&#160;    m_BlockInfos.clear();</div>
+<div class="line"><a name="l13537"></a><span class="lineno">13537</span>&#160;    </div>
+<div class="line"><a name="l13538"></a><span class="lineno">13538</span>&#160;    PostprocessMetadata();</div>
+<div class="line"><a name="l13539"></a><span class="lineno">13539</span>&#160; </div>
+<div class="line"><a name="l13540"></a><span class="lineno">13540</span>&#160;    <span class="keywordflow">return</span> VK_SUCCESS;</div>
+<div class="line"><a name="l13541"></a><span class="lineno">13541</span>&#160;}</div>
+<div class="line"><a name="l13542"></a><span class="lineno">13542</span>&#160; </div>
+<div class="line"><a name="l13543"></a><span class="lineno">13543</span>&#160;<span class="keywordtype">void</span> VmaDefragmentationAlgorithm_Fast::PreprocessMetadata()</div>
+<div class="line"><a name="l13544"></a><span class="lineno">13544</span>&#160;{</div>
+<div class="line"><a name="l13545"></a><span class="lineno">13545</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> blockCount = m_pBlockVector-&gt;GetBlockCount();</div>
+<div class="line"><a name="l13546"></a><span class="lineno">13546</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; blockIndex &lt; blockCount; ++blockIndex)</div>
+<div class="line"><a name="l13547"></a><span class="lineno">13547</span>&#160;    {</div>
+<div class="line"><a name="l13548"></a><span class="lineno">13548</span>&#160;        VmaBlockMetadata_Generic* <span class="keyword">const</span> pMetadata =</div>
+<div class="line"><a name="l13549"></a><span class="lineno">13549</span>&#160;            (VmaBlockMetadata_Generic*)m_pBlockVector-&gt;GetBlock(blockIndex)-&gt;m_pMetadata;</div>
+<div class="line"><a name="l13550"></a><span class="lineno">13550</span>&#160;        pMetadata-&gt;m_FreeCount = 0;</div>
+<div class="line"><a name="l13551"></a><span class="lineno">13551</span>&#160;        pMetadata-&gt;m_SumFreeSize = pMetadata-&gt;GetSize();</div>
+<div class="line"><a name="l13552"></a><span class="lineno">13552</span>&#160;        pMetadata-&gt;m_FreeSuballocationsBySize.clear();</div>
+<div class="line"><a name="l13553"></a><span class="lineno">13553</span>&#160;        <span class="keywordflow">for</span>(VmaSuballocationList::iterator it = pMetadata-&gt;m_Suballocations.begin();</div>
+<div class="line"><a name="l13554"></a><span class="lineno">13554</span>&#160;            it != pMetadata-&gt;m_Suballocations.end(); )</div>
+<div class="line"><a name="l13555"></a><span class="lineno">13555</span>&#160;        {</div>
+<div class="line"><a name="l13556"></a><span class="lineno">13556</span>&#160;            <span class="keywordflow">if</span>(it-&gt;type == VMA_SUBALLOCATION_TYPE_FREE)</div>
+<div class="line"><a name="l13557"></a><span class="lineno">13557</span>&#160;            {</div>
+<div class="line"><a name="l13558"></a><span class="lineno">13558</span>&#160;                VmaSuballocationList::iterator nextIt = it;</div>
+<div class="line"><a name="l13559"></a><span class="lineno">13559</span>&#160;                ++nextIt;</div>
+<div class="line"><a name="l13560"></a><span class="lineno">13560</span>&#160;                pMetadata-&gt;m_Suballocations.erase(it);</div>
+<div class="line"><a name="l13561"></a><span class="lineno">13561</span>&#160;                it = nextIt;</div>
+<div class="line"><a name="l13562"></a><span class="lineno">13562</span>&#160;            }</div>
+<div class="line"><a name="l13563"></a><span class="lineno">13563</span>&#160;            <span class="keywordflow">else</span></div>
+<div class="line"><a name="l13564"></a><span class="lineno">13564</span>&#160;            {</div>
+<div class="line"><a name="l13565"></a><span class="lineno">13565</span>&#160;                ++it;</div>
+<div class="line"><a name="l13566"></a><span class="lineno">13566</span>&#160;            }</div>
+<div class="line"><a name="l13567"></a><span class="lineno">13567</span>&#160;        }</div>
+<div class="line"><a name="l13568"></a><span class="lineno">13568</span>&#160;    }</div>
+<div class="line"><a name="l13569"></a><span class="lineno">13569</span>&#160;}</div>
+<div class="line"><a name="l13570"></a><span class="lineno">13570</span>&#160; </div>
+<div class="line"><a name="l13571"></a><span class="lineno">13571</span>&#160;<span class="keywordtype">void</span> VmaDefragmentationAlgorithm_Fast::PostprocessMetadata()</div>
+<div class="line"><a name="l13572"></a><span class="lineno">13572</span>&#160;{</div>
+<div class="line"><a name="l13573"></a><span class="lineno">13573</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> blockCount = m_pBlockVector-&gt;GetBlockCount();</div>
+<div class="line"><a name="l13574"></a><span class="lineno">13574</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> blockIndex = 0; blockIndex &lt; blockCount; ++blockIndex)</div>
+<div class="line"><a name="l13575"></a><span class="lineno">13575</span>&#160;    {</div>
+<div class="line"><a name="l13576"></a><span class="lineno">13576</span>&#160;        VmaBlockMetadata_Generic* <span class="keyword">const</span> pMetadata =</div>
+<div class="line"><a name="l13577"></a><span class="lineno">13577</span>&#160;            (VmaBlockMetadata_Generic*)m_pBlockVector-&gt;GetBlock(blockIndex)-&gt;m_pMetadata;</div>
+<div class="line"><a name="l13578"></a><span class="lineno">13578</span>&#160;        <span class="keyword">const</span> VkDeviceSize blockSize = pMetadata-&gt;GetSize();</div>
+<div class="line"><a name="l13579"></a><span class="lineno">13579</span>&#160;        </div>
+<div class="line"><a name="l13580"></a><span class="lineno">13580</span>&#160;        <span class="comment">// No allocations in this block - entire area is free.</span></div>
+<div class="line"><a name="l13581"></a><span class="lineno">13581</span>&#160;        <span class="keywordflow">if</span>(pMetadata-&gt;m_Suballocations.empty())</div>
+<div class="line"><a name="l13582"></a><span class="lineno">13582</span>&#160;        {</div>
+<div class="line"><a name="l13583"></a><span class="lineno">13583</span>&#160;            pMetadata-&gt;m_FreeCount = 1;</div>
+<div class="line"><a name="l13584"></a><span class="lineno">13584</span>&#160;            <span class="comment">//pMetadata-&gt;m_SumFreeSize is already set to blockSize.</span></div>
+<div class="line"><a name="l13585"></a><span class="lineno">13585</span>&#160;            VmaSuballocation suballoc = {</div>
+<div class="line"><a name="l13586"></a><span class="lineno">13586</span>&#160;                0, <span class="comment">// offset</span></div>
+<div class="line"><a name="l13587"></a><span class="lineno">13587</span>&#160;                blockSize, <span class="comment">// size</span></div>
+<div class="line"><a name="l13588"></a><span class="lineno">13588</span>&#160;                VMA_NULL, <span class="comment">// hAllocation</span></div>
+<div class="line"><a name="l13589"></a><span class="lineno">13589</span>&#160;                VMA_SUBALLOCATION_TYPE_FREE };</div>
+<div class="line"><a name="l13590"></a><span class="lineno">13590</span>&#160;            pMetadata-&gt;m_Suballocations.push_back(suballoc);</div>
+<div class="line"><a name="l13591"></a><span class="lineno">13591</span>&#160;            pMetadata-&gt;RegisterFreeSuballocation(pMetadata-&gt;m_Suballocations.begin());</div>
+<div class="line"><a name="l13592"></a><span class="lineno">13592</span>&#160;        }</div>
+<div class="line"><a name="l13593"></a><span class="lineno">13593</span>&#160;        <span class="comment">// There are some allocations in this block.</span></div>
+<div class="line"><a name="l13594"></a><span class="lineno">13594</span>&#160;        <span class="keywordflow">else</span></div>
+<div class="line"><a name="l13595"></a><span class="lineno">13595</span>&#160;        {</div>
+<div class="line"><a name="l13596"></a><span class="lineno">13596</span>&#160;            VkDeviceSize offset = 0;</div>
+<div class="line"><a name="l13597"></a><span class="lineno">13597</span>&#160;            VmaSuballocationList::iterator it;</div>
+<div class="line"><a name="l13598"></a><span class="lineno">13598</span>&#160;            <span class="keywordflow">for</span>(it = pMetadata-&gt;m_Suballocations.begin();</div>
+<div class="line"><a name="l13599"></a><span class="lineno">13599</span>&#160;                it != pMetadata-&gt;m_Suballocations.end();</div>
+<div class="line"><a name="l13600"></a><span class="lineno">13600</span>&#160;                ++it)</div>
+<div class="line"><a name="l13601"></a><span class="lineno">13601</span>&#160;            {</div>
+<div class="line"><a name="l13602"></a><span class="lineno">13602</span>&#160;                VMA_ASSERT(it-&gt;type != VMA_SUBALLOCATION_TYPE_FREE);</div>
+<div class="line"><a name="l13603"></a><span class="lineno">13603</span>&#160;                VMA_ASSERT(it-&gt;offset &gt;= offset);</div>
+<div class="line"><a name="l13604"></a><span class="lineno">13604</span>&#160; </div>
+<div class="line"><a name="l13605"></a><span class="lineno">13605</span>&#160;                <span class="comment">// Need to insert preceding free space.</span></div>
+<div class="line"><a name="l13606"></a><span class="lineno">13606</span>&#160;                <span class="keywordflow">if</span>(it-&gt;offset &gt; offset)</div>
+<div class="line"><a name="l13607"></a><span class="lineno">13607</span>&#160;                {</div>
+<div class="line"><a name="l13608"></a><span class="lineno">13608</span>&#160;                    ++pMetadata-&gt;m_FreeCount;</div>
+<div class="line"><a name="l13609"></a><span class="lineno">13609</span>&#160;                    <span class="keyword">const</span> VkDeviceSize freeSize = it-&gt;offset - offset;</div>
+<div class="line"><a name="l13610"></a><span class="lineno">13610</span>&#160;                    VmaSuballocation suballoc = {</div>
+<div class="line"><a name="l13611"></a><span class="lineno">13611</span>&#160;                        offset, <span class="comment">// offset</span></div>
+<div class="line"><a name="l13612"></a><span class="lineno">13612</span>&#160;                        freeSize, <span class="comment">// size</span></div>
+<div class="line"><a name="l13613"></a><span class="lineno">13613</span>&#160;                        VMA_NULL, <span class="comment">// hAllocation</span></div>
+<div class="line"><a name="l13614"></a><span class="lineno">13614</span>&#160;                        VMA_SUBALLOCATION_TYPE_FREE };</div>
+<div class="line"><a name="l13615"></a><span class="lineno">13615</span>&#160;                    VmaSuballocationList::iterator precedingFreeIt = pMetadata-&gt;m_Suballocations.insert(it, suballoc);</div>
+<div class="line"><a name="l13616"></a><span class="lineno">13616</span>&#160;                    <span class="keywordflow">if</span>(freeSize &gt;= VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER)</div>
+<div class="line"><a name="l13617"></a><span class="lineno">13617</span>&#160;                    {</div>
+<div class="line"><a name="l13618"></a><span class="lineno">13618</span>&#160;                        pMetadata-&gt;m_FreeSuballocationsBySize.push_back(precedingFreeIt);</div>
+<div class="line"><a name="l13619"></a><span class="lineno">13619</span>&#160;                    }</div>
+<div class="line"><a name="l13620"></a><span class="lineno">13620</span>&#160;                }</div>
+<div class="line"><a name="l13621"></a><span class="lineno">13621</span>&#160; </div>
+<div class="line"><a name="l13622"></a><span class="lineno">13622</span>&#160;                pMetadata-&gt;m_SumFreeSize -= it-&gt;size;</div>
+<div class="line"><a name="l13623"></a><span class="lineno">13623</span>&#160;                offset = it-&gt;offset + it-&gt;size;</div>
+<div class="line"><a name="l13624"></a><span class="lineno">13624</span>&#160;            }</div>
+<div class="line"><a name="l13625"></a><span class="lineno">13625</span>&#160; </div>
+<div class="line"><a name="l13626"></a><span class="lineno">13626</span>&#160;            <span class="comment">// Need to insert trailing free space.</span></div>
+<div class="line"><a name="l13627"></a><span class="lineno">13627</span>&#160;            <span class="keywordflow">if</span>(offset &lt; blockSize)</div>
+<div class="line"><a name="l13628"></a><span class="lineno">13628</span>&#160;            {</div>
+<div class="line"><a name="l13629"></a><span class="lineno">13629</span>&#160;                ++pMetadata-&gt;m_FreeCount;</div>
+<div class="line"><a name="l13630"></a><span class="lineno">13630</span>&#160;                <span class="keyword">const</span> VkDeviceSize freeSize = blockSize - offset;</div>
+<div class="line"><a name="l13631"></a><span class="lineno">13631</span>&#160;                VmaSuballocation suballoc = {</div>
+<div class="line"><a name="l13632"></a><span class="lineno">13632</span>&#160;                    offset, <span class="comment">// offset</span></div>
+<div class="line"><a name="l13633"></a><span class="lineno">13633</span>&#160;                    freeSize, <span class="comment">// size</span></div>
+<div class="line"><a name="l13634"></a><span class="lineno">13634</span>&#160;                    VMA_NULL, <span class="comment">// hAllocation</span></div>
+<div class="line"><a name="l13635"></a><span class="lineno">13635</span>&#160;                    VMA_SUBALLOCATION_TYPE_FREE };</div>
+<div class="line"><a name="l13636"></a><span class="lineno">13636</span>&#160;                VMA_ASSERT(it == pMetadata-&gt;m_Suballocations.end());</div>
+<div class="line"><a name="l13637"></a><span class="lineno">13637</span>&#160;                VmaSuballocationList::iterator trailingFreeIt = pMetadata-&gt;m_Suballocations.insert(it, suballoc);</div>
+<div class="line"><a name="l13638"></a><span class="lineno">13638</span>&#160;                <span class="keywordflow">if</span>(freeSize &gt; VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER)</div>
+<div class="line"><a name="l13639"></a><span class="lineno">13639</span>&#160;                {</div>
+<div class="line"><a name="l13640"></a><span class="lineno">13640</span>&#160;                    pMetadata-&gt;m_FreeSuballocationsBySize.push_back(trailingFreeIt);</div>
+<div class="line"><a name="l13641"></a><span class="lineno">13641</span>&#160;                }</div>
+<div class="line"><a name="l13642"></a><span class="lineno">13642</span>&#160;            }</div>
 <div class="line"><a name="l13643"></a><span class="lineno">13643</span>&#160; </div>
-<div class="line"><a name="l13644"></a><span class="lineno">13644</span>&#160;        VMA_HEAVY_ASSERT(pMetadata-&gt;Validate());</div>
-<div class="line"><a name="l13645"></a><span class="lineno">13645</span>&#160;    }</div>
-<div class="line"><a name="l13646"></a><span class="lineno">13646</span>&#160;}</div>
-<div class="line"><a name="l13647"></a><span class="lineno">13647</span>&#160; </div>
-<div class="line"><a name="l13648"></a><span class="lineno">13648</span>&#160;<span class="keywordtype">void</span> VmaDefragmentationAlgorithm_Fast::InsertSuballoc(VmaBlockMetadata_Generic* pMetadata, <span class="keyword">const</span> VmaSuballocation&amp; suballoc)</div>
-<div class="line"><a name="l13649"></a><span class="lineno">13649</span>&#160;{</div>
-<div class="line"><a name="l13650"></a><span class="lineno">13650</span>&#160;    <span class="comment">// TODO: Optimize somehow. Remember iterator instead of searching for it linearly.</span></div>
-<div class="line"><a name="l13651"></a><span class="lineno">13651</span>&#160;    VmaSuballocationList::iterator it = pMetadata-&gt;m_Suballocations.begin();</div>
-<div class="line"><a name="l13652"></a><span class="lineno">13652</span>&#160;    <span class="keywordflow">while</span>(it != pMetadata-&gt;m_Suballocations.end())</div>
-<div class="line"><a name="l13653"></a><span class="lineno">13653</span>&#160;    {</div>
-<div class="line"><a name="l13654"></a><span class="lineno">13654</span>&#160;        <span class="keywordflow">if</span>(it-&gt;offset &lt; suballoc.offset)</div>
-<div class="line"><a name="l13655"></a><span class="lineno">13655</span>&#160;        {</div>
-<div class="line"><a name="l13656"></a><span class="lineno">13656</span>&#160;            ++it;</div>
-<div class="line"><a name="l13657"></a><span class="lineno">13657</span>&#160;        }</div>
-<div class="line"><a name="l13658"></a><span class="lineno">13658</span>&#160;    }</div>
-<div class="line"><a name="l13659"></a><span class="lineno">13659</span>&#160;    pMetadata-&gt;m_Suballocations.insert(it, suballoc);</div>
-<div class="line"><a name="l13660"></a><span class="lineno">13660</span>&#160;}</div>
-<div class="line"><a name="l13661"></a><span class="lineno">13661</span>&#160; </div>
-<div class="line"><a name="l13663"></a><span class="lineno">13663</span>&#160;<span class="comment">// VmaBlockVectorDefragmentationContext</span></div>
-<div class="line"><a name="l13664"></a><span class="lineno">13664</span>&#160; </div>
-<div class="line"><a name="l13665"></a><span class="lineno">13665</span>&#160;VmaBlockVectorDefragmentationContext::VmaBlockVectorDefragmentationContext(</div>
-<div class="line"><a name="l13666"></a><span class="lineno">13666</span>&#160;    <a class="code" href="struct_vma_allocator.html">VmaAllocator</a> hAllocator,</div>
-<div class="line"><a name="l13667"></a><span class="lineno">13667</span>&#160;    <a class="code" href="struct_vma_pool.html">VmaPool</a> hCustomPool,</div>
-<div class="line"><a name="l13668"></a><span class="lineno">13668</span>&#160;    VmaBlockVector* pBlockVector,</div>
-<div class="line"><a name="l13669"></a><span class="lineno">13669</span>&#160;    uint32_t currFrameIndex) :</div>
-<div class="line"><a name="l13670"></a><span class="lineno">13670</span>&#160;    res(VK_SUCCESS),</div>
-<div class="line"><a name="l13671"></a><span class="lineno">13671</span>&#160;    mutexLocked(false),</div>
-<div class="line"><a name="l13672"></a><span class="lineno">13672</span>&#160;    blockContexts(VmaStlAllocator&lt;VmaBlockDefragmentationContext&gt;(hAllocator-&gt;GetAllocationCallbacks())),</div>
-<div class="line"><a name="l13673"></a><span class="lineno">13673</span>&#160;    m_hAllocator(hAllocator),</div>
-<div class="line"><a name="l13674"></a><span class="lineno">13674</span>&#160;    m_hCustomPool(hCustomPool),</div>
-<div class="line"><a name="l13675"></a><span class="lineno">13675</span>&#160;    m_pBlockVector(pBlockVector),</div>
-<div class="line"><a name="l13676"></a><span class="lineno">13676</span>&#160;    m_CurrFrameIndex(currFrameIndex),</div>
-<div class="line"><a name="l13677"></a><span class="lineno">13677</span>&#160;    m_pAlgorithm(VMA_NULL),</div>
-<div class="line"><a name="l13678"></a><span class="lineno">13678</span>&#160;    m_Allocations(VmaStlAllocator&lt;AllocInfo&gt;(hAllocator-&gt;GetAllocationCallbacks())),</div>
-<div class="line"><a name="l13679"></a><span class="lineno">13679</span>&#160;    m_AllAllocations(false)</div>
-<div class="line"><a name="l13680"></a><span class="lineno">13680</span>&#160;{</div>
-<div class="line"><a name="l13681"></a><span class="lineno">13681</span>&#160;}</div>
-<div class="line"><a name="l13682"></a><span class="lineno">13682</span>&#160; </div>
-<div class="line"><a name="l13683"></a><span class="lineno">13683</span>&#160;VmaBlockVectorDefragmentationContext::~VmaBlockVectorDefragmentationContext()</div>
-<div class="line"><a name="l13684"></a><span class="lineno">13684</span>&#160;{</div>
-<div class="line"><a name="l13685"></a><span class="lineno">13685</span>&#160;    vma_delete(m_hAllocator, m_pAlgorithm);</div>
-<div class="line"><a name="l13686"></a><span class="lineno">13686</span>&#160;}</div>
-<div class="line"><a name="l13687"></a><span class="lineno">13687</span>&#160; </div>
-<div class="line"><a name="l13688"></a><span class="lineno">13688</span>&#160;<span class="keywordtype">void</span> VmaBlockVectorDefragmentationContext::AddAllocation(<a class="code" href="struct_vma_allocation.html">VmaAllocation</a> hAlloc, VkBool32* pChanged)</div>
-<div class="line"><a name="l13689"></a><span class="lineno">13689</span>&#160;{</div>
-<div class="line"><a name="l13690"></a><span class="lineno">13690</span>&#160;    AllocInfo info = { hAlloc, pChanged };</div>
-<div class="line"><a name="l13691"></a><span class="lineno">13691</span>&#160;    m_Allocations.push_back(info);</div>
+<div class="line"><a name="l13644"></a><span class="lineno">13644</span>&#160;            VMA_SORT(</div>
+<div class="line"><a name="l13645"></a><span class="lineno">13645</span>&#160;                pMetadata-&gt;m_FreeSuballocationsBySize.begin(),</div>
+<div class="line"><a name="l13646"></a><span class="lineno">13646</span>&#160;                pMetadata-&gt;m_FreeSuballocationsBySize.end(),</div>
+<div class="line"><a name="l13647"></a><span class="lineno">13647</span>&#160;                VmaSuballocationItemSizeLess());</div>
+<div class="line"><a name="l13648"></a><span class="lineno">13648</span>&#160;        }</div>
+<div class="line"><a name="l13649"></a><span class="lineno">13649</span>&#160; </div>
+<div class="line"><a name="l13650"></a><span class="lineno">13650</span>&#160;        VMA_HEAVY_ASSERT(pMetadata-&gt;Validate());</div>
+<div class="line"><a name="l13651"></a><span class="lineno">13651</span>&#160;    }</div>
+<div class="line"><a name="l13652"></a><span class="lineno">13652</span>&#160;}</div>
+<div class="line"><a name="l13653"></a><span class="lineno">13653</span>&#160; </div>
+<div class="line"><a name="l13654"></a><span class="lineno">13654</span>&#160;<span class="keywordtype">void</span> VmaDefragmentationAlgorithm_Fast::InsertSuballoc(VmaBlockMetadata_Generic* pMetadata, <span class="keyword">const</span> VmaSuballocation&amp; suballoc)</div>
+<div class="line"><a name="l13655"></a><span class="lineno">13655</span>&#160;{</div>
+<div class="line"><a name="l13656"></a><span class="lineno">13656</span>&#160;    <span class="comment">// TODO: Optimize somehow. Remember iterator instead of searching for it linearly.</span></div>
+<div class="line"><a name="l13657"></a><span class="lineno">13657</span>&#160;    VmaSuballocationList::iterator it = pMetadata-&gt;m_Suballocations.begin();</div>
+<div class="line"><a name="l13658"></a><span class="lineno">13658</span>&#160;    <span class="keywordflow">while</span>(it != pMetadata-&gt;m_Suballocations.end())</div>
+<div class="line"><a name="l13659"></a><span class="lineno">13659</span>&#160;    {</div>
+<div class="line"><a name="l13660"></a><span class="lineno">13660</span>&#160;        <span class="keywordflow">if</span>(it-&gt;offset &lt; suballoc.offset)</div>
+<div class="line"><a name="l13661"></a><span class="lineno">13661</span>&#160;        {</div>
+<div class="line"><a name="l13662"></a><span class="lineno">13662</span>&#160;            ++it;</div>
+<div class="line"><a name="l13663"></a><span class="lineno">13663</span>&#160;        }</div>
+<div class="line"><a name="l13664"></a><span class="lineno">13664</span>&#160;    }</div>
+<div class="line"><a name="l13665"></a><span class="lineno">13665</span>&#160;    pMetadata-&gt;m_Suballocations.insert(it, suballoc);</div>
+<div class="line"><a name="l13666"></a><span class="lineno">13666</span>&#160;}</div>
+<div class="line"><a name="l13667"></a><span class="lineno">13667</span>&#160; </div>
+<div class="line"><a name="l13669"></a><span class="lineno">13669</span>&#160;<span class="comment">// VmaBlockVectorDefragmentationContext</span></div>
+<div class="line"><a name="l13670"></a><span class="lineno">13670</span>&#160; </div>
+<div class="line"><a name="l13671"></a><span class="lineno">13671</span>&#160;VmaBlockVectorDefragmentationContext::VmaBlockVectorDefragmentationContext(</div>
+<div class="line"><a name="l13672"></a><span class="lineno">13672</span>&#160;    <a class="code" href="struct_vma_allocator.html">VmaAllocator</a> hAllocator,</div>
+<div class="line"><a name="l13673"></a><span class="lineno">13673</span>&#160;    <a class="code" href="struct_vma_pool.html">VmaPool</a> hCustomPool,</div>
+<div class="line"><a name="l13674"></a><span class="lineno">13674</span>&#160;    VmaBlockVector* pBlockVector,</div>
+<div class="line"><a name="l13675"></a><span class="lineno">13675</span>&#160;    uint32_t currFrameIndex) :</div>
+<div class="line"><a name="l13676"></a><span class="lineno">13676</span>&#160;    res(VK_SUCCESS),</div>
+<div class="line"><a name="l13677"></a><span class="lineno">13677</span>&#160;    mutexLocked(false),</div>
+<div class="line"><a name="l13678"></a><span class="lineno">13678</span>&#160;    blockContexts(VmaStlAllocator&lt;VmaBlockDefragmentationContext&gt;(hAllocator-&gt;GetAllocationCallbacks())),</div>
+<div class="line"><a name="l13679"></a><span class="lineno">13679</span>&#160;    m_hAllocator(hAllocator),</div>
+<div class="line"><a name="l13680"></a><span class="lineno">13680</span>&#160;    m_hCustomPool(hCustomPool),</div>
+<div class="line"><a name="l13681"></a><span class="lineno">13681</span>&#160;    m_pBlockVector(pBlockVector),</div>
+<div class="line"><a name="l13682"></a><span class="lineno">13682</span>&#160;    m_CurrFrameIndex(currFrameIndex),</div>
+<div class="line"><a name="l13683"></a><span class="lineno">13683</span>&#160;    m_pAlgorithm(VMA_NULL),</div>
+<div class="line"><a name="l13684"></a><span class="lineno">13684</span>&#160;    m_Allocations(VmaStlAllocator&lt;AllocInfo&gt;(hAllocator-&gt;GetAllocationCallbacks())),</div>
+<div class="line"><a name="l13685"></a><span class="lineno">13685</span>&#160;    m_AllAllocations(false)</div>
+<div class="line"><a name="l13686"></a><span class="lineno">13686</span>&#160;{</div>
+<div class="line"><a name="l13687"></a><span class="lineno">13687</span>&#160;}</div>
+<div class="line"><a name="l13688"></a><span class="lineno">13688</span>&#160; </div>
+<div class="line"><a name="l13689"></a><span class="lineno">13689</span>&#160;VmaBlockVectorDefragmentationContext::~VmaBlockVectorDefragmentationContext()</div>
+<div class="line"><a name="l13690"></a><span class="lineno">13690</span>&#160;{</div>
+<div class="line"><a name="l13691"></a><span class="lineno">13691</span>&#160;    vma_delete(m_hAllocator, m_pAlgorithm);</div>
 <div class="line"><a name="l13692"></a><span class="lineno">13692</span>&#160;}</div>
 <div class="line"><a name="l13693"></a><span class="lineno">13693</span>&#160; </div>
-<div class="line"><a name="l13694"></a><span class="lineno">13694</span>&#160;<span class="keywordtype">void</span> VmaBlockVectorDefragmentationContext::Begin(<span class="keywordtype">bool</span> overlappingMoveSupported)</div>
+<div class="line"><a name="l13694"></a><span class="lineno">13694</span>&#160;<span class="keywordtype">void</span> VmaBlockVectorDefragmentationContext::AddAllocation(<a class="code" href="struct_vma_allocation.html">VmaAllocation</a> hAlloc, VkBool32* pChanged)</div>
 <div class="line"><a name="l13695"></a><span class="lineno">13695</span>&#160;{</div>
-<div class="line"><a name="l13696"></a><span class="lineno">13696</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> allAllocations = m_AllAllocations ||</div>
-<div class="line"><a name="l13697"></a><span class="lineno">13697</span>&#160;        m_Allocations.size() == m_pBlockVector-&gt;CalcAllocationCount();</div>
-<div class="line"><a name="l13698"></a><span class="lineno">13698</span>&#160; </div>
-<div class="line"><a name="l13699"></a><span class="lineno">13699</span>&#160;<span class="comment">    /********************************</span></div>
-<div class="line"><a name="l13700"></a><span class="lineno">13700</span>&#160;<span class="comment">    HERE IS THE CHOICE OF DEFRAGMENTATION ALGORITHM.</span></div>
-<div class="line"><a name="l13701"></a><span class="lineno">13701</span>&#160;<span class="comment">    ********************************/</span></div>
-<div class="line"><a name="l13702"></a><span class="lineno">13702</span>&#160; </div>
-<div class="line"><a name="l13703"></a><span class="lineno">13703</span>&#160;    <span class="comment">/*</span></div>
-<div class="line"><a name="l13704"></a><span class="lineno">13704</span>&#160;<span class="comment">    Fast algorithm is supported only when certain criteria are met:</span></div>
-<div class="line"><a name="l13705"></a><span class="lineno">13705</span>&#160;<span class="comment">    - VMA_DEBUG_MARGIN is 0.</span></div>
-<div class="line"><a name="l13706"></a><span class="lineno">13706</span>&#160;<span class="comment">    - All allocations in this block vector are moveable.</span></div>
-<div class="line"><a name="l13707"></a><span class="lineno">13707</span>&#160;<span class="comment">    - There is no possibility of image/buffer granularity conflict.</span></div>
-<div class="line"><a name="l13708"></a><span class="lineno">13708</span>&#160;<span class="comment">    */</span></div>
-<div class="line"><a name="l13709"></a><span class="lineno">13709</span>&#160;    <span class="keywordflow">if</span>(VMA_DEBUG_MARGIN == 0 &amp;&amp;</div>
-<div class="line"><a name="l13710"></a><span class="lineno">13710</span>&#160;        allAllocations &amp;&amp;</div>
-<div class="line"><a name="l13711"></a><span class="lineno">13711</span>&#160;        !m_pBlockVector-&gt;IsBufferImageGranularityConflictPossible())</div>
-<div class="line"><a name="l13712"></a><span class="lineno">13712</span>&#160;    {</div>
-<div class="line"><a name="l13713"></a><span class="lineno">13713</span>&#160;        m_pAlgorithm = vma_new(m_hAllocator, VmaDefragmentationAlgorithm_Fast)(</div>
-<div class="line"><a name="l13714"></a><span class="lineno">13714</span>&#160;            m_hAllocator, m_pBlockVector, m_CurrFrameIndex, overlappingMoveSupported);</div>
-<div class="line"><a name="l13715"></a><span class="lineno">13715</span>&#160;    }</div>
-<div class="line"><a name="l13716"></a><span class="lineno">13716</span>&#160;    <span class="keywordflow">else</span></div>
-<div class="line"><a name="l13717"></a><span class="lineno">13717</span>&#160;    {</div>
-<div class="line"><a name="l13718"></a><span class="lineno">13718</span>&#160;        m_pAlgorithm = vma_new(m_hAllocator, VmaDefragmentationAlgorithm_Generic)(</div>
-<div class="line"><a name="l13719"></a><span class="lineno">13719</span>&#160;            m_hAllocator, m_pBlockVector, m_CurrFrameIndex, overlappingMoveSupported);</div>
-<div class="line"><a name="l13720"></a><span class="lineno">13720</span>&#160;    }</div>
-<div class="line"><a name="l13721"></a><span class="lineno">13721</span>&#160; </div>
-<div class="line"><a name="l13722"></a><span class="lineno">13722</span>&#160;    <span class="keywordflow">if</span>(allAllocations)</div>
+<div class="line"><a name="l13696"></a><span class="lineno">13696</span>&#160;    AllocInfo info = { hAlloc, pChanged };</div>
+<div class="line"><a name="l13697"></a><span class="lineno">13697</span>&#160;    m_Allocations.push_back(info);</div>
+<div class="line"><a name="l13698"></a><span class="lineno">13698</span>&#160;}</div>
+<div class="line"><a name="l13699"></a><span class="lineno">13699</span>&#160; </div>
+<div class="line"><a name="l13700"></a><span class="lineno">13700</span>&#160;<span class="keywordtype">void</span> VmaBlockVectorDefragmentationContext::Begin(<span class="keywordtype">bool</span> overlappingMoveSupported)</div>
+<div class="line"><a name="l13701"></a><span class="lineno">13701</span>&#160;{</div>
+<div class="line"><a name="l13702"></a><span class="lineno">13702</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">bool</span> allAllocations = m_AllAllocations ||</div>
+<div class="line"><a name="l13703"></a><span class="lineno">13703</span>&#160;        m_Allocations.size() == m_pBlockVector-&gt;CalcAllocationCount();</div>
+<div class="line"><a name="l13704"></a><span class="lineno">13704</span>&#160; </div>
+<div class="line"><a name="l13705"></a><span class="lineno">13705</span>&#160;<span class="comment">    /********************************</span></div>
+<div class="line"><a name="l13706"></a><span class="lineno">13706</span>&#160;<span class="comment">    HERE IS THE CHOICE OF DEFRAGMENTATION ALGORITHM.</span></div>
+<div class="line"><a name="l13707"></a><span class="lineno">13707</span>&#160;<span class="comment">    ********************************/</span></div>
+<div class="line"><a name="l13708"></a><span class="lineno">13708</span>&#160; </div>
+<div class="line"><a name="l13709"></a><span class="lineno">13709</span>&#160;    <span class="comment">/*</span></div>
+<div class="line"><a name="l13710"></a><span class="lineno">13710</span>&#160;<span class="comment">    Fast algorithm is supported only when certain criteria are met:</span></div>
+<div class="line"><a name="l13711"></a><span class="lineno">13711</span>&#160;<span class="comment">    - VMA_DEBUG_MARGIN is 0.</span></div>
+<div class="line"><a name="l13712"></a><span class="lineno">13712</span>&#160;<span class="comment">    - All allocations in this block vector are moveable.</span></div>
+<div class="line"><a name="l13713"></a><span class="lineno">13713</span>&#160;<span class="comment">    - There is no possibility of image/buffer granularity conflict.</span></div>
+<div class="line"><a name="l13714"></a><span class="lineno">13714</span>&#160;<span class="comment">    */</span></div>
+<div class="line"><a name="l13715"></a><span class="lineno">13715</span>&#160;    <span class="keywordflow">if</span>(VMA_DEBUG_MARGIN == 0 &amp;&amp;</div>
+<div class="line"><a name="l13716"></a><span class="lineno">13716</span>&#160;        allAllocations &amp;&amp;</div>
+<div class="line"><a name="l13717"></a><span class="lineno">13717</span>&#160;        !m_pBlockVector-&gt;IsBufferImageGranularityConflictPossible())</div>
+<div class="line"><a name="l13718"></a><span class="lineno">13718</span>&#160;    {</div>
+<div class="line"><a name="l13719"></a><span class="lineno">13719</span>&#160;        m_pAlgorithm = vma_new(m_hAllocator, VmaDefragmentationAlgorithm_Fast)(</div>
+<div class="line"><a name="l13720"></a><span class="lineno">13720</span>&#160;            m_hAllocator, m_pBlockVector, m_CurrFrameIndex, overlappingMoveSupported);</div>
+<div class="line"><a name="l13721"></a><span class="lineno">13721</span>&#160;    }</div>
+<div class="line"><a name="l13722"></a><span class="lineno">13722</span>&#160;    <span class="keywordflow">else</span></div>
 <div class="line"><a name="l13723"></a><span class="lineno">13723</span>&#160;    {</div>
-<div class="line"><a name="l13724"></a><span class="lineno">13724</span>&#160;        m_pAlgorithm-&gt;AddAll();</div>
-<div class="line"><a name="l13725"></a><span class="lineno">13725</span>&#160;    }</div>
-<div class="line"><a name="l13726"></a><span class="lineno">13726</span>&#160;    <span class="keywordflow">else</span></div>
-<div class="line"><a name="l13727"></a><span class="lineno">13727</span>&#160;    {</div>
-<div class="line"><a name="l13728"></a><span class="lineno">13728</span>&#160;        <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 0, count = m_Allocations.size(); i &lt; count; ++i)</div>
-<div class="line"><a name="l13729"></a><span class="lineno">13729</span>&#160;        {</div>
-<div class="line"><a name="l13730"></a><span class="lineno">13730</span>&#160;            m_pAlgorithm-&gt;AddAllocation(m_Allocations[i].hAlloc, m_Allocations[i].pChanged);</div>
-<div class="line"><a name="l13731"></a><span class="lineno">13731</span>&#160;        }</div>
-<div class="line"><a name="l13732"></a><span class="lineno">13732</span>&#160;    }</div>
-<div class="line"><a name="l13733"></a><span class="lineno">13733</span>&#160;}</div>
-<div class="line"><a name="l13734"></a><span class="lineno">13734</span>&#160; </div>
-<div class="line"><a name="l13736"></a><span class="lineno">13736</span>&#160;<span class="comment">// VmaDefragmentationContext</span></div>
-<div class="line"><a name="l13737"></a><span class="lineno">13737</span>&#160; </div>
-<div class="line"><a name="l13738"></a><span class="lineno">13738</span>&#160;VmaDefragmentationContext_T::VmaDefragmentationContext_T(</div>
-<div class="line"><a name="l13739"></a><span class="lineno">13739</span>&#160;    <a class="code" href="struct_vma_allocator.html">VmaAllocator</a> hAllocator,</div>
-<div class="line"><a name="l13740"></a><span class="lineno">13740</span>&#160;    uint32_t currFrameIndex,</div>
-<div class="line"><a name="l13741"></a><span class="lineno">13741</span>&#160;    uint32_t flags,</div>
-<div class="line"><a name="l13742"></a><span class="lineno">13742</span>&#160;    <a class="code" href="struct_vma_defragmentation_stats.html">VmaDefragmentationStats</a>* pStats) :</div>
-<div class="line"><a name="l13743"></a><span class="lineno">13743</span>&#160;    m_hAllocator(hAllocator),</div>
-<div class="line"><a name="l13744"></a><span class="lineno">13744</span>&#160;    m_CurrFrameIndex(currFrameIndex),</div>
-<div class="line"><a name="l13745"></a><span class="lineno">13745</span>&#160;    m_Flags(flags),</div>
-<div class="line"><a name="l13746"></a><span class="lineno">13746</span>&#160;    m_pStats(pStats),</div>
-<div class="line"><a name="l13747"></a><span class="lineno">13747</span>&#160;    m_CustomPoolContexts(VmaStlAllocator&lt;VmaBlockVectorDefragmentationContext*&gt;(hAllocator-&gt;GetAllocationCallbacks()))</div>
-<div class="line"><a name="l13748"></a><span class="lineno">13748</span>&#160;{</div>
-<div class="line"><a name="l13749"></a><span class="lineno">13749</span>&#160;    memset(m_DefaultPoolContexts, 0, <span class="keyword">sizeof</span>(m_DefaultPoolContexts));</div>
-<div class="line"><a name="l13750"></a><span class="lineno">13750</span>&#160;}</div>
-<div class="line"><a name="l13751"></a><span class="lineno">13751</span>&#160; </div>
-<div class="line"><a name="l13752"></a><span class="lineno">13752</span>&#160;VmaDefragmentationContext_T::~VmaDefragmentationContext_T()</div>
-<div class="line"><a name="l13753"></a><span class="lineno">13753</span>&#160;{</div>
-<div class="line"><a name="l13754"></a><span class="lineno">13754</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = m_CustomPoolContexts.size(); i--; )</div>
-<div class="line"><a name="l13755"></a><span class="lineno">13755</span>&#160;    {</div>
-<div class="line"><a name="l13756"></a><span class="lineno">13756</span>&#160;        VmaBlockVectorDefragmentationContext* pBlockVectorCtx = m_CustomPoolContexts[i];</div>
-<div class="line"><a name="l13757"></a><span class="lineno">13757</span>&#160;        pBlockVectorCtx-&gt;GetBlockVector()-&gt;DefragmentationEnd(pBlockVectorCtx, m_pStats);</div>
-<div class="line"><a name="l13758"></a><span class="lineno">13758</span>&#160;        vma_delete(m_hAllocator, pBlockVectorCtx);</div>
-<div class="line"><a name="l13759"></a><span class="lineno">13759</span>&#160;    }</div>
-<div class="line"><a name="l13760"></a><span class="lineno">13760</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = m_hAllocator-&gt;m_MemProps.memoryTypeCount; i--; )</div>
+<div class="line"><a name="l13724"></a><span class="lineno">13724</span>&#160;        m_pAlgorithm = vma_new(m_hAllocator, VmaDefragmentationAlgorithm_Generic)(</div>
+<div class="line"><a name="l13725"></a><span class="lineno">13725</span>&#160;            m_hAllocator, m_pBlockVector, m_CurrFrameIndex, overlappingMoveSupported);</div>
+<div class="line"><a name="l13726"></a><span class="lineno">13726</span>&#160;    }</div>
+<div class="line"><a name="l13727"></a><span class="lineno">13727</span>&#160; </div>
+<div class="line"><a name="l13728"></a><span class="lineno">13728</span>&#160;    <span class="keywordflow">if</span>(allAllocations)</div>
+<div class="line"><a name="l13729"></a><span class="lineno">13729</span>&#160;    {</div>
+<div class="line"><a name="l13730"></a><span class="lineno">13730</span>&#160;        m_pAlgorithm-&gt;AddAll();</div>
+<div class="line"><a name="l13731"></a><span class="lineno">13731</span>&#160;    }</div>
+<div class="line"><a name="l13732"></a><span class="lineno">13732</span>&#160;    <span class="keywordflow">else</span></div>
+<div class="line"><a name="l13733"></a><span class="lineno">13733</span>&#160;    {</div>
+<div class="line"><a name="l13734"></a><span class="lineno">13734</span>&#160;        <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 0, count = m_Allocations.size(); i &lt; count; ++i)</div>
+<div class="line"><a name="l13735"></a><span class="lineno">13735</span>&#160;        {</div>
+<div class="line"><a name="l13736"></a><span class="lineno">13736</span>&#160;            m_pAlgorithm-&gt;AddAllocation(m_Allocations[i].hAlloc, m_Allocations[i].pChanged);</div>
+<div class="line"><a name="l13737"></a><span class="lineno">13737</span>&#160;        }</div>
+<div class="line"><a name="l13738"></a><span class="lineno">13738</span>&#160;    }</div>
+<div class="line"><a name="l13739"></a><span class="lineno">13739</span>&#160;}</div>
+<div class="line"><a name="l13740"></a><span class="lineno">13740</span>&#160; </div>
+<div class="line"><a name="l13742"></a><span class="lineno">13742</span>&#160;<span class="comment">// VmaDefragmentationContext</span></div>
+<div class="line"><a name="l13743"></a><span class="lineno">13743</span>&#160; </div>
+<div class="line"><a name="l13744"></a><span class="lineno">13744</span>&#160;VmaDefragmentationContext_T::VmaDefragmentationContext_T(</div>
+<div class="line"><a name="l13745"></a><span class="lineno">13745</span>&#160;    <a class="code" href="struct_vma_allocator.html">VmaAllocator</a> hAllocator,</div>
+<div class="line"><a name="l13746"></a><span class="lineno">13746</span>&#160;    uint32_t currFrameIndex,</div>
+<div class="line"><a name="l13747"></a><span class="lineno">13747</span>&#160;    uint32_t flags,</div>
+<div class="line"><a name="l13748"></a><span class="lineno">13748</span>&#160;    <a class="code" href="struct_vma_defragmentation_stats.html">VmaDefragmentationStats</a>* pStats) :</div>
+<div class="line"><a name="l13749"></a><span class="lineno">13749</span>&#160;    m_hAllocator(hAllocator),</div>
+<div class="line"><a name="l13750"></a><span class="lineno">13750</span>&#160;    m_CurrFrameIndex(currFrameIndex),</div>
+<div class="line"><a name="l13751"></a><span class="lineno">13751</span>&#160;    m_Flags(flags),</div>
+<div class="line"><a name="l13752"></a><span class="lineno">13752</span>&#160;    m_pStats(pStats),</div>
+<div class="line"><a name="l13753"></a><span class="lineno">13753</span>&#160;    m_CustomPoolContexts(VmaStlAllocator&lt;VmaBlockVectorDefragmentationContext*&gt;(hAllocator-&gt;GetAllocationCallbacks()))</div>
+<div class="line"><a name="l13754"></a><span class="lineno">13754</span>&#160;{</div>
+<div class="line"><a name="l13755"></a><span class="lineno">13755</span>&#160;    memset(m_DefaultPoolContexts, 0, <span class="keyword">sizeof</span>(m_DefaultPoolContexts));</div>
+<div class="line"><a name="l13756"></a><span class="lineno">13756</span>&#160;}</div>
+<div class="line"><a name="l13757"></a><span class="lineno">13757</span>&#160; </div>
+<div class="line"><a name="l13758"></a><span class="lineno">13758</span>&#160;VmaDefragmentationContext_T::~VmaDefragmentationContext_T()</div>
+<div class="line"><a name="l13759"></a><span class="lineno">13759</span>&#160;{</div>
+<div class="line"><a name="l13760"></a><span class="lineno">13760</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = m_CustomPoolContexts.size(); i--; )</div>
 <div class="line"><a name="l13761"></a><span class="lineno">13761</span>&#160;    {</div>
-<div class="line"><a name="l13762"></a><span class="lineno">13762</span>&#160;        VmaBlockVectorDefragmentationContext* pBlockVectorCtx = m_DefaultPoolContexts[i];</div>
-<div class="line"><a name="l13763"></a><span class="lineno">13763</span>&#160;        <span class="keywordflow">if</span>(pBlockVectorCtx)</div>
-<div class="line"><a name="l13764"></a><span class="lineno">13764</span>&#160;        {</div>
-<div class="line"><a name="l13765"></a><span class="lineno">13765</span>&#160;            pBlockVectorCtx-&gt;GetBlockVector()-&gt;DefragmentationEnd(pBlockVectorCtx, m_pStats);</div>
-<div class="line"><a name="l13766"></a><span class="lineno">13766</span>&#160;            vma_delete(m_hAllocator, pBlockVectorCtx);</div>
-<div class="line"><a name="l13767"></a><span class="lineno">13767</span>&#160;        }</div>
-<div class="line"><a name="l13768"></a><span class="lineno">13768</span>&#160;    }</div>
-<div class="line"><a name="l13769"></a><span class="lineno">13769</span>&#160;}</div>
-<div class="line"><a name="l13770"></a><span class="lineno">13770</span>&#160; </div>
-<div class="line"><a name="l13771"></a><span class="lineno">13771</span>&#160;<span class="keywordtype">void</span> VmaDefragmentationContext_T::AddPools(uint32_t poolCount, <a class="code" href="struct_vma_pool.html">VmaPool</a>* pPools)</div>
-<div class="line"><a name="l13772"></a><span class="lineno">13772</span>&#160;{</div>
-<div class="line"><a name="l13773"></a><span class="lineno">13773</span>&#160;    <span class="keywordflow">for</span>(uint32_t poolIndex = 0; poolIndex &lt; poolCount; ++poolIndex)</div>
-<div class="line"><a name="l13774"></a><span class="lineno">13774</span>&#160;    {</div>
-<div class="line"><a name="l13775"></a><span class="lineno">13775</span>&#160;        <a class="code" href="struct_vma_pool.html">VmaPool</a> pool = pPools[poolIndex];</div>
-<div class="line"><a name="l13776"></a><span class="lineno">13776</span>&#160;        VMA_ASSERT(pool);</div>
-<div class="line"><a name="l13777"></a><span class="lineno">13777</span>&#160;        <span class="comment">// Pools with algorithm other than default are not defragmented.</span></div>
-<div class="line"><a name="l13778"></a><span class="lineno">13778</span>&#160;        <span class="keywordflow">if</span>(pool-&gt;m_BlockVector.GetAlgorithm() == 0)</div>
-<div class="line"><a name="l13779"></a><span class="lineno">13779</span>&#160;        {</div>
-<div class="line"><a name="l13780"></a><span class="lineno">13780</span>&#160;            VmaBlockVectorDefragmentationContext* pBlockVectorDefragCtx = VMA_NULL;</div>
-<div class="line"><a name="l13781"></a><span class="lineno">13781</span>&#160;            </div>
-<div class="line"><a name="l13782"></a><span class="lineno">13782</span>&#160;            <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = m_CustomPoolContexts.size(); i--; )</div>
-<div class="line"><a name="l13783"></a><span class="lineno">13783</span>&#160;            {</div>
-<div class="line"><a name="l13784"></a><span class="lineno">13784</span>&#160;                <span class="keywordflow">if</span>(m_CustomPoolContexts[i]-&gt;GetCustomPool() == pool)</div>
-<div class="line"><a name="l13785"></a><span class="lineno">13785</span>&#160;                {</div>
-<div class="line"><a name="l13786"></a><span class="lineno">13786</span>&#160;                    pBlockVectorDefragCtx = m_CustomPoolContexts[i];</div>
-<div class="line"><a name="l13787"></a><span class="lineno">13787</span>&#160;                    <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l13788"></a><span class="lineno">13788</span>&#160;                }</div>
-<div class="line"><a name="l13789"></a><span class="lineno">13789</span>&#160;            }</div>
-<div class="line"><a name="l13790"></a><span class="lineno">13790</span>&#160;            </div>
-<div class="line"><a name="l13791"></a><span class="lineno">13791</span>&#160;            <span class="keywordflow">if</span>(!pBlockVectorDefragCtx)</div>
-<div class="line"><a name="l13792"></a><span class="lineno">13792</span>&#160;            {</div>
-<div class="line"><a name="l13793"></a><span class="lineno">13793</span>&#160;                pBlockVectorDefragCtx = vma_new(m_hAllocator, VmaBlockVectorDefragmentationContext)(</div>
-<div class="line"><a name="l13794"></a><span class="lineno">13794</span>&#160;                    m_hAllocator,</div>
-<div class="line"><a name="l13795"></a><span class="lineno">13795</span>&#160;                    pool,</div>
-<div class="line"><a name="l13796"></a><span class="lineno">13796</span>&#160;                    &amp;pool-&gt;m_BlockVector,</div>
-<div class="line"><a name="l13797"></a><span class="lineno">13797</span>&#160;                    m_CurrFrameIndex);</div>
-<div class="line"><a name="l13798"></a><span class="lineno">13798</span>&#160;                m_CustomPoolContexts.push_back(pBlockVectorDefragCtx);</div>
-<div class="line"><a name="l13799"></a><span class="lineno">13799</span>&#160;            }</div>
-<div class="line"><a name="l13800"></a><span class="lineno">13800</span>&#160; </div>
-<div class="line"><a name="l13801"></a><span class="lineno">13801</span>&#160;            pBlockVectorDefragCtx-&gt;AddAll();</div>
-<div class="line"><a name="l13802"></a><span class="lineno">13802</span>&#160;        }</div>
-<div class="line"><a name="l13803"></a><span class="lineno">13803</span>&#160;    }</div>
-<div class="line"><a name="l13804"></a><span class="lineno">13804</span>&#160;}</div>
-<div class="line"><a name="l13805"></a><span class="lineno">13805</span>&#160; </div>
-<div class="line"><a name="l13806"></a><span class="lineno">13806</span>&#160;<span class="keywordtype">void</span> VmaDefragmentationContext_T::AddAllocations(</div>
-<div class="line"><a name="l13807"></a><span class="lineno">13807</span>&#160;    uint32_t allocationCount,</div>
-<div class="line"><a name="l13808"></a><span class="lineno">13808</span>&#160;    <a class="code" href="struct_vma_allocation.html">VmaAllocation</a>* pAllocations,</div>
-<div class="line"><a name="l13809"></a><span class="lineno">13809</span>&#160;    VkBool32* pAllocationsChanged)</div>
-<div class="line"><a name="l13810"></a><span class="lineno">13810</span>&#160;{</div>
-<div class="line"><a name="l13811"></a><span class="lineno">13811</span>&#160;    <span class="comment">// Dispatch pAllocations among defragmentators. Create them when necessary.</span></div>
-<div class="line"><a name="l13812"></a><span class="lineno">13812</span>&#160;    <span class="keywordflow">for</span>(uint32_t allocIndex = 0; allocIndex &lt; allocationCount; ++allocIndex)</div>
-<div class="line"><a name="l13813"></a><span class="lineno">13813</span>&#160;    {</div>
-<div class="line"><a name="l13814"></a><span class="lineno">13814</span>&#160;        <span class="keyword">const</span> <a class="code" href="struct_vma_allocation.html">VmaAllocation</a> hAlloc = pAllocations[allocIndex];</div>
-<div class="line"><a name="l13815"></a><span class="lineno">13815</span>&#160;        VMA_ASSERT(hAlloc);</div>
-<div class="line"><a name="l13816"></a><span class="lineno">13816</span>&#160;        <span class="comment">// DedicatedAlloc cannot be defragmented.</span></div>
-<div class="line"><a name="l13817"></a><span class="lineno">13817</span>&#160;        <span class="keywordflow">if</span>((hAlloc-&gt;GetType() == VmaAllocation_T::ALLOCATION_TYPE_BLOCK) &amp;&amp;</div>
-<div class="line"><a name="l13818"></a><span class="lineno">13818</span>&#160;            <span class="comment">// Lost allocation cannot be defragmented.</span></div>
-<div class="line"><a name="l13819"></a><span class="lineno">13819</span>&#160;            (hAlloc-&gt;GetLastUseFrameIndex() != VMA_FRAME_INDEX_LOST))</div>
-<div class="line"><a name="l13820"></a><span class="lineno">13820</span>&#160;        {</div>
-<div class="line"><a name="l13821"></a><span class="lineno">13821</span>&#160;            VmaBlockVectorDefragmentationContext* pBlockVectorDefragCtx = VMA_NULL;</div>
-<div class="line"><a name="l13822"></a><span class="lineno">13822</span>&#160; </div>
-<div class="line"><a name="l13823"></a><span class="lineno">13823</span>&#160;            <span class="keyword">const</span> <a class="code" href="struct_vma_pool.html">VmaPool</a> hAllocPool = hAlloc-&gt;GetBlock()-&gt;GetParentPool();</div>
-<div class="line"><a name="l13824"></a><span class="lineno">13824</span>&#160;            <span class="comment">// This allocation belongs to custom pool.</span></div>
-<div class="line"><a name="l13825"></a><span class="lineno">13825</span>&#160;            <span class="keywordflow">if</span>(hAllocPool != VK_NULL_HANDLE)</div>
-<div class="line"><a name="l13826"></a><span class="lineno">13826</span>&#160;            {</div>
-<div class="line"><a name="l13827"></a><span class="lineno">13827</span>&#160;                <span class="comment">// Pools with algorithm other than default are not defragmented.</span></div>
-<div class="line"><a name="l13828"></a><span class="lineno">13828</span>&#160;                <span class="keywordflow">if</span>(hAllocPool-&gt;m_BlockVector.GetAlgorithm() == 0)</div>
-<div class="line"><a name="l13829"></a><span class="lineno">13829</span>&#160;                {</div>
-<div class="line"><a name="l13830"></a><span class="lineno">13830</span>&#160;                    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = m_CustomPoolContexts.size(); i--; )</div>
-<div class="line"><a name="l13831"></a><span class="lineno">13831</span>&#160;                    {</div>
-<div class="line"><a name="l13832"></a><span class="lineno">13832</span>&#160;                        <span class="keywordflow">if</span>(m_CustomPoolContexts[i]-&gt;GetCustomPool() == hAllocPool)</div>
-<div class="line"><a name="l13833"></a><span class="lineno">13833</span>&#160;                        {</div>
-<div class="line"><a name="l13834"></a><span class="lineno">13834</span>&#160;                            pBlockVectorDefragCtx = m_CustomPoolContexts[i];</div>
-<div class="line"><a name="l13835"></a><span class="lineno">13835</span>&#160;                            <span class="keywordflow">break</span>;</div>
-<div class="line"><a name="l13836"></a><span class="lineno">13836</span>&#160;                        }</div>
-<div class="line"><a name="l13837"></a><span class="lineno">13837</span>&#160;                    }</div>
-<div class="line"><a name="l13838"></a><span class="lineno">13838</span>&#160;                    <span class="keywordflow">if</span>(!pBlockVectorDefragCtx)</div>
-<div class="line"><a name="l13839"></a><span class="lineno">13839</span>&#160;                    {</div>
-<div class="line"><a name="l13840"></a><span class="lineno">13840</span>&#160;                        pBlockVectorDefragCtx = vma_new(m_hAllocator, VmaBlockVectorDefragmentationContext)(</div>
-<div class="line"><a name="l13841"></a><span class="lineno">13841</span>&#160;                            m_hAllocator,</div>
-<div class="line"><a name="l13842"></a><span class="lineno">13842</span>&#160;                            hAllocPool,</div>
-<div class="line"><a name="l13843"></a><span class="lineno">13843</span>&#160;                            &amp;hAllocPool-&gt;m_BlockVector,</div>
-<div class="line"><a name="l13844"></a><span class="lineno">13844</span>&#160;                            m_CurrFrameIndex);</div>
-<div class="line"><a name="l13845"></a><span class="lineno">13845</span>&#160;                        m_CustomPoolContexts.push_back(pBlockVectorDefragCtx);</div>
-<div class="line"><a name="l13846"></a><span class="lineno">13846</span>&#160;                    }</div>
-<div class="line"><a name="l13847"></a><span class="lineno">13847</span>&#160;                }</div>
-<div class="line"><a name="l13848"></a><span class="lineno">13848</span>&#160;            }</div>
-<div class="line"><a name="l13849"></a><span class="lineno">13849</span>&#160;            <span class="comment">// This allocation belongs to default pool.</span></div>
-<div class="line"><a name="l13850"></a><span class="lineno">13850</span>&#160;            <span class="keywordflow">else</span></div>
-<div class="line"><a name="l13851"></a><span class="lineno">13851</span>&#160;            {</div>
-<div class="line"><a name="l13852"></a><span class="lineno">13852</span>&#160;                <span class="keyword">const</span> uint32_t memTypeIndex = hAlloc-&gt;GetMemoryTypeIndex();</div>
-<div class="line"><a name="l13853"></a><span class="lineno">13853</span>&#160;                pBlockVectorDefragCtx = m_DefaultPoolContexts[memTypeIndex];</div>
-<div class="line"><a name="l13854"></a><span class="lineno">13854</span>&#160;                <span class="keywordflow">if</span>(!pBlockVectorDefragCtx)</div>
-<div class="line"><a name="l13855"></a><span class="lineno">13855</span>&#160;                {</div>
-<div class="line"><a name="l13856"></a><span class="lineno">13856</span>&#160;                    pBlockVectorDefragCtx = vma_new(m_hAllocator, VmaBlockVectorDefragmentationContext)(</div>
-<div class="line"><a name="l13857"></a><span class="lineno">13857</span>&#160;                        m_hAllocator,</div>
-<div class="line"><a name="l13858"></a><span class="lineno">13858</span>&#160;                        VMA_NULL, <span class="comment">// hCustomPool</span></div>
-<div class="line"><a name="l13859"></a><span class="lineno">13859</span>&#160;                        m_hAllocator-&gt;m_pBlockVectors[memTypeIndex],</div>
-<div class="line"><a name="l13860"></a><span class="lineno">13860</span>&#160;                        m_CurrFrameIndex);</div>
-<div class="line"><a name="l13861"></a><span class="lineno">13861</span>&#160;                    m_DefaultPoolContexts[memTypeIndex] = pBlockVectorDefragCtx;</div>
-<div class="line"><a name="l13862"></a><span class="lineno">13862</span>&#160;                }</div>
-<div class="line"><a name="l13863"></a><span class="lineno">13863</span>&#160;            }</div>
-<div class="line"><a name="l13864"></a><span class="lineno">13864</span>&#160; </div>
-<div class="line"><a name="l13865"></a><span class="lineno">13865</span>&#160;            <span class="keywordflow">if</span>(pBlockVectorDefragCtx)</div>
-<div class="line"><a name="l13866"></a><span class="lineno">13866</span>&#160;            {</div>
-<div class="line"><a name="l13867"></a><span class="lineno">13867</span>&#160;                VkBool32* <span class="keyword">const</span> pChanged = (pAllocationsChanged != VMA_NULL) ?</div>
-<div class="line"><a name="l13868"></a><span class="lineno">13868</span>&#160;                    &amp;pAllocationsChanged[allocIndex] : VMA_NULL;</div>
-<div class="line"><a name="l13869"></a><span class="lineno">13869</span>&#160;                pBlockVectorDefragCtx-&gt;AddAllocation(hAlloc, pChanged);</div>
-<div class="line"><a name="l13870"></a><span class="lineno">13870</span>&#160;            }</div>
-<div class="line"><a name="l13871"></a><span class="lineno">13871</span>&#160;        }</div>
-<div class="line"><a name="l13872"></a><span class="lineno">13872</span>&#160;    }</div>
-<div class="line"><a name="l13873"></a><span class="lineno">13873</span>&#160;}</div>
-<div class="line"><a name="l13874"></a><span class="lineno">13874</span>&#160; </div>
-<div class="line"><a name="l13875"></a><span class="lineno">13875</span>&#160;VkResult VmaDefragmentationContext_T::Defragment(</div>
-<div class="line"><a name="l13876"></a><span class="lineno">13876</span>&#160;    VkDeviceSize maxCpuBytesToMove, uint32_t maxCpuAllocationsToMove,</div>
-<div class="line"><a name="l13877"></a><span class="lineno">13877</span>&#160;    VkDeviceSize maxGpuBytesToMove, uint32_t maxGpuAllocationsToMove,</div>
-<div class="line"><a name="l13878"></a><span class="lineno">13878</span>&#160;    VkCommandBuffer commandBuffer, <a class="code" href="struct_vma_defragmentation_stats.html">VmaDefragmentationStats</a>* pStats)</div>
-<div class="line"><a name="l13879"></a><span class="lineno">13879</span>&#160;{</div>
-<div class="line"><a name="l13880"></a><span class="lineno">13880</span>&#160;    <span class="keywordflow">if</span>(pStats)</div>
-<div class="line"><a name="l13881"></a><span class="lineno">13881</span>&#160;    {</div>
-<div class="line"><a name="l13882"></a><span class="lineno">13882</span>&#160;        memset(pStats, 0, <span class="keyword">sizeof</span>(<a class="code" href="struct_vma_defragmentation_stats.html">VmaDefragmentationStats</a>));</div>
-<div class="line"><a name="l13883"></a><span class="lineno">13883</span>&#160;    }</div>
-<div class="line"><a name="l13884"></a><span class="lineno">13884</span>&#160; </div>
-<div class="line"><a name="l13885"></a><span class="lineno">13885</span>&#160;    <span class="keywordflow">if</span>(commandBuffer == VK_NULL_HANDLE)</div>
-<div class="line"><a name="l13886"></a><span class="lineno">13886</span>&#160;    {</div>
-<div class="line"><a name="l13887"></a><span class="lineno">13887</span>&#160;        maxGpuBytesToMove = 0;</div>
-<div class="line"><a name="l13888"></a><span class="lineno">13888</span>&#160;        maxGpuAllocationsToMove = 0;</div>
+<div class="line"><a name="l13762"></a><span class="lineno">13762</span>&#160;        VmaBlockVectorDefragmentationContext* pBlockVectorCtx = m_CustomPoolContexts[i];</div>
+<div class="line"><a name="l13763"></a><span class="lineno">13763</span>&#160;        pBlockVectorCtx-&gt;GetBlockVector()-&gt;DefragmentationEnd(pBlockVectorCtx, m_pStats);</div>
+<div class="line"><a name="l13764"></a><span class="lineno">13764</span>&#160;        vma_delete(m_hAllocator, pBlockVectorCtx);</div>
+<div class="line"><a name="l13765"></a><span class="lineno">13765</span>&#160;    }</div>
+<div class="line"><a name="l13766"></a><span class="lineno">13766</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = m_hAllocator-&gt;m_MemProps.memoryTypeCount; i--; )</div>
+<div class="line"><a name="l13767"></a><span class="lineno">13767</span>&#160;    {</div>
+<div class="line"><a name="l13768"></a><span class="lineno">13768</span>&#160;        VmaBlockVectorDefragmentationContext* pBlockVectorCtx = m_DefaultPoolContexts[i];</div>
+<div class="line"><a name="l13769"></a><span class="lineno">13769</span>&#160;        <span class="keywordflow">if</span>(pBlockVectorCtx)</div>
+<div class="line"><a name="l13770"></a><span class="lineno">13770</span>&#160;        {</div>
+<div class="line"><a name="l13771"></a><span class="lineno">13771</span>&#160;            pBlockVectorCtx-&gt;GetBlockVector()-&gt;DefragmentationEnd(pBlockVectorCtx, m_pStats);</div>
+<div class="line"><a name="l13772"></a><span class="lineno">13772</span>&#160;            vma_delete(m_hAllocator, pBlockVectorCtx);</div>
+<div class="line"><a name="l13773"></a><span class="lineno">13773</span>&#160;        }</div>
+<div class="line"><a name="l13774"></a><span class="lineno">13774</span>&#160;    }</div>
+<div class="line"><a name="l13775"></a><span class="lineno">13775</span>&#160;}</div>
+<div class="line"><a name="l13776"></a><span class="lineno">13776</span>&#160; </div>
+<div class="line"><a name="l13777"></a><span class="lineno">13777</span>&#160;<span class="keywordtype">void</span> VmaDefragmentationContext_T::AddPools(uint32_t poolCount, <a class="code" href="struct_vma_pool.html">VmaPool</a>* pPools)</div>
+<div class="line"><a name="l13778"></a><span class="lineno">13778</span>&#160;{</div>
+<div class="line"><a name="l13779"></a><span class="lineno">13779</span>&#160;    <span class="keywordflow">for</span>(uint32_t poolIndex = 0; poolIndex &lt; poolCount; ++poolIndex)</div>
+<div class="line"><a name="l13780"></a><span class="lineno">13780</span>&#160;    {</div>
+<div class="line"><a name="l13781"></a><span class="lineno">13781</span>&#160;        <a class="code" href="struct_vma_pool.html">VmaPool</a> pool = pPools[poolIndex];</div>
+<div class="line"><a name="l13782"></a><span class="lineno">13782</span>&#160;        VMA_ASSERT(pool);</div>
+<div class="line"><a name="l13783"></a><span class="lineno">13783</span>&#160;        <span class="comment">// Pools with algorithm other than default are not defragmented.</span></div>
+<div class="line"><a name="l13784"></a><span class="lineno">13784</span>&#160;        <span class="keywordflow">if</span>(pool-&gt;m_BlockVector.GetAlgorithm() == 0)</div>
+<div class="line"><a name="l13785"></a><span class="lineno">13785</span>&#160;        {</div>
+<div class="line"><a name="l13786"></a><span class="lineno">13786</span>&#160;            VmaBlockVectorDefragmentationContext* pBlockVectorDefragCtx = VMA_NULL;</div>
+<div class="line"><a name="l13787"></a><span class="lineno">13787</span>&#160;            </div>
+<div class="line"><a name="l13788"></a><span class="lineno">13788</span>&#160;            <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = m_CustomPoolContexts.size(); i--; )</div>
+<div class="line"><a name="l13789"></a><span class="lineno">13789</span>&#160;            {</div>
+<div class="line"><a name="l13790"></a><span class="lineno">13790</span>&#160;                <span class="keywordflow">if</span>(m_CustomPoolContexts[i]-&gt;GetCustomPool() == pool)</div>
+<div class="line"><a name="l13791"></a><span class="lineno">13791</span>&#160;                {</div>
+<div class="line"><a name="l13792"></a><span class="lineno">13792</span>&#160;                    pBlockVectorDefragCtx = m_CustomPoolContexts[i];</div>
+<div class="line"><a name="l13793"></a><span class="lineno">13793</span>&#160;                    <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l13794"></a><span class="lineno">13794</span>&#160;                }</div>
+<div class="line"><a name="l13795"></a><span class="lineno">13795</span>&#160;            }</div>
+<div class="line"><a name="l13796"></a><span class="lineno">13796</span>&#160;            </div>
+<div class="line"><a name="l13797"></a><span class="lineno">13797</span>&#160;            <span class="keywordflow">if</span>(!pBlockVectorDefragCtx)</div>
+<div class="line"><a name="l13798"></a><span class="lineno">13798</span>&#160;            {</div>
+<div class="line"><a name="l13799"></a><span class="lineno">13799</span>&#160;                pBlockVectorDefragCtx = vma_new(m_hAllocator, VmaBlockVectorDefragmentationContext)(</div>
+<div class="line"><a name="l13800"></a><span class="lineno">13800</span>&#160;                    m_hAllocator,</div>
+<div class="line"><a name="l13801"></a><span class="lineno">13801</span>&#160;                    pool,</div>
+<div class="line"><a name="l13802"></a><span class="lineno">13802</span>&#160;                    &amp;pool-&gt;m_BlockVector,</div>
+<div class="line"><a name="l13803"></a><span class="lineno">13803</span>&#160;                    m_CurrFrameIndex);</div>
+<div class="line"><a name="l13804"></a><span class="lineno">13804</span>&#160;                m_CustomPoolContexts.push_back(pBlockVectorDefragCtx);</div>
+<div class="line"><a name="l13805"></a><span class="lineno">13805</span>&#160;            }</div>
+<div class="line"><a name="l13806"></a><span class="lineno">13806</span>&#160; </div>
+<div class="line"><a name="l13807"></a><span class="lineno">13807</span>&#160;            pBlockVectorDefragCtx-&gt;AddAll();</div>
+<div class="line"><a name="l13808"></a><span class="lineno">13808</span>&#160;        }</div>
+<div class="line"><a name="l13809"></a><span class="lineno">13809</span>&#160;    }</div>
+<div class="line"><a name="l13810"></a><span class="lineno">13810</span>&#160;}</div>
+<div class="line"><a name="l13811"></a><span class="lineno">13811</span>&#160; </div>
+<div class="line"><a name="l13812"></a><span class="lineno">13812</span>&#160;<span class="keywordtype">void</span> VmaDefragmentationContext_T::AddAllocations(</div>
+<div class="line"><a name="l13813"></a><span class="lineno">13813</span>&#160;    uint32_t allocationCount,</div>
+<div class="line"><a name="l13814"></a><span class="lineno">13814</span>&#160;    <a class="code" href="struct_vma_allocation.html">VmaAllocation</a>* pAllocations,</div>
+<div class="line"><a name="l13815"></a><span class="lineno">13815</span>&#160;    VkBool32* pAllocationsChanged)</div>
+<div class="line"><a name="l13816"></a><span class="lineno">13816</span>&#160;{</div>
+<div class="line"><a name="l13817"></a><span class="lineno">13817</span>&#160;    <span class="comment">// Dispatch pAllocations among defragmentators. Create them when necessary.</span></div>
+<div class="line"><a name="l13818"></a><span class="lineno">13818</span>&#160;    <span class="keywordflow">for</span>(uint32_t allocIndex = 0; allocIndex &lt; allocationCount; ++allocIndex)</div>
+<div class="line"><a name="l13819"></a><span class="lineno">13819</span>&#160;    {</div>
+<div class="line"><a name="l13820"></a><span class="lineno">13820</span>&#160;        <span class="keyword">const</span> <a class="code" href="struct_vma_allocation.html">VmaAllocation</a> hAlloc = pAllocations[allocIndex];</div>
+<div class="line"><a name="l13821"></a><span class="lineno">13821</span>&#160;        VMA_ASSERT(hAlloc);</div>
+<div class="line"><a name="l13822"></a><span class="lineno">13822</span>&#160;        <span class="comment">// DedicatedAlloc cannot be defragmented.</span></div>
+<div class="line"><a name="l13823"></a><span class="lineno">13823</span>&#160;        <span class="keywordflow">if</span>((hAlloc-&gt;GetType() == VmaAllocation_T::ALLOCATION_TYPE_BLOCK) &amp;&amp;</div>
+<div class="line"><a name="l13824"></a><span class="lineno">13824</span>&#160;            <span class="comment">// Lost allocation cannot be defragmented.</span></div>
+<div class="line"><a name="l13825"></a><span class="lineno">13825</span>&#160;            (hAlloc-&gt;GetLastUseFrameIndex() != VMA_FRAME_INDEX_LOST))</div>
+<div class="line"><a name="l13826"></a><span class="lineno">13826</span>&#160;        {</div>
+<div class="line"><a name="l13827"></a><span class="lineno">13827</span>&#160;            VmaBlockVectorDefragmentationContext* pBlockVectorDefragCtx = VMA_NULL;</div>
+<div class="line"><a name="l13828"></a><span class="lineno">13828</span>&#160; </div>
+<div class="line"><a name="l13829"></a><span class="lineno">13829</span>&#160;            <span class="keyword">const</span> <a class="code" href="struct_vma_pool.html">VmaPool</a> hAllocPool = hAlloc-&gt;GetBlock()-&gt;GetParentPool();</div>
+<div class="line"><a name="l13830"></a><span class="lineno">13830</span>&#160;            <span class="comment">// This allocation belongs to custom pool.</span></div>
+<div class="line"><a name="l13831"></a><span class="lineno">13831</span>&#160;            <span class="keywordflow">if</span>(hAllocPool != VK_NULL_HANDLE)</div>
+<div class="line"><a name="l13832"></a><span class="lineno">13832</span>&#160;            {</div>
+<div class="line"><a name="l13833"></a><span class="lineno">13833</span>&#160;                <span class="comment">// Pools with algorithm other than default are not defragmented.</span></div>
+<div class="line"><a name="l13834"></a><span class="lineno">13834</span>&#160;                <span class="keywordflow">if</span>(hAllocPool-&gt;m_BlockVector.GetAlgorithm() == 0)</div>
+<div class="line"><a name="l13835"></a><span class="lineno">13835</span>&#160;                {</div>
+<div class="line"><a name="l13836"></a><span class="lineno">13836</span>&#160;                    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = m_CustomPoolContexts.size(); i--; )</div>
+<div class="line"><a name="l13837"></a><span class="lineno">13837</span>&#160;                    {</div>
+<div class="line"><a name="l13838"></a><span class="lineno">13838</span>&#160;                        <span class="keywordflow">if</span>(m_CustomPoolContexts[i]-&gt;GetCustomPool() == hAllocPool)</div>
+<div class="line"><a name="l13839"></a><span class="lineno">13839</span>&#160;                        {</div>
+<div class="line"><a name="l13840"></a><span class="lineno">13840</span>&#160;                            pBlockVectorDefragCtx = m_CustomPoolContexts[i];</div>
+<div class="line"><a name="l13841"></a><span class="lineno">13841</span>&#160;                            <span class="keywordflow">break</span>;</div>
+<div class="line"><a name="l13842"></a><span class="lineno">13842</span>&#160;                        }</div>
+<div class="line"><a name="l13843"></a><span class="lineno">13843</span>&#160;                    }</div>
+<div class="line"><a name="l13844"></a><span class="lineno">13844</span>&#160;                    <span class="keywordflow">if</span>(!pBlockVectorDefragCtx)</div>
+<div class="line"><a name="l13845"></a><span class="lineno">13845</span>&#160;                    {</div>
+<div class="line"><a name="l13846"></a><span class="lineno">13846</span>&#160;                        pBlockVectorDefragCtx = vma_new(m_hAllocator, VmaBlockVectorDefragmentationContext)(</div>
+<div class="line"><a name="l13847"></a><span class="lineno">13847</span>&#160;                            m_hAllocator,</div>
+<div class="line"><a name="l13848"></a><span class="lineno">13848</span>&#160;                            hAllocPool,</div>
+<div class="line"><a name="l13849"></a><span class="lineno">13849</span>&#160;                            &amp;hAllocPool-&gt;m_BlockVector,</div>
+<div class="line"><a name="l13850"></a><span class="lineno">13850</span>&#160;                            m_CurrFrameIndex);</div>
+<div class="line"><a name="l13851"></a><span class="lineno">13851</span>&#160;                        m_CustomPoolContexts.push_back(pBlockVectorDefragCtx);</div>
+<div class="line"><a name="l13852"></a><span class="lineno">13852</span>&#160;                    }</div>
+<div class="line"><a name="l13853"></a><span class="lineno">13853</span>&#160;                }</div>
+<div class="line"><a name="l13854"></a><span class="lineno">13854</span>&#160;            }</div>
+<div class="line"><a name="l13855"></a><span class="lineno">13855</span>&#160;            <span class="comment">// This allocation belongs to default pool.</span></div>
+<div class="line"><a name="l13856"></a><span class="lineno">13856</span>&#160;            <span class="keywordflow">else</span></div>
+<div class="line"><a name="l13857"></a><span class="lineno">13857</span>&#160;            {</div>
+<div class="line"><a name="l13858"></a><span class="lineno">13858</span>&#160;                <span class="keyword">const</span> uint32_t memTypeIndex = hAlloc-&gt;GetMemoryTypeIndex();</div>
+<div class="line"><a name="l13859"></a><span class="lineno">13859</span>&#160;                pBlockVectorDefragCtx = m_DefaultPoolContexts[memTypeIndex];</div>
+<div class="line"><a name="l13860"></a><span class="lineno">13860</span>&#160;                <span class="keywordflow">if</span>(!pBlockVectorDefragCtx)</div>
+<div class="line"><a name="l13861"></a><span class="lineno">13861</span>&#160;                {</div>
+<div class="line"><a name="l13862"></a><span class="lineno">13862</span>&#160;                    pBlockVectorDefragCtx = vma_new(m_hAllocator, VmaBlockVectorDefragmentationContext)(</div>
+<div class="line"><a name="l13863"></a><span class="lineno">13863</span>&#160;                        m_hAllocator,</div>
+<div class="line"><a name="l13864"></a><span class="lineno">13864</span>&#160;                        VMA_NULL, <span class="comment">// hCustomPool</span></div>
+<div class="line"><a name="l13865"></a><span class="lineno">13865</span>&#160;                        m_hAllocator-&gt;m_pBlockVectors[memTypeIndex],</div>
+<div class="line"><a name="l13866"></a><span class="lineno">13866</span>&#160;                        m_CurrFrameIndex);</div>
+<div class="line"><a name="l13867"></a><span class="lineno">13867</span>&#160;                    m_DefaultPoolContexts[memTypeIndex] = pBlockVectorDefragCtx;</div>
+<div class="line"><a name="l13868"></a><span class="lineno">13868</span>&#160;                }</div>
+<div class="line"><a name="l13869"></a><span class="lineno">13869</span>&#160;            }</div>
+<div class="line"><a name="l13870"></a><span class="lineno">13870</span>&#160; </div>
+<div class="line"><a name="l13871"></a><span class="lineno">13871</span>&#160;            <span class="keywordflow">if</span>(pBlockVectorDefragCtx)</div>
+<div class="line"><a name="l13872"></a><span class="lineno">13872</span>&#160;            {</div>
+<div class="line"><a name="l13873"></a><span class="lineno">13873</span>&#160;                VkBool32* <span class="keyword">const</span> pChanged = (pAllocationsChanged != VMA_NULL) ?</div>
+<div class="line"><a name="l13874"></a><span class="lineno">13874</span>&#160;                    &amp;pAllocationsChanged[allocIndex] : VMA_NULL;</div>
+<div class="line"><a name="l13875"></a><span class="lineno">13875</span>&#160;                pBlockVectorDefragCtx-&gt;AddAllocation(hAlloc, pChanged);</div>
+<div class="line"><a name="l13876"></a><span class="lineno">13876</span>&#160;            }</div>
+<div class="line"><a name="l13877"></a><span class="lineno">13877</span>&#160;        }</div>
+<div class="line"><a name="l13878"></a><span class="lineno">13878</span>&#160;    }</div>
+<div class="line"><a name="l13879"></a><span class="lineno">13879</span>&#160;}</div>
+<div class="line"><a name="l13880"></a><span class="lineno">13880</span>&#160; </div>
+<div class="line"><a name="l13881"></a><span class="lineno">13881</span>&#160;VkResult VmaDefragmentationContext_T::Defragment(</div>
+<div class="line"><a name="l13882"></a><span class="lineno">13882</span>&#160;    VkDeviceSize maxCpuBytesToMove, uint32_t maxCpuAllocationsToMove,</div>
+<div class="line"><a name="l13883"></a><span class="lineno">13883</span>&#160;    VkDeviceSize maxGpuBytesToMove, uint32_t maxGpuAllocationsToMove,</div>
+<div class="line"><a name="l13884"></a><span class="lineno">13884</span>&#160;    VkCommandBuffer commandBuffer, <a class="code" href="struct_vma_defragmentation_stats.html">VmaDefragmentationStats</a>* pStats)</div>
+<div class="line"><a name="l13885"></a><span class="lineno">13885</span>&#160;{</div>
+<div class="line"><a name="l13886"></a><span class="lineno">13886</span>&#160;    <span class="keywordflow">if</span>(pStats)</div>
+<div class="line"><a name="l13887"></a><span class="lineno">13887</span>&#160;    {</div>
+<div class="line"><a name="l13888"></a><span class="lineno">13888</span>&#160;        memset(pStats, 0, <span class="keyword">sizeof</span>(<a class="code" href="struct_vma_defragmentation_stats.html">VmaDefragmentationStats</a>));</div>
 <div class="line"><a name="l13889"></a><span class="lineno">13889</span>&#160;    }</div>
 <div class="line"><a name="l13890"></a><span class="lineno">13890</span>&#160; </div>
-<div class="line"><a name="l13891"></a><span class="lineno">13891</span>&#160;    VkResult res = VK_SUCCESS;</div>
-<div class="line"><a name="l13892"></a><span class="lineno">13892</span>&#160; </div>
-<div class="line"><a name="l13893"></a><span class="lineno">13893</span>&#160;    <span class="comment">// Process default pools.</span></div>
-<div class="line"><a name="l13894"></a><span class="lineno">13894</span>&#160;    <span class="keywordflow">for</span>(uint32_t memTypeIndex = 0;</div>
-<div class="line"><a name="l13895"></a><span class="lineno">13895</span>&#160;        memTypeIndex &lt; m_hAllocator-&gt;GetMemoryTypeCount() &amp;&amp; res &gt;= VK_SUCCESS;</div>
-<div class="line"><a name="l13896"></a><span class="lineno">13896</span>&#160;        ++memTypeIndex)</div>
-<div class="line"><a name="l13897"></a><span class="lineno">13897</span>&#160;    {</div>
-<div class="line"><a name="l13898"></a><span class="lineno">13898</span>&#160;        VmaBlockVectorDefragmentationContext* pBlockVectorCtx = m_DefaultPoolContexts[memTypeIndex];</div>
-<div class="line"><a name="l13899"></a><span class="lineno">13899</span>&#160;        <span class="keywordflow">if</span>(pBlockVectorCtx)</div>
-<div class="line"><a name="l13900"></a><span class="lineno">13900</span>&#160;        {</div>
-<div class="line"><a name="l13901"></a><span class="lineno">13901</span>&#160;            VMA_ASSERT(pBlockVectorCtx-&gt;GetBlockVector());</div>
-<div class="line"><a name="l13902"></a><span class="lineno">13902</span>&#160;            pBlockVectorCtx-&gt;GetBlockVector()-&gt;Defragment(</div>
-<div class="line"><a name="l13903"></a><span class="lineno">13903</span>&#160;                pBlockVectorCtx,</div>
-<div class="line"><a name="l13904"></a><span class="lineno">13904</span>&#160;                pStats,</div>
-<div class="line"><a name="l13905"></a><span class="lineno">13905</span>&#160;                maxCpuBytesToMove, maxCpuAllocationsToMove,</div>
-<div class="line"><a name="l13906"></a><span class="lineno">13906</span>&#160;                maxGpuBytesToMove, maxGpuAllocationsToMove,</div>
-<div class="line"><a name="l13907"></a><span class="lineno">13907</span>&#160;                commandBuffer);</div>
-<div class="line"><a name="l13908"></a><span class="lineno">13908</span>&#160;            <span class="keywordflow">if</span>(pBlockVectorCtx-&gt;res != VK_SUCCESS)</div>
-<div class="line"><a name="l13909"></a><span class="lineno">13909</span>&#160;            {</div>
-<div class="line"><a name="l13910"></a><span class="lineno">13910</span>&#160;                res = pBlockVectorCtx-&gt;res;</div>
-<div class="line"><a name="l13911"></a><span class="lineno">13911</span>&#160;            }</div>
-<div class="line"><a name="l13912"></a><span class="lineno">13912</span>&#160;        }</div>
-<div class="line"><a name="l13913"></a><span class="lineno">13913</span>&#160;    }</div>
-<div class="line"><a name="l13914"></a><span class="lineno">13914</span>&#160; </div>
-<div class="line"><a name="l13915"></a><span class="lineno">13915</span>&#160;    <span class="comment">// Process custom pools.</span></div>
-<div class="line"><a name="l13916"></a><span class="lineno">13916</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> customCtxIndex = 0, customCtxCount = m_CustomPoolContexts.size();</div>
-<div class="line"><a name="l13917"></a><span class="lineno">13917</span>&#160;        customCtxIndex &lt; customCtxCount &amp;&amp; res &gt;= VK_SUCCESS;</div>
-<div class="line"><a name="l13918"></a><span class="lineno">13918</span>&#160;        ++customCtxIndex)</div>
-<div class="line"><a name="l13919"></a><span class="lineno">13919</span>&#160;    {</div>
-<div class="line"><a name="l13920"></a><span class="lineno">13920</span>&#160;        VmaBlockVectorDefragmentationContext* pBlockVectorCtx = m_CustomPoolContexts[customCtxIndex];</div>
-<div class="line"><a name="l13921"></a><span class="lineno">13921</span>&#160;        VMA_ASSERT(pBlockVectorCtx &amp;&amp; pBlockVectorCtx-&gt;GetBlockVector());</div>
-<div class="line"><a name="l13922"></a><span class="lineno">13922</span>&#160;        pBlockVectorCtx-&gt;GetBlockVector()-&gt;Defragment(</div>
-<div class="line"><a name="l13923"></a><span class="lineno">13923</span>&#160;            pBlockVectorCtx,</div>
-<div class="line"><a name="l13924"></a><span class="lineno">13924</span>&#160;            pStats,</div>
-<div class="line"><a name="l13925"></a><span class="lineno">13925</span>&#160;            maxCpuBytesToMove, maxCpuAllocationsToMove,</div>
-<div class="line"><a name="l13926"></a><span class="lineno">13926</span>&#160;            maxGpuBytesToMove, maxGpuAllocationsToMove,</div>
-<div class="line"><a name="l13927"></a><span class="lineno">13927</span>&#160;            commandBuffer);</div>
-<div class="line"><a name="l13928"></a><span class="lineno">13928</span>&#160;        <span class="keywordflow">if</span>(pBlockVectorCtx-&gt;res != VK_SUCCESS)</div>
-<div class="line"><a name="l13929"></a><span class="lineno">13929</span>&#160;        {</div>
-<div class="line"><a name="l13930"></a><span class="lineno">13930</span>&#160;            res = pBlockVectorCtx-&gt;res;</div>
-<div class="line"><a name="l13931"></a><span class="lineno">13931</span>&#160;        }</div>
-<div class="line"><a name="l13932"></a><span class="lineno">13932</span>&#160;    }</div>
-<div class="line"><a name="l13933"></a><span class="lineno">13933</span>&#160; </div>
-<div class="line"><a name="l13934"></a><span class="lineno">13934</span>&#160;    <span class="keywordflow">return</span> res;</div>
-<div class="line"><a name="l13935"></a><span class="lineno">13935</span>&#160;}</div>
-<div class="line"><a name="l13936"></a><span class="lineno">13936</span>&#160; </div>
-<div class="line"><a name="l13938"></a><span class="lineno">13938</span>&#160;<span class="comment">// VmaRecorder</span></div>
+<div class="line"><a name="l13891"></a><span class="lineno">13891</span>&#160;    <span class="keywordflow">if</span>(commandBuffer == VK_NULL_HANDLE)</div