mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
synced 2024-11-21 20:00:11 +00:00
Change in the defragmentation API. Compatibility breaking!
Removed VmaDefragmentationMove::dstMemory, dstOffset, internalData, added dstTmpAllocation. Code by @medranSolus
This commit is contained in:
parent
80a07979f5
commit
7d182e2c5a
@ -101,7 +101,7 @@ $(function() {
|
||||
<div class="line"> VkImage newImg;</div>
|
||||
<div class="line"> res = vkCreateImage(device, &imgCreateInfo, <span class="keyword">nullptr</span>, &newImg);</div>
|
||||
<div class="line"> <span class="comment">// Check res...</span></div>
|
||||
<div class="line"> res = vKBindImageMemory(device, newImg, pass.<a class="code hl_variable" href="struct_vma_defragmentation_pass_move_info.html#adfa7a4994afd9b940e7f1dfaf436a725">pMoves</a>[i].<a class="code hl_variable" href="struct_vma_defragmentation_move.html#a382fbec8dac2747abdc1883b69ef9458">dstMemory</a>, pass.<a class="code hl_variable" href="struct_vma_defragmentation_pass_move_info.html#adfa7a4994afd9b940e7f1dfaf436a725">pMoves</a>[i].<a class="code hl_variable" href="struct_vma_defragmentation_move.html#a80c466b445bc272f82c7dbf1a971ba18">dstOffset</a>);</div>
|
||||
<div class="line"> res = <a class="code hl_function" href="group__group__alloc.html#ga3d3ca45799923aa5d138e9e5f9eb2da5">vmaBindImageMemory</a>(allocator, pMoves[i].dstTmpAllocation, newImg);</div>
|
||||
<div class="line"> <span class="comment">// Check res...</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Issue a vkCmdCopyBuffer/vkCmdCopyImage to copy its content to the new place.</span></div>
|
||||
@ -128,6 +128,7 @@ $(function() {
|
||||
<div class="line">}</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><a class="code hl_function" href="group__group__alloc.html#ga59f01ca3d53d50b7cca9b442b77a3e87">vmaEndDefragmentation</a>(allocator, defragCtx, <span class="keyword">nullptr</span>);</div>
|
||||
<div class="ttc" id="agroup__group__alloc_html_ga3d3ca45799923aa5d138e9e5f9eb2da5"><div class="ttname"><a href="group__group__alloc.html#ga3d3ca45799923aa5d138e9e5f9eb2da5">vmaBindImageMemory</a></div><div class="ttdeci">VkResult vmaBindImageMemory(VmaAllocator allocator, VmaAllocation allocation, VkImage image)</div><div class="ttdoc">Binds image to allocation.</div></div>
|
||||
<div class="ttc" id="agroup__group__alloc_html_ga59f01ca3d53d50b7cca9b442b77a3e87"><div class="ttname"><a href="group__group__alloc.html#ga59f01ca3d53d50b7cca9b442b77a3e87">vmaEndDefragmentation</a></div><div class="ttdeci">void vmaEndDefragmentation(VmaAllocator allocator, VmaDefragmentationContext context, VmaDefragmentationStats *pStats)</div><div class="ttdoc">Ends defragmentation process.</div></div>
|
||||
<div class="ttc" id="agroup__group__alloc_html_ga86dd08aba8633bfa4ad0df2e76481d8b"><div class="ttname"><a href="group__group__alloc.html#ga86dd08aba8633bfa4ad0df2e76481d8b">vmaGetAllocationInfo</a></div><div class="ttdeci">void vmaGetAllocationInfo(VmaAllocator allocator, VmaAllocation allocation, VmaAllocationInfo *pAllocationInfo)</div><div class="ttdoc">Returns current information about specified allocation.</div></div>
|
||||
<div class="ttc" id="agroup__group__alloc_html_ga980d7da2ce3b1fd5c8b8476bc362cc00"><div class="ttname"><a href="group__group__alloc.html#ga980d7da2ce3b1fd5c8b8476bc362cc00">vmaBeginDefragmentationPass</a></div><div class="ttdeci">VkResult vmaBeginDefragmentationPass(VmaAllocator allocator, VmaDefragmentationContext context, VmaDefragmentationPassMoveInfo *pPassInfo)</div><div class="ttdoc">Starts single defragmentation pass.</div></div>
|
||||
@ -140,33 +141,30 @@ $(function() {
|
||||
<div class="ttc" id="astruct_vma_defragmentation_info_html"><div class="ttname"><a href="struct_vma_defragmentation_info.html">VmaDefragmentationInfo</a></div><div class="ttdoc">Parameters for defragmentation.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1401</div></div>
|
||||
<div class="ttc" id="astruct_vma_defragmentation_info_html_a18dd2097d8ab2976cdc7dd3e7b978bd4"><div class="ttname"><a href="struct_vma_defragmentation_info.html#a18dd2097d8ab2976cdc7dd3e7b978bd4">VmaDefragmentationInfo::pool</a></div><div class="ttdeci">VmaPool pool</div><div class="ttdoc">Custom pool to be defragmented.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1408</div></div>
|
||||
<div class="ttc" id="astruct_vma_defragmentation_info_html_a3e23080c978ecf3abb3180f5b2069da7"><div class="ttname"><a href="struct_vma_defragmentation_info.html#a3e23080c978ecf3abb3180f5b2069da7">VmaDefragmentationInfo::flags</a></div><div class="ttdeci">VmaDefragmentationFlags flags</div><div class="ttdoc">Use combination of VmaDefragmentationFlagBits.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1403</div></div>
|
||||
<div class="ttc" id="astruct_vma_defragmentation_move_html_a382fbec8dac2747abdc1883b69ef9458"><div class="ttname"><a href="struct_vma_defragmentation_move.html#a382fbec8dac2747abdc1883b69ef9458">VmaDefragmentationMove::dstMemory</a></div><div class="ttdeci">VkDeviceMemory dstMemory</div><div class="ttdoc">Destination memory block where the allocation should be moved.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1429</div></div>
|
||||
<div class="ttc" id="astruct_vma_defragmentation_move_html_a80c466b445bc272f82c7dbf1a971ba18"><div class="ttname"><a href="struct_vma_defragmentation_move.html#a80c466b445bc272f82c7dbf1a971ba18">VmaDefragmentationMove::dstOffset</a></div><div class="ttdeci">VkDeviceSize dstOffset</div><div class="ttdoc">Destination offset where the allocation should be moved.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1431</div></div>
|
||||
<div class="ttc" id="astruct_vma_defragmentation_pass_move_info_html"><div class="ttname"><a href="struct_vma_defragmentation_pass_move_info.html">VmaDefragmentationPassMoveInfo</a></div><div class="ttdoc">Parameters for incremental defragmentation steps.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1441</div></div>
|
||||
<div class="ttc" id="astruct_vma_defragmentation_pass_move_info_html_a1b3e18c23f9691f35baf183e615c4408"><div class="ttname"><a href="struct_vma_defragmentation_pass_move_info.html#a1b3e18c23f9691f35baf183e615c4408">VmaDefragmentationPassMoveInfo::moveCount</a></div><div class="ttdeci">uint32_t moveCount</div><div class="ttdoc">Number of elements in the pMoves array.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1443</div></div>
|
||||
<div class="ttc" id="astruct_vma_defragmentation_pass_move_info_html_adfa7a4994afd9b940e7f1dfaf436a725"><div class="ttname"><a href="struct_vma_defragmentation_pass_move_info.html#adfa7a4994afd9b940e7f1dfaf436a725">VmaDefragmentationPassMoveInfo::pMoves</a></div><div class="ttdeci">VmaDefragmentationMove * pMoves</div><div class="ttdoc">Array of moves to be performed by the user in the current defragmentation pass.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1467</div></div>
|
||||
<div class="ttc" id="astruct_vma_defragmentation_pass_move_info_html"><div class="ttname"><a href="struct_vma_defragmentation_pass_move_info.html">VmaDefragmentationPassMoveInfo</a></div><div class="ttdoc">Parameters for incremental defragmentation steps.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1442</div></div>
|
||||
<div class="ttc" id="astruct_vma_defragmentation_pass_move_info_html_a1b3e18c23f9691f35baf183e615c4408"><div class="ttname"><a href="struct_vma_defragmentation_pass_move_info.html#a1b3e18c23f9691f35baf183e615c4408">VmaDefragmentationPassMoveInfo::moveCount</a></div><div class="ttdeci">uint32_t moveCount</div><div class="ttdoc">Number of elements in the pMoves array.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1444</div></div>
|
||||
</div><!-- fragment --><p >Although functions like <a class="el" href="group__group__alloc.html#gac72ee55598617e8eecca384e746bab51" title="Creates a new VkBuffer, allocates and binds memory for it.">vmaCreateBuffer()</a>, <a class="el" href="group__group__alloc.html#ga02a94f25679275851a53e82eacbcfc73" title="Function similar to vmaCreateBuffer().">vmaCreateImage()</a>, <a class="el" href="group__group__alloc.html#ga0d9f4e4ba5bf9aab1f1c746387753d77" title="Destroys Vulkan buffer and frees allocated memory.">vmaDestroyBuffer()</a>, <a class="el" href="group__group__alloc.html#gae50d2cb3b4a3bfd4dd40987234e50e7e" title="Destroys Vulkan image and frees allocated memory.">vmaDestroyImage()</a> create/destroy an allocation and a buffer/image at once, these are just a shortcut for creating the resource, allocating memory, and binding them together. Defragmentation works on memory allocations only. You must handle the rest manually. Defragmentation is an iterative process that should repreat "passes" as long as related functions return <code>VK_INCOMPLETE</code> not <code>VK_SUCCESS</code>. In each pass:</p>
|
||||
<ol type="1">
|
||||
<li><a class="el" href="group__group__alloc.html#ga980d7da2ce3b1fd5c8b8476bc362cc00" title="Starts single defragmentation pass.">vmaBeginDefragmentationPass()</a> function call:<ul>
|
||||
<li>Calculates and returns the list of allocations to be moved in this pass. Note this can be a time-consuming process.</li>
|
||||
<li>Reserves destination memory for them by creating internal allocations. Returns their <code>VkDeviceMemory</code> + offset.</li>
|
||||
<li>Reserves destination memory for them by creating temporary destination allocations that you can query for their <code>VkDeviceMemory</code> + offset using <a class="el" href="group__group__alloc.html#ga86dd08aba8633bfa4ad0df2e76481d8b" title="Returns current information about specified allocation.">vmaGetAllocationInfo()</a>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Inside the pass, <b>you should</b>:<ul>
|
||||
<li>Inspect the returned list of allocations to be moved.</li>
|
||||
<li>Create new buffers/images and bind them at the returned destination <code>VkDeviceMemory</code> + offset.</li>
|
||||
<li>Create new buffers/images and bind them at the returned destination temporary allocations.</li>
|
||||
<li>Copy data from source to destination resources if necessary.</li>
|
||||
<li>Destroy the source buffers/images, but NOT their allocations.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="el" href="group__group__alloc.html#gaded05a445742a00718ee766144c5c226" title="Ends single defragmentation pass.">vmaEndDefragmentationPass()</a> function call:<ul>
|
||||
<li>Frees the source memory reserved for the allocations that are moved.</li>
|
||||
<li>Modifies <a class="el" href="struct_vma_allocation.html" title="Represents single memory allocation.">VmaAllocation</a> objects that are moved to point to the destination reserved memory.</li>
|
||||
<li>Modifies source <a class="el" href="struct_vma_allocation.html" title="Represents single memory allocation.">VmaAllocation</a> objects that are moved to point to the destination reserved memory.</li>
|
||||
<li>Frees <code>VkDeviceMemory</code> blocks that became empty.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ol>
|
||||
<p >Unlike in previous iterations of the defragmentation API, there is no list of "movable" allocations passed as a parameter. Defragmentation algorithm tries to move all suitable allocations. You can, however, refuse to move some of them inside a defragmentation pass, by setting <code>pass.pMoves[i].operation</code> to <a class="el" href="group__group__alloc.html#ggada9e3861caf96f08894b0bcc160ec257ad25bc6f816b226b4fd5170e845f218d2" title="Set this value if you cannot move the allocation. New place reserved dstMemory + dstOffset will be fr...">VMA_DEFRAGMENTATION_MOVE_OPERATION_IGNORE</a>. This is not recommended and may result in suboptimal packing of the allocations after defragmentation. If you cannot ensure any allocation can be moved, it is better to keep movable allocations separate in a custom pool.</p>
|
||||
<p >Unlike in previous iterations of the defragmentation API, there is no list of "movable" allocations passed as a parameter. Defragmentation algorithm tries to move all suitable allocations. You can, however, refuse to move some of them inside a defragmentation pass, by setting <code>pass.pMoves[i].operation</code> to <a class="el" href="group__group__alloc.html#ggada9e3861caf96f08894b0bcc160ec257ad25bc6f816b226b4fd5170e845f218d2" title="Set this value if you cannot move the allocation. New place reserved at dstTmpAllocation will be free...">VMA_DEFRAGMENTATION_MOVE_OPERATION_IGNORE</a>. This is not recommended and may result in suboptimal packing of the allocations after defragmentation. If you cannot ensure any allocation can be moved, it is better to keep movable allocations separate in a custom pool.</p>
|
||||
<p >Inside a pass, for each allocation that should be moved:</p>
|
||||
<ul>
|
||||
<li>You should copy its data from the source to the destination place by calling e.g. <code>vkCmdCopyBuffer()</code>, <code>vkCmdCopyImage()</code>.<ul>
|
||||
@ -175,12 +173,12 @@ $(function() {
|
||||
</li>
|
||||
<li>If a resource doesn't contain any meaningful data, e.g. it is a transient color attachment image to be cleared, filled, and used temporarily in each rendering frame, you can just recreate this image without copying its data.</li>
|
||||
<li>If the resource is in <code>HOST_VISIBLE</code> and <code>HOST_COHERENT</code> memory, you can copy its data on the CPU using <code>memcpy()</code>.</li>
|
||||
<li>If you cannot move the allocation, you can set <code>pass.pMoves[i].operation</code> to <a class="el" href="group__group__alloc.html#ggada9e3861caf96f08894b0bcc160ec257ad25bc6f816b226b4fd5170e845f218d2" title="Set this value if you cannot move the allocation. New place reserved dstMemory + dstOffset will be fr...">VMA_DEFRAGMENTATION_MOVE_OPERATION_IGNORE</a>. This will cancel the move.<ul>
|
||||
<li>If you cannot move the allocation, you can set <code>pass.pMoves[i].operation</code> to <a class="el" href="group__group__alloc.html#ggada9e3861caf96f08894b0bcc160ec257ad25bc6f816b226b4fd5170e845f218d2" title="Set this value if you cannot move the allocation. New place reserved at dstTmpAllocation will be free...">VMA_DEFRAGMENTATION_MOVE_OPERATION_IGNORE</a>. This will cancel the move.<ul>
|
||||
<li><a class="el" href="group__group__alloc.html#gaded05a445742a00718ee766144c5c226" title="Ends single defragmentation pass.">vmaEndDefragmentationPass()</a> will then free the destination memory not the source memory of the allocation, leaving it unchanged.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>If you decide the allocation is unimportant and can be destroyed instead of moved (e.g. it wasn't used for long time), you can set <code>pass.pMoves[i].operation</code> to <a class="el" href="group__group__alloc.html#ggada9e3861caf96f08894b0bcc160ec257a9786f8492a9be2c03bd26395e352ab85" title="Set this value if you decide to abandon the allocation and you destroyed the buffer/image....">VMA_DEFRAGMENTATION_MOVE_OPERATION_DESTROY</a>.<ul>
|
||||
<li><a class="el" href="group__group__alloc.html#gaded05a445742a00718ee766144c5c226" title="Ends single defragmentation pass.">vmaEndDefragmentationPass()</a> will then free both source and destination memory, and will destroy the <a class="el" href="struct_vma_allocation.html" title="Represents single memory allocation.">VmaAllocation</a> object.</li>
|
||||
<li><a class="el" href="group__group__alloc.html#gaded05a445742a00718ee766144c5c226" title="Ends single defragmentation pass.">vmaEndDefragmentationPass()</a> will then free both source and destination memory, and will destroy the source <a class="el" href="struct_vma_allocation.html" title="Represents single memory allocation.">VmaAllocation</a> object.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -88,8 +88,7 @@ $(function() {
|
||||
<li>device : <a class="el" href="struct_vma_allocator_create_info.html#ad924ddd77b04039c88d0c09b0ffcd500">VmaAllocatorCreateInfo</a>, <a class="el" href="struct_vma_allocator_info.html#a012b4c485bf3b0ea8921352c5ee0c357">VmaAllocatorInfo</a></li>
|
||||
<li>deviceMemory : <a class="el" href="struct_vma_allocation_info.html#ae0bfb7dfdf79a76ffefc9a94677a2f67">VmaAllocationInfo</a></li>
|
||||
<li>deviceMemoryBlocksFreed : <a class="el" href="struct_vma_defragmentation_stats.html#a0113f1877904a5d1ee8f409216ff276b">VmaDefragmentationStats</a></li>
|
||||
<li>dstMemory : <a class="el" href="struct_vma_defragmentation_move.html#a382fbec8dac2747abdc1883b69ef9458">VmaDefragmentationMove</a></li>
|
||||
<li>dstOffset : <a class="el" href="struct_vma_defragmentation_move.html#a80c466b445bc272f82c7dbf1a971ba18">VmaDefragmentationMove</a></li>
|
||||
<li>dstTmpAllocation : <a class="el" href="struct_vma_defragmentation_move.html#ab65b106adf209acd7313296d1075300e">VmaDefragmentationMove</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
@ -100,7 +99,6 @@ $(function() {
|
||||
|
||||
<h3><a id="index_i" name="index_i"></a>- i -</h3><ul>
|
||||
<li>instance : <a class="el" href="struct_vma_allocator_create_info.html#a70dd42e29b1df1d1b9b61532ae0b370b">VmaAllocatorCreateInfo</a>, <a class="el" href="struct_vma_allocator_info.html#a2ed6a4d2d3fea039d66a13f15d0ce5fe">VmaAllocatorInfo</a></li>
|
||||
<li>internalData : <a class="el" href="struct_vma_defragmentation_move.html#a4f3637400767f3e642b3936e18b00e0f">VmaDefragmentationMove</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -88,8 +88,7 @@ $(function() {
|
||||
<li>device : <a class="el" href="struct_vma_allocator_create_info.html#ad924ddd77b04039c88d0c09b0ffcd500">VmaAllocatorCreateInfo</a>, <a class="el" href="struct_vma_allocator_info.html#a012b4c485bf3b0ea8921352c5ee0c357">VmaAllocatorInfo</a></li>
|
||||
<li>deviceMemory : <a class="el" href="struct_vma_allocation_info.html#ae0bfb7dfdf79a76ffefc9a94677a2f67">VmaAllocationInfo</a></li>
|
||||
<li>deviceMemoryBlocksFreed : <a class="el" href="struct_vma_defragmentation_stats.html#a0113f1877904a5d1ee8f409216ff276b">VmaDefragmentationStats</a></li>
|
||||
<li>dstMemory : <a class="el" href="struct_vma_defragmentation_move.html#a382fbec8dac2747abdc1883b69ef9458">VmaDefragmentationMove</a></li>
|
||||
<li>dstOffset : <a class="el" href="struct_vma_defragmentation_move.html#a80c466b445bc272f82c7dbf1a971ba18">VmaDefragmentationMove</a></li>
|
||||
<li>dstTmpAllocation : <a class="el" href="struct_vma_defragmentation_move.html#ab65b106adf209acd7313296d1075300e">VmaDefragmentationMove</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
@ -100,7 +99,6 @@ $(function() {
|
||||
|
||||
<h3><a id="index_i" name="index_i"></a>- i -</h3><ul>
|
||||
<li>instance : <a class="el" href="struct_vma_allocator_create_info.html#a70dd42e29b1df1d1b9b61532ae0b370b">VmaAllocatorCreateInfo</a>, <a class="el" href="struct_vma_allocator_info.html#a2ed6a4d2d3fea039d66a13f15d0ce5fe">VmaAllocatorInfo</a></li>
|
||||
<li>internalData : <a class="el" href="struct_vma_defragmentation_move.html#a4f3637400767f3e642b3936e18b00e0f">VmaDefragmentationMove</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -712,11 +712,11 @@ Functions</h2></td></tr>
|
||||
|
||||
<p>Operation performed on single defragmentation move. See structure <a class="el" href="struct_vma_defragmentation_move.html" title="Single move of an allocation to be done for defragmentation.">VmaDefragmentationMove</a>. </p>
|
||||
<table class="fieldtable">
|
||||
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="ggada9e3861caf96f08894b0bcc160ec257ad4a06ac46c4cb1c67b0ebc1edfab9f18" name="ggada9e3861caf96f08894b0bcc160ec257ad4a06ac46c4cb1c67b0ebc1edfab9f18"></a>VMA_DEFRAGMENTATION_MOVE_OPERATION_COPY </td><td class="fielddoc"><p >Buffer/image has been recreated at <code>dstMemory</code> + <code>dstOffset</code>, data has been copied, old buffer/image has been destroyed. <code>srcAllocation</code> should be changed to point to the new place. This is the default value set by <a class="el" href="group__group__alloc.html#ga980d7da2ce3b1fd5c8b8476bc362cc00" title="Starts single defragmentation pass.">vmaBeginDefragmentationPass()</a>. </p>
|
||||
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="ggada9e3861caf96f08894b0bcc160ec257ad4a06ac46c4cb1c67b0ebc1edfab9f18" name="ggada9e3861caf96f08894b0bcc160ec257ad4a06ac46c4cb1c67b0ebc1edfab9f18"></a>VMA_DEFRAGMENTATION_MOVE_OPERATION_COPY </td><td class="fielddoc"><p >Buffer/image has been recreated at <code>dstTmpAllocation</code>, data has been copied, old buffer/image has been destroyed. <code>srcAllocation</code> should be changed to point to the new place. This is the default value set by <a class="el" href="group__group__alloc.html#ga980d7da2ce3b1fd5c8b8476bc362cc00" title="Starts single defragmentation pass.">vmaBeginDefragmentationPass()</a>. </p>
|
||||
</td></tr>
|
||||
<tr><td class="fieldname"><a id="ggada9e3861caf96f08894b0bcc160ec257ad25bc6f816b226b4fd5170e845f218d2" name="ggada9e3861caf96f08894b0bcc160ec257ad25bc6f816b226b4fd5170e845f218d2"></a>VMA_DEFRAGMENTATION_MOVE_OPERATION_IGNORE </td><td class="fielddoc"><p >Set this value if you cannot move the allocation. New place reserved <code>dstMemory</code> + <code>dstOffset</code> will be freed. <code>srcAllocation</code> will remain unchanged. </p>
|
||||
<tr><td class="fieldname"><a id="ggada9e3861caf96f08894b0bcc160ec257ad25bc6f816b226b4fd5170e845f218d2" name="ggada9e3861caf96f08894b0bcc160ec257ad25bc6f816b226b4fd5170e845f218d2"></a>VMA_DEFRAGMENTATION_MOVE_OPERATION_IGNORE </td><td class="fielddoc"><p >Set this value if you cannot move the allocation. New place reserved at <code>dstTmpAllocation</code> will be freed. <code>srcAllocation</code> will remain unchanged. </p>
|
||||
</td></tr>
|
||||
<tr><td class="fieldname"><a id="ggada9e3861caf96f08894b0bcc160ec257a9786f8492a9be2c03bd26395e352ab85" name="ggada9e3861caf96f08894b0bcc160ec257a9786f8492a9be2c03bd26395e352ab85"></a>VMA_DEFRAGMENTATION_MOVE_OPERATION_DESTROY </td><td class="fielddoc"><p >Set this value if you decide to abandon the allocation and you destroyed the buffer/image. New place reserved <code>dstMemory</code> + <code>dstOffset</code> will be freed, along with <code>srcAllocation</code>. </p>
|
||||
<tr><td class="fieldname"><a id="ggada9e3861caf96f08894b0bcc160ec257a9786f8492a9be2c03bd26395e352ab85" name="ggada9e3861caf96f08894b0bcc160ec257a9786f8492a9be2c03bd26395e352ab85"></a>VMA_DEFRAGMENTATION_MOVE_OPERATION_DESTROY </td><td class="fielddoc"><p >Set this value if you decide to abandon the allocation and you destroyed the buffer/image. New place reserved at <code>dstTmpAllocation</code> will be freed, along with <code>srcAllocation</code>, which will be destroyed. </p>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
@ -1862,7 +1862,7 @@ Functions</h2></td></tr>
|
||||
<p>Returns <code>VK_SUCCESS</code> if no more moves are possible or <code>VK_INCOMPLETE</code> if more defragmentations are possible.</p>
|
||||
<p >Ends incremental defragmentation pass and commits all defragmentation moves from <code>pPassInfo</code>. After this call:</p>
|
||||
<ul>
|
||||
<li>Allocations at <code>pPassInfo[i].srcAllocation</code> that had <code>pPassInfo[i].operation ==</code> <a class="el" href="group__group__alloc.html#ggada9e3861caf96f08894b0bcc160ec257ad4a06ac46c4cb1c67b0ebc1edfab9f18" title="Buffer/image has been recreated at dstMemory + dstOffset, data has been copied, old buffer/image has ...">VMA_DEFRAGMENTATION_MOVE_OPERATION_COPY</a> (which is the default) will be pointing to the new destination place.</li>
|
||||
<li>Allocations at <code>pPassInfo[i].srcAllocation</code> that had <code>pPassInfo[i].operation ==</code> <a class="el" href="group__group__alloc.html#ggada9e3861caf96f08894b0bcc160ec257ad4a06ac46c4cb1c67b0ebc1edfab9f18" title="Buffer/image has been recreated at dstTmpAllocation, data has been copied, old buffer/image has been ...">VMA_DEFRAGMENTATION_MOVE_OPERATION_COPY</a> (which is the default) will be pointing to the new destination place.</li>
|
||||
<li>Allocation at <code>pPassInfo[i].srcAllocation</code> that had <code>pPassInfo[i].operation ==</code> <a class="el" href="group__group__alloc.html#ggada9e3861caf96f08894b0bcc160ec257a9786f8492a9be2c03bd26395e352ab85" title="Set this value if you decide to abandon the allocation and you destroyed the buffer/image....">VMA_DEFRAGMENTATION_MOVE_OPERATION_DESTROY</a> will be freed.</li>
|
||||
</ul>
|
||||
<p >If no more moves are possible you can end whole defragmentation. </p>
|
||||
|
@ -6,6 +6,5 @@ var searchData=
|
||||
['device_3',['device',['../struct_vma_allocator_create_info.html#ad924ddd77b04039c88d0c09b0ffcd500',1,'VmaAllocatorCreateInfo::device()'],['../struct_vma_allocator_info.html#a012b4c485bf3b0ea8921352c5ee0c357',1,'VmaAllocatorInfo::device()']]],
|
||||
['devicememory_4',['deviceMemory',['../struct_vma_allocation_info.html#ae0bfb7dfdf79a76ffefc9a94677a2f67',1,'VmaAllocationInfo']]],
|
||||
['devicememoryblocksfreed_5',['deviceMemoryBlocksFreed',['../struct_vma_defragmentation_stats.html#a0113f1877904a5d1ee8f409216ff276b',1,'VmaDefragmentationStats']]],
|
||||
['dstmemory_6',['dstMemory',['../struct_vma_defragmentation_move.html#a382fbec8dac2747abdc1883b69ef9458',1,'VmaDefragmentationMove']]],
|
||||
['dstoffset_7',['dstOffset',['../struct_vma_defragmentation_move.html#a80c466b445bc272f82c7dbf1a971ba18',1,'VmaDefragmentationMove']]]
|
||||
['dsttmpallocation_6',['dstTmpAllocation',['../struct_vma_defragmentation_move.html#ab65b106adf209acd7313296d1075300e',1,'VmaDefragmentationMove']]]
|
||||
];
|
||||
|
@ -1,5 +1,4 @@
|
||||
var searchData=
|
||||
[
|
||||
['instance_0',['instance',['../struct_vma_allocator_create_info.html#a70dd42e29b1df1d1b9b61532ae0b370b',1,'VmaAllocatorCreateInfo::instance()'],['../struct_vma_allocator_info.html#a2ed6a4d2d3fea039d66a13f15d0ce5fe',1,'VmaAllocatorInfo::instance()']]],
|
||||
['internaldata_1',['internalData',['../struct_vma_defragmentation_move.html#a4f3637400767f3e642b3936e18b00e0f',1,'VmaDefragmentationMove']]]
|
||||
['instance_0',['instance',['../struct_vma_allocator_create_info.html#a70dd42e29b1df1d1b9b61532ae0b370b',1,'VmaAllocatorCreateInfo::instance()'],['../struct_vma_allocator_info.html#a2ed6a4d2d3fea039d66a13f15d0ce5fe',1,'VmaAllocatorInfo::instance()']]]
|
||||
];
|
||||
|
@ -3,6 +3,5 @@ var searchData=
|
||||
['device_0',['device',['../struct_vma_allocator_create_info.html#ad924ddd77b04039c88d0c09b0ffcd500',1,'VmaAllocatorCreateInfo::device()'],['../struct_vma_allocator_info.html#a012b4c485bf3b0ea8921352c5ee0c357',1,'VmaAllocatorInfo::device()']]],
|
||||
['devicememory_1',['deviceMemory',['../struct_vma_allocation_info.html#ae0bfb7dfdf79a76ffefc9a94677a2f67',1,'VmaAllocationInfo']]],
|
||||
['devicememoryblocksfreed_2',['deviceMemoryBlocksFreed',['../struct_vma_defragmentation_stats.html#a0113f1877904a5d1ee8f409216ff276b',1,'VmaDefragmentationStats']]],
|
||||
['dstmemory_3',['dstMemory',['../struct_vma_defragmentation_move.html#a382fbec8dac2747abdc1883b69ef9458',1,'VmaDefragmentationMove']]],
|
||||
['dstoffset_4',['dstOffset',['../struct_vma_defragmentation_move.html#a80c466b445bc272f82c7dbf1a971ba18',1,'VmaDefragmentationMove']]]
|
||||
['dsttmpallocation_3',['dstTmpAllocation',['../struct_vma_defragmentation_move.html#ab65b106adf209acd7313296d1075300e',1,'VmaDefragmentationMove']]]
|
||||
];
|
||||
|
@ -1,5 +1,4 @@
|
||||
var searchData=
|
||||
[
|
||||
['instance_0',['instance',['../struct_vma_allocator_create_info.html#a70dd42e29b1df1d1b9b61532ae0b370b',1,'VmaAllocatorCreateInfo::instance()'],['../struct_vma_allocator_info.html#a2ed6a4d2d3fea039d66a13f15d0ce5fe',1,'VmaAllocatorInfo::instance()']]],
|
||||
['internaldata_1',['internalData',['../struct_vma_defragmentation_move.html#a4f3637400767f3e642b3936e18b00e0f',1,'VmaDefragmentationMove']]]
|
||||
['instance_0',['instance',['../struct_vma_allocator_create_info.html#a70dd42e29b1df1d1b9b61532ae0b370b',1,'VmaAllocatorCreateInfo::instance()'],['../struct_vma_allocator_info.html#a2ed6a4d2d3fea039d66a13f15d0ce5fe',1,'VmaAllocatorInfo::instance()']]]
|
||||
];
|
||||
|
@ -68,9 +68,7 @@ $(function() {
|
||||
|
||||
<p>This is the complete list of members for <a class="el" href="struct_vma_defragmentation_move.html">VmaDefragmentationMove</a>, including all inherited members.</p>
|
||||
<table class="directory">
|
||||
<tr class="even"><td class="entry"><a class="el" href="struct_vma_defragmentation_move.html#a382fbec8dac2747abdc1883b69ef9458">dstMemory</a></td><td class="entry"><a class="el" href="struct_vma_defragmentation_move.html">VmaDefragmentationMove</a></td><td class="entry"></td></tr>
|
||||
<tr class="odd"><td class="entry"><a class="el" href="struct_vma_defragmentation_move.html#a80c466b445bc272f82c7dbf1a971ba18">dstOffset</a></td><td class="entry"><a class="el" href="struct_vma_defragmentation_move.html">VmaDefragmentationMove</a></td><td class="entry"></td></tr>
|
||||
<tr class="even"><td class="entry"><a class="el" href="struct_vma_defragmentation_move.html#a4f3637400767f3e642b3936e18b00e0f">internalData</a></td><td class="entry"><a class="el" href="struct_vma_defragmentation_move.html">VmaDefragmentationMove</a></td><td class="entry"></td></tr>
|
||||
<tr class="even"><td class="entry"><a class="el" href="struct_vma_defragmentation_move.html#ab65b106adf209acd7313296d1075300e">dstTmpAllocation</a></td><td class="entry"><a class="el" href="struct_vma_defragmentation_move.html">VmaDefragmentationMove</a></td><td class="entry"></td></tr>
|
||||
<tr class="odd"><td class="entry"><a class="el" href="struct_vma_defragmentation_move.html#a20996a4686c9246dff77b375ac4a91e2">operation</a></td><td class="entry"><a class="el" href="struct_vma_defragmentation_move.html">VmaDefragmentationMove</a></td><td class="entry"></td></tr>
|
||||
<tr class="even"><td class="entry"><a class="el" href="struct_vma_defragmentation_move.html#a25aa1bb64efc507a49c6cbc50689f862">srcAllocation</a></td><td class="entry"><a class="el" href="struct_vma_defragmentation_move.html">VmaDefragmentationMove</a></td><td class="entry"></td></tr>
|
||||
</table></div><!-- contents -->
|
||||
|
@ -75,69 +75,32 @@ $(function() {
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-attribs" name="pub-attribs"></a>
|
||||
Public Attributes</h2></td></tr>
|
||||
<tr class="memitem:a20996a4686c9246dff77b375ac4a91e2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__alloc.html#gada9e3861caf96f08894b0bcc160ec257">VmaDefragmentationMoveOperation</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_vma_defragmentation_move.html#a20996a4686c9246dff77b375ac4a91e2">operation</a></td></tr>
|
||||
<tr class="memdesc:a20996a4686c9246dff77b375ac4a91e2"><td class="mdescLeft"> </td><td class="mdescRight">Operation to be performed on the allocation by <a class="el" href="group__group__alloc.html#gaded05a445742a00718ee766144c5c226" title="Ends single defragmentation pass.">vmaEndDefragmentationPass()</a>. Default value is <a class="el" href="group__group__alloc.html#ggada9e3861caf96f08894b0bcc160ec257ad4a06ac46c4cb1c67b0ebc1edfab9f18" title="Buffer/image has been recreated at dstMemory + dstOffset, data has been copied, old buffer/image has ...">VMA_DEFRAGMENTATION_MOVE_OPERATION_COPY</a>. You can modify it. <a href="struct_vma_defragmentation_move.html#a20996a4686c9246dff77b375ac4a91e2">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:a20996a4686c9246dff77b375ac4a91e2"><td class="mdescLeft"> </td><td class="mdescRight">Operation to be performed on the allocation by <a class="el" href="group__group__alloc.html#gaded05a445742a00718ee766144c5c226" title="Ends single defragmentation pass.">vmaEndDefragmentationPass()</a>. Default value is <a class="el" href="group__group__alloc.html#ggada9e3861caf96f08894b0bcc160ec257ad4a06ac46c4cb1c67b0ebc1edfab9f18" title="Buffer/image has been recreated at dstTmpAllocation, data has been copied, old buffer/image has been ...">VMA_DEFRAGMENTATION_MOVE_OPERATION_COPY</a>. You can modify it. <a href="struct_vma_defragmentation_move.html#a20996a4686c9246dff77b375ac4a91e2">More...</a><br /></td></tr>
|
||||
<tr class="separator:a20996a4686c9246dff77b375ac4a91e2"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a25aa1bb64efc507a49c6cbc50689f862"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_vma_allocation.html">VmaAllocation</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_vma_defragmentation_move.html#a25aa1bb64efc507a49c6cbc50689f862">srcAllocation</a></td></tr>
|
||||
<tr class="memdesc:a25aa1bb64efc507a49c6cbc50689f862"><td class="mdescLeft"> </td><td class="mdescRight">Allocation that should be moved. <a href="struct_vma_defragmentation_move.html#a25aa1bb64efc507a49c6cbc50689f862">More...</a><br /></td></tr>
|
||||
<tr class="separator:a25aa1bb64efc507a49c6cbc50689f862"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a382fbec8dac2747abdc1883b69ef9458"><td class="memItemLeft" align="right" valign="top">VkDeviceMemory </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_vma_defragmentation_move.html#a382fbec8dac2747abdc1883b69ef9458">dstMemory</a></td></tr>
|
||||
<tr class="memdesc:a382fbec8dac2747abdc1883b69ef9458"><td class="mdescLeft"> </td><td class="mdescRight">Destination memory block where the allocation should be moved. <a href="struct_vma_defragmentation_move.html#a382fbec8dac2747abdc1883b69ef9458">More...</a><br /></td></tr>
|
||||
<tr class="separator:a382fbec8dac2747abdc1883b69ef9458"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a80c466b445bc272f82c7dbf1a971ba18"><td class="memItemLeft" align="right" valign="top">VkDeviceSize </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_vma_defragmentation_move.html#a80c466b445bc272f82c7dbf1a971ba18">dstOffset</a></td></tr>
|
||||
<tr class="memdesc:a80c466b445bc272f82c7dbf1a971ba18"><td class="mdescLeft"> </td><td class="mdescRight">Destination offset where the allocation should be moved. <a href="struct_vma_defragmentation_move.html#a80c466b445bc272f82c7dbf1a971ba18">More...</a><br /></td></tr>
|
||||
<tr class="separator:a80c466b445bc272f82c7dbf1a971ba18"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a4f3637400767f3e642b3936e18b00e0f"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_vma_defragmentation_move.html#a4f3637400767f3e642b3936e18b00e0f">internalData</a></td></tr>
|
||||
<tr class="memdesc:a4f3637400767f3e642b3936e18b00e0f"><td class="mdescLeft"> </td><td class="mdescRight">Internal data used by VMA. Do not use or modify! <a href="struct_vma_defragmentation_move.html#a4f3637400767f3e642b3936e18b00e0f">More...</a><br /></td></tr>
|
||||
<tr class="separator:a4f3637400767f3e642b3936e18b00e0f"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:ab65b106adf209acd7313296d1075300e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_vma_allocation.html">VmaAllocation</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_vma_defragmentation_move.html#ab65b106adf209acd7313296d1075300e">dstTmpAllocation</a></td></tr>
|
||||
<tr class="memdesc:ab65b106adf209acd7313296d1075300e"><td class="mdescLeft"> </td><td class="mdescRight">Temporary allocation pointing to destination memory that will replace <code>srcAllocation</code>. <a href="struct_vma_defragmentation_move.html#ab65b106adf209acd7313296d1075300e">More...</a><br /></td></tr>
|
||||
<tr class="separator:ab65b106adf209acd7313296d1075300e"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
</table>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p >Single move of an allocation to be done for defragmentation. </p>
|
||||
</div><h2 class="groupheader">Member Data Documentation</h2>
|
||||
<a id="a382fbec8dac2747abdc1883b69ef9458" name="a382fbec8dac2747abdc1883b69ef9458"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a382fbec8dac2747abdc1883b69ef9458">◆ </a></span>dstMemory</h2>
|
||||
<a id="ab65b106adf209acd7313296d1075300e" name="ab65b106adf209acd7313296d1075300e"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#ab65b106adf209acd7313296d1075300e">◆ </a></span>dstTmpAllocation</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname">VkDeviceMemory VmaDefragmentationMove::dstMemory</td>
|
||||
<td class="memname"><a class="el" href="struct_vma_allocation.html">VmaAllocation</a> VmaDefragmentationMove::dstTmpAllocation</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Destination memory block where the allocation should be moved. </p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a id="a80c466b445bc272f82c7dbf1a971ba18" name="a80c466b445bc272f82c7dbf1a971ba18"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a80c466b445bc272f82c7dbf1a971ba18">◆ </a></span>dstOffset</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname">VkDeviceSize VmaDefragmentationMove::dstOffset</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Destination offset where the allocation should be moved. </p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a id="a4f3637400767f3e642b3936e18b00e0f" name="a4f3637400767f3e642b3936e18b00e0f"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a4f3637400767f3e642b3936e18b00e0f">◆ </a></span>internalData</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname">void* VmaDefragmentationMove::internalData</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Internal data used by VMA. Do not use or modify! </p>
|
||||
<p>Temporary allocation pointing to destination memory that will replace <code>srcAllocation</code>. </p>
|
||||
<dl class="section warning"><dt>Warning</dt><dd>Do not store this allocation in your data structures! It exists only temporarily, for the duration of the defragmentation pass, to be used for binding new buffer/image to the destination memory using e.g. <a class="el" href="group__group__alloc.html#ga6b0929b914b60cf2d45cac4bf3547470" title="Binds buffer to allocation.">vmaBindBufferMemory()</a>. <a class="el" href="group__group__alloc.html#gaded05a445742a00718ee766144c5c226" title="Ends single defragmentation pass.">vmaEndDefragmentationPass()</a> will destroy it and make <code>srcAllocation</code> point to this memory. </dd></dl>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -153,7 +116,7 @@ Public Attributes</h2></td></tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Operation to be performed on the allocation by <a class="el" href="group__group__alloc.html#gaded05a445742a00718ee766144c5c226" title="Ends single defragmentation pass.">vmaEndDefragmentationPass()</a>. Default value is <a class="el" href="group__group__alloc.html#ggada9e3861caf96f08894b0bcc160ec257ad4a06ac46c4cb1c67b0ebc1edfab9f18" title="Buffer/image has been recreated at dstMemory + dstOffset, data has been copied, old buffer/image has ...">VMA_DEFRAGMENTATION_MOVE_OPERATION_COPY</a>. You can modify it. </p>
|
||||
<p>Operation to be performed on the allocation by <a class="el" href="group__group__alloc.html#gaded05a445742a00718ee766144c5c226" title="Ends single defragmentation pass.">vmaEndDefragmentationPass()</a>. Default value is <a class="el" href="group__group__alloc.html#ggada9e3861caf96f08894b0bcc160ec257ad4a06ac46c4cb1c67b0ebc1edfab9f18" title="Buffer/image has been recreated at dstTmpAllocation, data has been copied, old buffer/image has been ...">VMA_DEFRAGMENTATION_MOVE_OPERATION_COPY</a>. You can modify it. </p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -117,13 +117,13 @@ Public Attributes</h2></td></tr>
|
||||
<p >Pointer to an array of <code>moveCount</code> elements, owned by VMA, created in <a class="el" href="group__group__alloc.html#ga980d7da2ce3b1fd5c8b8476bc362cc00" title="Starts single defragmentation pass.">vmaBeginDefragmentationPass()</a>, destroyed in <a class="el" href="group__group__alloc.html#gaded05a445742a00718ee766144c5c226" title="Ends single defragmentation pass.">vmaEndDefragmentationPass()</a>.</p>
|
||||
<p >For each element, you should:</p>
|
||||
<ol type="1">
|
||||
<li>Create a new buffer/image in the place pointed by <a class="el" href="struct_vma_defragmentation_move.html#a382fbec8dac2747abdc1883b69ef9458" title="Destination memory block where the allocation should be moved.">VmaDefragmentationMove::dstMemory</a> + <a class="el" href="struct_vma_defragmentation_move.html#a80c466b445bc272f82c7dbf1a971ba18" title="Destination offset where the allocation should be moved.">VmaDefragmentationMove::dstOffset</a>.</li>
|
||||
<li>Create a new buffer/image in the place pointed by VmaDefragmentationMove::dstMemory + VmaDefragmentationMove::dstOffset.</li>
|
||||
<li>Copy data from the <a class="el" href="struct_vma_defragmentation_move.html#a25aa1bb64efc507a49c6cbc50689f862" title="Allocation that should be moved.">VmaDefragmentationMove::srcAllocation</a> e.g. using <code>vkCmdCopyBuffer</code>, <code>vkCmdCopyImage</code>.</li>
|
||||
<li>Make sure these commands finished executing on the GPU.</li>
|
||||
<li>Destroy the old buffer/image.</li>
|
||||
</ol>
|
||||
<p >Only then you can finish defragmentation pass by calling <a class="el" href="group__group__alloc.html#gaded05a445742a00718ee766144c5c226" title="Ends single defragmentation pass.">vmaEndDefragmentationPass()</a>. After this call, the allocation will point to the new place in memory.</p>
|
||||
<p >Alternatively, if you cannot move specific allocation, you can set <a class="el" href="struct_vma_defragmentation_move.html#a20996a4686c9246dff77b375ac4a91e2" title="Operation to be performed on the allocation by vmaEndDefragmentationPass(). Default value is VMA_DEFR...">VmaDefragmentationMove::operation</a> to <a class="el" href="group__group__alloc.html#ggada9e3861caf96f08894b0bcc160ec257ad25bc6f816b226b4fd5170e845f218d2" title="Set this value if you cannot move the allocation. New place reserved dstMemory + dstOffset will be fr...">VMA_DEFRAGMENTATION_MOVE_OPERATION_IGNORE</a>.</p>
|
||||
<p >Alternatively, if you cannot move specific allocation, you can set <a class="el" href="struct_vma_defragmentation_move.html#a20996a4686c9246dff77b375ac4a91e2" title="Operation to be performed on the allocation by vmaEndDefragmentationPass(). Default value is VMA_DEFR...">VmaDefragmentationMove::operation</a> to <a class="el" href="group__group__alloc.html#ggada9e3861caf96f08894b0bcc160ec257ad25bc6f816b226b4fd5170e845f218d2" title="Set this value if you cannot move the allocation. New place reserved at dstTmpAllocation will be free...">VMA_DEFRAGMENTATION_MOVE_OPERATION_IGNORE</a>.</p>
|
||||
<p >Alternatively, if you decide you want to completely remove the allocation:</p>
|
||||
<ol type="1">
|
||||
<li>Destroy its buffer/image.</li>
|
||||
|
@ -84,8 +84,8 @@ Creating virtual block</h1>
|
||||
<div class="line"><a class="code hl_struct" href="struct_vma_virtual_block.html">VmaVirtualBlock</a> block;</div>
|
||||
<div class="line">VkResult res = <a class="code hl_function" href="group__group__virtual.html#gab585754076877265fdae33e5c40ef13b">vmaCreateVirtualBlock</a>(&blockCreateInfo, &block);</div>
|
||||
<div class="ttc" id="agroup__group__virtual_html_gab585754076877265fdae33e5c40ef13b"><div class="ttname"><a href="group__group__virtual.html#gab585754076877265fdae33e5c40ef13b">vmaCreateVirtualBlock</a></div><div class="ttdeci">VkResult vmaCreateVirtualBlock(const VmaVirtualBlockCreateInfo *pCreateInfo, VmaVirtualBlock *pVirtualBlock)</div><div class="ttdoc">Creates new VmaVirtualBlock object.</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_block_create_info_html"><div class="ttname"><a href="struct_vma_virtual_block_create_info.html">VmaVirtualBlockCreateInfo</a></div><div class="ttdoc">Parameters of created VmaVirtualBlock object to be passed to vmaCreateVirtualBlock().</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1492</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_block_create_info_html_a670ab8c6a6e822f3c36781d79e8824e9"><div class="ttname"><a href="struct_vma_virtual_block_create_info.html#a670ab8c6a6e822f3c36781d79e8824e9">VmaVirtualBlockCreateInfo::size</a></div><div class="ttdeci">VkDeviceSize size</div><div class="ttdoc">Total size of the virtual block.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1498</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_block_create_info_html"><div class="ttname"><a href="struct_vma_virtual_block_create_info.html">VmaVirtualBlockCreateInfo</a></div><div class="ttdoc">Parameters of created VmaVirtualBlock object to be passed to vmaCreateVirtualBlock().</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1493</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_block_create_info_html_a670ab8c6a6e822f3c36781d79e8824e9"><div class="ttname"><a href="struct_vma_virtual_block_create_info.html#a670ab8c6a6e822f3c36781d79e8824e9">VmaVirtualBlockCreateInfo::size</a></div><div class="ttdeci">VkDeviceSize size</div><div class="ttdoc">Total size of the virtual block.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1499</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_block_html"><div class="ttname"><a href="struct_vma_virtual_block.html">VmaVirtualBlock</a></div><div class="ttdoc">Handle to a virtual block object that allows to use core allocation algorithm without allocating any ...</div></div>
|
||||
</div><!-- fragment --><h1><a class="anchor" id="virtual_allocator_making_virtual_allocations"></a>
|
||||
Making virtual allocations</h1>
|
||||
@ -111,8 +111,8 @@ Making virtual allocations</h1>
|
||||
<div class="line"> <span class="comment">// Allocation failed - no space for it could be found. Handle this error!</span></div>
|
||||
<div class="line">}</div>
|
||||
<div class="ttc" id="agroup__group__virtual_html_ga6b7cdcc1c3e5103c323fedc4e1319e01"><div class="ttname"><a href="group__group__virtual.html#ga6b7cdcc1c3e5103c323fedc4e1319e01">vmaVirtualAllocate</a></div><div class="ttdeci">VkResult vmaVirtualAllocate(VmaVirtualBlock virtualBlock, const VmaVirtualAllocationCreateInfo *pCreateInfo, VmaVirtualAllocation *pAllocation, VkDeviceSize *pOffset)</div><div class="ttdoc">Allocates new virtual allocation inside given VmaVirtualBlock.</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_allocation_create_info_html"><div class="ttname"><a href="struct_vma_virtual_allocation_create_info.html">VmaVirtualAllocationCreateInfo</a></div><div class="ttdoc">Parameters of created virtual allocation to be passed to vmaVirtualAllocate().</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1513</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_allocation_create_info_html_aae08752b86817abd0d944c6025dc603e"><div class="ttname"><a href="struct_vma_virtual_allocation_create_info.html#aae08752b86817abd0d944c6025dc603e">VmaVirtualAllocationCreateInfo::size</a></div><div class="ttdeci">VkDeviceSize size</div><div class="ttdoc">Size of the allocation.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1518</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_allocation_create_info_html"><div class="ttname"><a href="struct_vma_virtual_allocation_create_info.html">VmaVirtualAllocationCreateInfo</a></div><div class="ttdoc">Parameters of created virtual allocation to be passed to vmaVirtualAllocate().</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1514</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_allocation_create_info_html_aae08752b86817abd0d944c6025dc603e"><div class="ttname"><a href="struct_vma_virtual_allocation_create_info.html#aae08752b86817abd0d944c6025dc603e">VmaVirtualAllocationCreateInfo::size</a></div><div class="ttdeci">VkDeviceSize size</div><div class="ttdoc">Size of the allocation.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1519</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_allocation_html"><div class="ttname"><a href="struct_vma_virtual_allocation.html">VmaVirtualAllocation</a></div><div class="ttdoc">Represents single memory allocation done inside VmaVirtualBlock.</div></div>
|
||||
</div><!-- fragment --><h1><a class="anchor" id="virtual_allocator_deallocation"></a>
|
||||
Deallocation</h1>
|
||||
@ -140,8 +140,8 @@ Allocation parameters</h1>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><a class="code hl_function" href="group__group__virtual.html#ga09fc688c0c3653ff23723b037e5d5033">vmaVirtualFree</a>(block, alloc);</div>
|
||||
<div class="ttc" id="agroup__group__virtual_html_ga8ee14ceb1fe033ec84d8aa29e1f75afa"><div class="ttname"><a href="group__group__virtual.html#ga8ee14ceb1fe033ec84d8aa29e1f75afa">vmaGetVirtualAllocationInfo</a></div><div class="ttdeci">void vmaGetVirtualAllocationInfo(VmaVirtualBlock virtualBlock, VmaVirtualAllocation allocation, VmaVirtualAllocationInfo *pVirtualAllocInfo)</div><div class="ttdoc">Returns information about a specific virtual allocation within a virtual block, like its size and pUs...</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_allocation_info_html"><div class="ttname"><a href="struct_vma_virtual_allocation_info.html">VmaVirtualAllocationInfo</a></div><div class="ttdoc">Parameters of an existing virtual allocation, returned by vmaGetVirtualAllocationInfo().</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1536</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_allocation_info_html_a41d5cb09357656411653d82fee436f45"><div class="ttname"><a href="struct_vma_virtual_allocation_info.html#a41d5cb09357656411653d82fee436f45">VmaVirtualAllocationInfo::pUserData</a></div><div class="ttdeci">void * pUserData</div><div class="ttdoc">Custom pointer associated with the allocation.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1551</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_allocation_info_html"><div class="ttname"><a href="struct_vma_virtual_allocation_info.html">VmaVirtualAllocationInfo</a></div><div class="ttdoc">Parameters of an existing virtual allocation, returned by vmaGetVirtualAllocationInfo().</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1537</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_allocation_info_html_a41d5cb09357656411653d82fee436f45"><div class="ttname"><a href="struct_vma_virtual_allocation_info.html#a41d5cb09357656411653d82fee436f45">VmaVirtualAllocationInfo::pUserData</a></div><div class="ttdeci">void * pUserData</div><div class="ttdoc">Custom pointer associated with the allocation.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1552</div></div>
|
||||
</div><!-- fragment --><h1><a class="anchor" id="virtual_allocator_alignment_and_units"></a>
|
||||
Alignment and units</h1>
|
||||
<p >It feels natural to express sizes and offsets in bytes. If an offset of an allocation needs to be aligned to a multiply of some number (e.g. 4 bytes), you can fill optional member <a class="el" href="struct_vma_virtual_allocation_create_info.html#a9d19709872fc1904a105079e1c885821" title="Required alignment of the allocation. Optional.">VmaVirtualAllocationCreateInfo::alignment</a> to request it. Example:</p>
|
||||
@ -151,7 +151,7 @@ Alignment and units</h1>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><a class="code hl_struct" href="struct_vma_virtual_allocation.html">VmaVirtualAllocation</a> alloc;</div>
|
||||
<div class="line">res = <a class="code hl_function" href="group__group__virtual.html#ga6b7cdcc1c3e5103c323fedc4e1319e01">vmaVirtualAllocate</a>(block, &allocCreateInfo, &alloc, <span class="keyword">nullptr</span>);</div>
|
||||
<div class="ttc" id="astruct_vma_virtual_allocation_create_info_html_a9d19709872fc1904a105079e1c885821"><div class="ttname"><a href="struct_vma_virtual_allocation_create_info.html#a9d19709872fc1904a105079e1c885821">VmaVirtualAllocationCreateInfo::alignment</a></div><div class="ttdeci">VkDeviceSize alignment</div><div class="ttdoc">Required alignment of the allocation. Optional.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1523</div></div>
|
||||
<div class="ttc" id="astruct_vma_virtual_allocation_create_info_html_a9d19709872fc1904a105079e1c885821"><div class="ttname"><a href="struct_vma_virtual_allocation_create_info.html#a9d19709872fc1904a105079e1c885821">VmaVirtualAllocationCreateInfo::alignment</a></div><div class="ttdeci">VkDeviceSize alignment</div><div class="ttdoc">Required alignment of the allocation. Optional.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:1524</div></div>
|
||||
</div><!-- fragment --><p >Alignments of different allocations made from one block may vary. However, if all alignments and sizes are always multiply of some size e.g. 4 B or <code>sizeof(MyDataStruct)</code>, you can express all sizes, alignments, and offsets in multiples of that size instead of individual bytes. It might be more convenient, but you need to make sure to use this new unit consistently in all the places:</p>
|
||||
<ul>
|
||||
<li><a class="el" href="struct_vma_virtual_block_create_info.html#a670ab8c6a6e822f3c36781d79e8824e9" title="Total size of the virtual block.">VmaVirtualBlockCreateInfo::size</a></li>
|
||||
|
@ -735,11 +735,11 @@ typedef VkFlags VmaDefragmentationFlags;
|
||||
/// Operation performed on single defragmentation move. See structure #VmaDefragmentationMove.
|
||||
typedef enum VmaDefragmentationMoveOperation
|
||||
{
|
||||
/// Buffer/image has been recreated at `dstMemory` + `dstOffset`, data has been copied, old buffer/image has been destroyed. `srcAllocation` should be changed to point to the new place. This is the default value set by vmaBeginDefragmentationPass().
|
||||
/// Buffer/image has been recreated at `dstTmpAllocation`, data has been copied, old buffer/image has been destroyed. `srcAllocation` should be changed to point to the new place. This is the default value set by vmaBeginDefragmentationPass().
|
||||
VMA_DEFRAGMENTATION_MOVE_OPERATION_COPY = 0,
|
||||
/// Set this value if you cannot move the allocation. New place reserved `dstMemory` + `dstOffset` will be freed. `srcAllocation` will remain unchanged.
|
||||
/// Set this value if you cannot move the allocation. New place reserved at `dstTmpAllocation` will be freed. `srcAllocation` will remain unchanged.
|
||||
VMA_DEFRAGMENTATION_MOVE_OPERATION_IGNORE = 1,
|
||||
/// Set this value if you decide to abandon the allocation and you destroyed the buffer/image. New place reserved `dstMemory` + `dstOffset` will be freed, along with `srcAllocation`.
|
||||
/// Set this value if you decide to abandon the allocation and you destroyed the buffer/image. New place reserved at `dstTmpAllocation` will be freed, along with `srcAllocation`, which will be destroyed.
|
||||
VMA_DEFRAGMENTATION_MOVE_OPERATION_DESTROY = 2,
|
||||
} VmaDefragmentationMoveOperation;
|
||||
|
||||
@ -1425,12 +1425,13 @@ typedef struct VmaDefragmentationMove
|
||||
VmaDefragmentationMoveOperation operation;
|
||||
/// Allocation that should be moved.
|
||||
VmaAllocation VMA_NOT_NULL srcAllocation;
|
||||
/// Destination memory block where the allocation should be moved.
|
||||
VkDeviceMemory VMA_NOT_NULL_NON_DISPATCHABLE dstMemory;
|
||||
/// Destination offset where the allocation should be moved.
|
||||
VkDeviceSize dstOffset;
|
||||
/// Internal data used by VMA. Do not use or modify!
|
||||
void* VMA_NOT_NULL internalData;
|
||||
/** \brief Temporary allocation pointing to destination memory that will replace `srcAllocation`.
|
||||
|
||||
\warning Do not store this allocation in your data structures! It exists only temporarily, for the duration of the defragmentation pass,
|
||||
to be used for binding new buffer/image to the destination memory using e.g. vmaBindBufferMemory().
|
||||
vmaEndDefragmentationPass() will destroy it and make `srcAllocation` point to this memory.
|
||||
*/
|
||||
VmaAllocation VMA_NOT_NULL dstTmpAllocation;
|
||||
} VmaDefragmentationMove;
|
||||
|
||||
/** \brief Parameters for incremental defragmentation steps.
|
||||
@ -13141,13 +13142,12 @@ VkResult VmaDefragmentationContext_T::DefragmentPassEnd(VmaDefragmentationPassMo
|
||||
vector = m_pBlockVectors[vectorIndex];
|
||||
VMA_ASSERT(vector != VMA_NULL);
|
||||
}
|
||||
|
||||
VmaAllocation dst = reinterpret_cast<VmaAllocation>(move.internalData);
|
||||
|
||||
switch (move.operation)
|
||||
{
|
||||
case VMA_DEFRAGMENTATION_MOVE_OPERATION_COPY:
|
||||
{
|
||||
uint8_t mapCount = move.srcAllocation->SwapBlockAllocation(vector->m_hAllocator, dst);
|
||||
uint8_t mapCount = move.srcAllocation->SwapBlockAllocation(vector->m_hAllocator, move.dstTmpAllocation);
|
||||
if (mapCount > 0)
|
||||
{
|
||||
allocator = vector->m_hAllocator;
|
||||
@ -13170,9 +13170,9 @@ VkResult VmaDefragmentationContext_T::DefragmentPassEnd(VmaDefragmentationPassMo
|
||||
{
|
||||
VmaMutexLockRead lock(vector->GetMutex(), vector->GetAllocator()->m_UseMutex);
|
||||
prevCount = vector->GetBlockCount();
|
||||
freedBlockSize = dst->GetBlock()->m_pMetadata->GetSize();
|
||||
freedBlockSize = move.dstTmpAllocation->GetBlock()->m_pMetadata->GetSize();
|
||||
}
|
||||
vector->Free(dst, false);
|
||||
vector->Free(move.dstTmpAllocation, false);
|
||||
{
|
||||
VmaMutexLockRead lock(vector->GetMutex(), vector->GetAllocator()->m_UseMutex);
|
||||
currentCount = vector->GetBlockCount();
|
||||
@ -13185,7 +13185,7 @@ VkResult VmaDefragmentationContext_T::DefragmentPassEnd(VmaDefragmentationPassMo
|
||||
{
|
||||
m_PassStats.bytesMoved -= move.srcAllocation->GetSize();
|
||||
--m_PassStats.allocationsMoved;
|
||||
vector->Free(dst, false);
|
||||
vector->Free(move.dstTmpAllocation, false);
|
||||
|
||||
VmaDeviceMemoryBlock* newBlock = move.srcAllocation->GetBlock();
|
||||
bool notPresent = true;
|
||||
@ -13221,9 +13221,9 @@ VkResult VmaDefragmentationContext_T::DefragmentPassEnd(VmaDefragmentationPassMo
|
||||
VkDeviceSize dstBlockSize;
|
||||
{
|
||||
VmaMutexLockRead lock(vector->GetMutex(), vector->GetAllocator()->m_UseMutex);
|
||||
dstBlockSize = dst->GetBlock()->m_pMetadata->GetSize();
|
||||
dstBlockSize = move.dstTmpAllocation->GetBlock()->m_pMetadata->GetSize();
|
||||
}
|
||||
vector->Free(dst, false);
|
||||
vector->Free(move.dstTmpAllocation, false);
|
||||
{
|
||||
VmaMutexLockRead lock(vector->GetMutex(), vector->GetAllocator()->m_UseMutex);
|
||||
freedBlockSize += dstBlockSize * (currentCount - vector->GetBlockCount());
|
||||
@ -13430,8 +13430,7 @@ bool VmaDefragmentationContext_T::ReallocWithinBlock(VmaBlockVector& vector, Vma
|
||||
case CounterStatus::Pass:
|
||||
break;
|
||||
}
|
||||
VmaAllocation& dst = reinterpret_cast<VmaAllocation&>(moveData.move.internalData);
|
||||
|
||||
|
||||
VkDeviceSize offset = moveData.move.srcAllocation->GetOffset();
|
||||
if (offset != 0 && metadata->GetSumFreeSize() >= moveData.size)
|
||||
{
|
||||
@ -13453,12 +13452,9 @@ bool VmaDefragmentationContext_T::ReallocWithinBlock(VmaBlockVector& vector, Vma
|
||||
moveData.flags,
|
||||
this,
|
||||
moveData.type,
|
||||
&dst) == VK_SUCCESS)
|
||||
&moveData.move.dstTmpAllocation) == VK_SUCCESS)
|
||||
{
|
||||
moveData.move.dstMemory = dst->GetMemory();
|
||||
moveData.move.dstOffset = dst->GetOffset();
|
||||
m_Moves.push_back(moveData.move);
|
||||
|
||||
if (IncrementCounters(moveData.size))
|
||||
return true;
|
||||
}
|
||||
@ -13471,8 +13467,6 @@ bool VmaDefragmentationContext_T::ReallocWithinBlock(VmaBlockVector& vector, Vma
|
||||
|
||||
bool VmaDefragmentationContext_T::AllocInOtherBlock(size_t start, size_t end, MoveAllocationData& data, VmaBlockVector& vector)
|
||||
{
|
||||
VmaAllocation& dst = reinterpret_cast<VmaAllocation&>(data.move.internalData);
|
||||
|
||||
for (; start < end; ++start)
|
||||
{
|
||||
VmaDeviceMemoryBlock* dstBlock = vector.GetBlock(start);
|
||||
@ -13485,12 +13479,9 @@ bool VmaDefragmentationContext_T::AllocInOtherBlock(size_t start, size_t end, Mo
|
||||
this,
|
||||
data.type,
|
||||
0,
|
||||
&dst) == VK_SUCCESS)
|
||||
&data.move.dstTmpAllocation) == VK_SUCCESS)
|
||||
{
|
||||
data.move.dstMemory = dst->GetMemory();
|
||||
data.move.dstOffset = dst->GetOffset();
|
||||
m_Moves.push_back(data.move);
|
||||
|
||||
if (IncrementCounters(data.size))
|
||||
return true;
|
||||
break;
|
||||
@ -13603,7 +13594,6 @@ bool VmaDefragmentationContext_T::ComputeDefragmentation_Balanced(VmaBlockVector
|
||||
{
|
||||
if (metadata->GetAllocationOffset(request.allocHandle) < offset)
|
||||
{
|
||||
VmaAllocation& dst = reinterpret_cast<VmaAllocation&>(moveData.move.internalData);
|
||||
if (vector.CommitAllocationRequest(
|
||||
request,
|
||||
block,
|
||||
@ -13611,12 +13601,9 @@ bool VmaDefragmentationContext_T::ComputeDefragmentation_Balanced(VmaBlockVector
|
||||
moveData.flags,
|
||||
this,
|
||||
moveData.type,
|
||||
&dst) == VK_SUCCESS)
|
||||
&moveData.move.dstTmpAllocation) == VK_SUCCESS)
|
||||
{
|
||||
moveData.move.dstMemory = dst->GetMemory();
|
||||
moveData.move.dstOffset = dst->GetOffset();
|
||||
m_Moves.push_back(moveData.move);
|
||||
|
||||
if (IncrementCounters(moveData.size))
|
||||
return true;
|
||||
}
|
||||
@ -13687,7 +13674,6 @@ bool VmaDefragmentationContext_T::ComputeDefragmentation_Full(VmaBlockVector& ve
|
||||
{
|
||||
if (metadata->GetAllocationOffset(request.allocHandle) < offset)
|
||||
{
|
||||
VmaAllocation& dst = reinterpret_cast<VmaAllocation&>(moveData.move.internalData);
|
||||
if (vector.CommitAllocationRequest(
|
||||
request,
|
||||
block,
|
||||
@ -13695,12 +13681,9 @@ bool VmaDefragmentationContext_T::ComputeDefragmentation_Full(VmaBlockVector& ve
|
||||
moveData.flags,
|
||||
this,
|
||||
moveData.type,
|
||||
&dst) == VK_SUCCESS)
|
||||
&moveData.move.dstTmpAllocation) == VK_SUCCESS)
|
||||
{
|
||||
moveData.move.dstMemory = dst->GetMemory();
|
||||
moveData.move.dstOffset = dst->GetOffset();
|
||||
m_Moves.push_back(moveData.move);
|
||||
|
||||
if (IncrementCounters(moveData.size))
|
||||
return true;
|
||||
}
|
||||
@ -18282,7 +18265,7 @@ for(;;)
|
||||
VkImage newImg;
|
||||
res = vkCreateImage(device, &imgCreateInfo, nullptr, &newImg);
|
||||
// Check res...
|
||||
res = vKBindImageMemory(device, newImg, pass.pMoves[i].dstMemory, pass.pMoves[i].dstOffset);
|
||||
res = vmaBindImageMemory(allocator, pMoves[i].dstTmpAllocation, newImg);
|
||||
// Check res...
|
||||
|
||||
// Issue a vkCmdCopyBuffer/vkCmdCopyImage to copy its content to the new place.
|
||||
@ -18322,16 +18305,16 @@ In each pass:
|
||||
1. vmaBeginDefragmentationPass() function call:
|
||||
- Calculates and returns the list of allocations to be moved in this pass.
|
||||
Note this can be a time-consuming process.
|
||||
- Reserves destination memory for them by creating internal allocations.
|
||||
Returns their `VkDeviceMemory` + offset.
|
||||
- Reserves destination memory for them by creating temporary destination allocations
|
||||
that you can query for their `VkDeviceMemory` + offset using vmaGetAllocationInfo().
|
||||
2. Inside the pass, **you should**:
|
||||
- Inspect the returned list of allocations to be moved.
|
||||
- Create new buffers/images and bind them at the returned destination `VkDeviceMemory` + offset.
|
||||
- Create new buffers/images and bind them at the returned destination temporary allocations.
|
||||
- Copy data from source to destination resources if necessary.
|
||||
- Destroy the source buffers/images, but NOT their allocations.
|
||||
3. vmaEndDefragmentationPass() function call:
|
||||
- Frees the source memory reserved for the allocations that are moved.
|
||||
- Modifies #VmaAllocation objects that are moved to point to the destination reserved memory.
|
||||
- Modifies source #VmaAllocation objects that are moved to point to the destination reserved memory.
|
||||
- Frees `VkDeviceMemory` blocks that became empty.
|
||||
|
||||
Unlike in previous iterations of the defragmentation API, there is no list of "movable" allocations passed as a parameter.
|
||||
@ -18356,7 +18339,7 @@ Inside a pass, for each allocation that should be moved:
|
||||
not the source memory of the allocation, leaving it unchanged.
|
||||
- If you decide the allocation is unimportant and can be destroyed instead of moved (e.g. it wasn't used for long time),
|
||||
you can set `pass.pMoves[i].operation` to #VMA_DEFRAGMENTATION_MOVE_OPERATION_DESTROY.
|
||||
- vmaEndDefragmentationPass() will then free both source and destination memory, and will destroy the #VmaAllocation object.
|
||||
- vmaEndDefragmentationPass() will then free both source and destination memory, and will destroy the source #VmaAllocation object.
|
||||
|
||||
You can defragment a specific custom pool by setting VmaDefragmentationInfo::pool
|
||||
(like in the example above) or all the default pools by setting this member to null.
|
||||
|
@ -1442,7 +1442,7 @@ static void ProcessDefragmentationPass(VmaDefragmentationPassMoveInfo& stepInfo)
|
||||
const VkResult result = vkCreateImage(g_hDevice, &allocInfo->m_ImageInfo, g_Allocs, &newImage);
|
||||
TEST(result >= VK_SUCCESS);
|
||||
|
||||
vkBindImageMemory(g_hDevice, newImage, stepInfo.pMoves[i].dstMemory, stepInfo.pMoves[i].dstOffset);
|
||||
vmaBindImageMemory(g_hAllocator, stepInfo.pMoves[i].dstTmpAllocation, newImage);
|
||||
allocInfo->m_NewImage = newImage;
|
||||
|
||||
// Keep track of our pipeline stages that we need to wait/signal on
|
||||
@ -1496,7 +1496,7 @@ static void ProcessDefragmentationPass(VmaDefragmentationPassMoveInfo& stepInfo)
|
||||
const VkResult result = vkCreateBuffer(g_hDevice, &allocInfo->m_BufferInfo, g_Allocs, &newBuffer);
|
||||
TEST(result >= VK_SUCCESS);
|
||||
|
||||
vkBindBufferMemory(g_hDevice, newBuffer, stepInfo.pMoves[i].dstMemory, stepInfo.pMoves[i].dstOffset);
|
||||
vmaBindBufferMemory(g_hAllocator, stepInfo.pMoves[i].dstTmpAllocation, newBuffer);
|
||||
allocInfo->m_NewBuffer = newBuffer;
|
||||
|
||||
// Keep track of our pipeline stages that we need to wait/signal on
|
||||
|
Loading…
Reference in New Issue
Block a user