diff --git a/docs/html/defragmentation.html b/docs/html/defragmentation.html index 5c9a878..e63de25 100644 --- a/docs/html/defragmentation.html +++ b/docs/html/defragmentation.html @@ -70,7 +70,7 @@ $(function() {

Interleaved allocations and deallocations of many objects of varying size can cause fragmentation over time, which can lead to a situation where the library is unable to find a continuous range of free memory for a new allocation despite there is enough free space, just scattered across many small free ranges between existing allocations.

-

To mitigate this problem, you can use defragmentation feature. It doesn't happen automatically thought and needs your cooperation, because VMA is a low level library that only allocates memory. It cannot recreate buffers and images in a new place as it doesn't remember the contents of VkBufferCreateInfo / VkImageCreateInfo structures. It cannot copy their contents as it doesn't record any commands to a command buffer.

+

To mitigate this problem, you can use defragmentation feature. It doesn't happen automatically though and needs your cooperation, because VMA is a low level library that only allocates memory. It cannot recreate buffers and images in a new place as it doesn't remember the contents of VkBufferCreateInfo / VkImageCreateInfo structures. It cannot copy their contents as it doesn't record any commands to a command buffer.

Example:

VmaDefragmentationInfo defragInfo = {};
defragInfo.pool = myPool;
@@ -96,7 +96,11 @@ $(function() {
}
//- Make sure the copy commands finished executing.
//- Update appropriate descriptors to point to the new places.
-
vmaEndDefragmentationPass(allocator, defragCtx, &pass);
+
res = vmaEndDefragmentationPass(allocator, defragCtx, &pass);
+
if(res == VK_SUCCESS)
+
break;
+
else if(res != VK_INCOMPLETE)
+
// Handle error...
}
else
// Handle error...
diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h index af82f3b..48e61d3 100644 --- a/include/vk_mem_alloc.h +++ b/include/vk_mem_alloc.h @@ -17939,7 +17939,7 @@ enough free space, just scattered across many small free ranges between existing allocations. To mitigate this problem, you can use defragmentation feature. -It doesn't happen automatically thought and needs your cooperation, +It doesn't happen automatically though and needs your cooperation, because VMA is a low level library that only allocates memory. It cannot recreate buffers and images in a new place as it doesn't remember the contents of `VkBufferCreateInfo` / `VkImageCreateInfo` structures. It cannot copy their contents as it doesn't record any commands to a command buffer. @@ -17971,7 +17971,11 @@ for(;;) } //- Make sure the copy commands finished executing. //- Update appropriate descriptors to point to the new places. - vmaEndDefragmentationPass(allocator, defragCtx, &pass); + res = vmaEndDefragmentationPass(allocator, defragCtx, &pass); + if(res == VK_SUCCESS) + break; + else if(res != VK_INCOMPLETE) + // Handle error... } else // Handle error...