| 12375 | } |
| 12376 | |
| 12377 | bool VmaDefragmentationContext_T::ReallocWithinBlock(VmaBlockVector& vector, VmaDeviceMemoryBlock* block) |
| 12378 | { |
| 12379 | VmaBlockMetadata* metadata = block->m_pMetadata; |
| 12380 | |
| 12381 | for (VmaAllocHandle handle = metadata->GetAllocationListBegin(); |
| 12382 | handle != VK_NULL_HANDLE; |
| 12383 | handle = metadata->GetNextAllocation(handle)) |
| 12384 | { |
| 12385 | MoveAllocationData moveData = GetMoveData(handle, metadata); |
| 12386 | // Ignore newly created allocations by defragmentation algorithm |
| 12387 | if (moveData.move.srcAllocation->GetUserData() == this) |
| 12388 | continue; |
| 12389 | switch (CheckCounters(moveData.move.srcAllocation->GetSize())) |
| 12390 | { |
| 12391 | case CounterStatus::Ignore: |
| 12392 | continue; |
| 12393 | case CounterStatus::End: |
| 12394 | return true; |
| 12395 | case CounterStatus::Pass: |
| 12396 | break; |
| 12397 | default: |
| 12398 | VMA_ASSERT(0); |
| 12399 | } |
| 12400 | |
| 12401 | VkDeviceSize offset = moveData.move.srcAllocation->GetOffset(); |
| 12402 | if (offset != 0 && metadata->GetSumFreeSize() >= moveData.size) |
| 12403 | { |
| 12404 | VmaAllocationRequest request = {}; |
| 12405 | if (metadata->CreateAllocationRequest( |
| 12406 | moveData.size, |
| 12407 | moveData.alignment, |
| 12408 | false, |
| 12409 | moveData.type, |
| 12410 | VMA_ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT, |
| 12411 | &request)) |
| 12412 | { |
| 12413 | if (metadata->GetAllocationOffset(request.allocHandle) < offset) |
| 12414 | { |
| 12415 | if (vector.CommitAllocationRequest( |
| 12416 | request, |
| 12417 | block, |
| 12418 | moveData.alignment, |
| 12419 | moveData.flags, |
| 12420 | this, |
| 12421 | moveData.type, |
| 12422 | &moveData.move.dstTmpAllocation) == VK_SUCCESS) |
| 12423 | { |
| 12424 | m_Moves.push_back(moveData.move); |
| 12425 | if (IncrementCounters(moveData.size)) |
| 12426 | return true; |
| 12427 | } |
| 12428 | } |
| 12429 | } |
| 12430 | } |
| 12431 | } |
| 12432 | return false; |
| 12433 | } |
| 12434 |
nothing calls this directly
no test coverage detected