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

Method MoveDataToFreeBlocks

include/vk_mem_alloc.h:12876–12923  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12874}
12875
12876bool VmaDefragmentationContext_T::MoveDataToFreeBlocks(VmaSuballocationType currentType,
12877 VmaBlockVector& vector, size_t firstFreeBlock,
12878 bool& texturePresent, bool& bufferPresent, bool& otherPresent)
12879{
12880 const size_t prevMoveCount = m_Moves.size();
12881 for (size_t i = firstFreeBlock ; i;)
12882 {
12883 VmaDeviceMemoryBlock* block = vector.GetBlock(--i);
12884 VmaBlockMetadata* metadata = block->m_pMetadata;
12885
12886 for (VmaAllocHandle handle = metadata->GetAllocationListBegin();
12887 handle != VK_NULL_HANDLE;
12888 handle = metadata->GetNextAllocation(handle))
12889 {
12890 MoveAllocationData moveData = GetMoveData(handle, metadata);
12891 // Ignore newly created allocations by defragmentation algorithm
12892 if (moveData.move.srcAllocation->GetUserData() == this)
12893 continue;
12894 switch (CheckCounters(moveData.move.srcAllocation->GetSize()))
12895 {
12896 case CounterStatus::Ignore:
12897 continue;
12898 case CounterStatus::End:
12899 return true;
12900 case CounterStatus::Pass:
12901 break;
12902 default:
12903 VMA_ASSERT(0);
12904 }
12905
12906 // Move only single type of resources at once
12907 if (!VmaIsBufferImageGranularityConflict(moveData.type, currentType))
12908 {
12909 // Try to fit allocation into free blocks
12910 if (AllocInOtherBlock(firstFreeBlock, vector.GetBlockCount(), moveData, vector))
12911 return false;
12912 }
12913
12914 if (!VmaIsBufferImageGranularityConflict(moveData.type, VMA_SUBALLOCATION_TYPE_IMAGE_OPTIMAL))
12915 texturePresent = true;
12916 else if (!VmaIsBufferImageGranularityConflict(moveData.type, VMA_SUBALLOCATION_TYPE_BUFFER))
12917 bufferPresent = true;
12918 else
12919 otherPresent = true;
12920 }
12921 }
12922 return prevMoveCount == m_Moves.size();
12923}
12924#endif // _VMA_DEFRAGMENTATION_CONTEXT_FUNCTIONS
12925
12926#ifndef _VMA_POOL_T_FUNCTIONS

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected