MCPcopy Create free account
hub / github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator / ReallocWithinBlock

Method ReallocWithinBlock

include/vk_mem_alloc.h:12714–12770  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12712}
12713
12714bool VmaDefragmentationContext_T::ReallocWithinBlock(VmaBlockVector& vector, VmaDeviceMemoryBlock* block)
12715{
12716 VmaBlockMetadata* metadata = block->m_pMetadata;
12717
12718 for (VmaAllocHandle handle = metadata->GetAllocationListBegin();
12719 handle != VK_NULL_HANDLE;
12720 handle = metadata->GetNextAllocation(handle))
12721 {
12722 MoveAllocationData moveData = GetMoveData(handle, metadata);
12723 // Ignore newly created allocations by defragmentation algorithm
12724 if (moveData.move.srcAllocation->GetUserData() == this)
12725 continue;
12726 switch (CheckCounters(moveData.move.srcAllocation->GetSize()))
12727 {
12728 case CounterStatus::Ignore:
12729 continue;
12730 case CounterStatus::End:
12731 return true;
12732 case CounterStatus::Pass:
12733 break;
12734 default:
12735 VMA_ASSERT(0);
12736 }
12737
12738 VkDeviceSize offset = moveData.move.srcAllocation->GetOffset();
12739 if (offset != 0 && metadata->GetSumFreeSize() >= moveData.size)
12740 {
12741 VmaAllocationRequest request = {};
12742 if (metadata->CreateAllocationRequest(
12743 moveData.size,
12744 moveData.alignment,
12745 false,
12746 moveData.type,
12747 VMA_ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT,
12748 &request))
12749 {
12750 if (metadata->GetAllocationOffset(request.allocHandle) < offset)
12751 {
12752 if (vector.CommitAllocationRequest(
12753 request,
12754 block,
12755 moveData.alignment,
12756 moveData.flags,
12757 this,
12758 moveData.type,
12759 &moveData.move.dstTmpAllocation) == VK_SUCCESS)
12760 {
12761 m_Moves.push_back(moveData.move);
12762 if (IncrementCounters(moveData.size))
12763 return true;
12764 }
12765 }
12766 }
12767 }
12768 }
12769 return false;
12770}
12771

Callers

nothing calls this directly

Calls 10

GetNextAllocationMethod · 0.80
GetUserDataMethod · 0.80
GetOffsetMethod · 0.80
GetSizeMethod · 0.45
GetSumFreeSizeMethod · 0.45
GetAllocationOffsetMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected