diff --git a/docs/html/defragmentation.html b/docs/html/defragmentation.html index 221e9e2..0bf30ee 100644 --- a/docs/html/defragmentation.html +++ b/docs/html/defragmentation.html @@ -106,7 +106,16 @@ Additional notes

While using defragmentation, you may experience validation layer warnings, which you just need to ignore. See Validation layer warnings.

If you defragment allocations bound to images, these images should be created with VK_IMAGE_CREATE_ALIAS_BIT flag, to make sure that new image created with same parameters and pointing to data copied to another memory region will interpret its contents consistently. Otherwise you may experience corrupted data on some implementations, e.g. due to different pixel swizzling used internally by the graphics driver.

If you defragment allocations bound to images, new images to be bound to new memory region after defragmentation should be created with VK_IMAGE_LAYOUT_PREINITIALIZED and then transitioned to their original layout from before defragmentation using an image memory barrier.

-

Please don't expect memory to be fully compacted after defragmentation. Algorithms inside are based on some heuristics that try to maximize number of Vulkan memory blocks to make totally empty to release them, as well as to maximimze continuous empty space inside remaining blocks, while minimizing the number and size of allocations that needs to be moved. Some fragmentation may still remain after this call. This is normal.

+

Please don't expect memory to be fully compacted after defragmentation. Algorithms inside are based on some heuristics that try to maximize number of Vulkan memory blocks to make totally empty to release them, as well as to maximimze continuous empty space inside remaining blocks, while minimizing the number and size of allocations that need to be moved. Some fragmentation may still remain - this is normal.

+

+Writing custom defragmentation algorithm

+

If you want to implement your own, custom defragmentation algorithm, there is infrastructure prepared for that, but it is not exposed through the library API - you need to hack its source code. Here are steps needed to do this:

+
    +
  1. Main thing you need to do is to define your own class derived from base abstract class VmaDefragmentationAlgorithm and implement your version of its pure virtual method. See definition and comments of this class for details.
  2. +
  3. Your code needs to interact with device memory block metadata. If you need more access to its data than it's provided by its public interface, declare your new class as a friend class e.g. in class VmaBlockMetadata_Generic.
  4. +
  5. If you want to create a flag that would enable your algorithm or pass some additional flags to configure it, define some enum with such flags and use them in VmaDefragmentationInfo2::flags.
  6. +
  7. Modify function VmaBlockVectorDefragmentationContext::Begin to create object of your new class whenever needed.
  8. +