| 13211 | } |
| 13212 | |
| 13213 | bool VmaDefragmentationContext_T::MoveDataToFreeBlocks(VmaSuballocationType currentType, |
| 13214 | VmaBlockVector& vector, size_t firstFreeBlock, |
| 13215 | bool& texturePresent, bool& bufferPresent, bool& otherPresent) |
| 13216 | { |
| 13217 | const size_t prevMoveCount = m_Moves.size(); |
| 13218 | for (size_t i = firstFreeBlock ; i;) |
| 13219 | { |
| 13220 | VmaDeviceMemoryBlock* block = vector.GetBlock(--i); |
| 13221 | VmaBlockMetadata* metadata = block->m_pMetadata; |
| 13222 | |
| 13223 | for (VmaAllocHandle handle = metadata->GetAllocationListBegin(); |
| 13224 | handle != VK_NULL_HANDLE; |
| 13225 | handle = metadata->GetNextAllocation(handle)) |
| 13226 | { |
| 13227 | MoveAllocationData moveData = GetMoveData(handle, metadata); |
| 13228 | // Ignore newly created allocations by defragmentation algorithm |
| 13229 | if (moveData.move.srcAllocation->GetUserData() == this) |
| 13230 | continue; |
| 13231 | switch (CheckCounters(moveData.move.srcAllocation->GetSize())) |
| 13232 | { |
| 13233 | case CounterStatus::Ignore: |
| 13234 | continue; |
| 13235 | case CounterStatus::End: |
| 13236 | return true; |
| 13237 | case CounterStatus::Pass: |
| 13238 | break; |
| 13239 | default: |
| 13240 | VMA_ASSERT(0); |
| 13241 | } |
| 13242 | |
| 13243 | // Move only single type of resources at once |
| 13244 | if (!VmaIsBufferImageGranularityConflict(moveData.type, currentType)) |
| 13245 | { |
| 13246 | // Try to fit allocation into free blocks |
| 13247 | if (AllocInOtherBlock(firstFreeBlock, vector.GetBlockCount(), moveData, vector)) |
| 13248 | return false; |
| 13249 | } |
| 13250 | |
| 13251 | if (!VmaIsBufferImageGranularityConflict(moveData.type, VMA_SUBALLOCATION_TYPE_IMAGE_OPTIMAL)) |
| 13252 | texturePresent = true; |
| 13253 | else if (!VmaIsBufferImageGranularityConflict(moveData.type, VMA_SUBALLOCATION_TYPE_BUFFER)) |
| 13254 | bufferPresent = true; |
| 13255 | else |
| 13256 | otherPresent = true; |
| 13257 | } |
| 13258 | } |
| 13259 | return prevMoveCount == m_Moves.size(); |
| 13260 | } |
| 13261 | #endif // _VMA_DEFRAGMENTATION_CONTEXT_FUNCTIONS |
| 13262 | |
| 13263 | #ifndef _VMA_POOL_T_FUNCTIONS |
nothing calls this directly
no test coverage detected