MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / ComputeDefragmentation_Fast

Method ComputeDefragmentation_Fast

include/vk_mem_alloc.h:12461–12496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12459}
12460
12461bool VmaDefragmentationContext_T::ComputeDefragmentation_Fast(VmaBlockVector& vector)
12462{
12463 // Move only between blocks
12464
12465 // Go through allocations in last blocks and try to fit them inside first ones
12466 for (size_t i = vector.GetBlockCount() - 1; i > m_ImmovableBlockCount; --i)
12467 {
12468 VmaBlockMetadata* metadata = vector.GetBlock(i)->m_pMetadata;
12469
12470 for (VmaAllocHandle handle = metadata->GetAllocationListBegin();
12471 handle != VK_NULL_HANDLE;
12472 handle = metadata->GetNextAllocation(handle))
12473 {
12474 MoveAllocationData moveData = GetMoveData(handle, metadata);
12475 // Ignore newly created allocations by defragmentation algorithm
12476 if (moveData.move.srcAllocation->GetUserData() == this)
12477 continue;
12478 switch (CheckCounters(moveData.move.srcAllocation->GetSize()))
12479 {
12480 case CounterStatus::Ignore:
12481 continue;
12482 case CounterStatus::End:
12483 return true;
12484 case CounterStatus::Pass:
12485 break;
12486 default:
12487 VMA_ASSERT(0);
12488 }
12489
12490 // Check all previous blocks for free space
12491 if (AllocInOtherBlock(0, i, moveData, vector))
12492 return true;
12493 }
12494 }
12495 return false;
12496}
12497
12498bool VmaDefragmentationContext_T::ComputeDefragmentation_Balanced(VmaBlockVector& vector, size_t index, bool update)
12499{

Callers

nothing calls this directly

Calls 6

GetBlockCountMethod · 0.80
GetNextAllocationMethod · 0.80
GetUserDataMethod · 0.80
GetBlockMethod · 0.45
GetSizeMethod · 0.45

Tested by

no test coverage detected