Small refactoring: Removed function VmaBlockVector::DestroyDefragmentator.

This commit is contained in:
Adam Sawicki 2018-10-10 16:49:36 +02:00
parent f863a1dbd0
commit 6826f2d768

View file

@ -5519,13 +5519,12 @@ public:
VmaAllocator hAllocator,
uint32_t currentFrameIndex);
// If m_pDefragmentator is not null, uses it to defragment and destroys it.
VkResult Defragment(
VmaDefragmentationStats* pDefragmentationStats,
VkDeviceSize& maxBytesToMove,
uint32_t& maxAllocationsToMove);
void DestroyDefragmentator();
private:
friend class VmaDefragmentationAlgorithm;
friend class VmaDefragmentator;
@ -11157,6 +11156,8 @@ VkResult VmaBlockVector::Defragment(
}
// Free empty blocks.
if(result >= 0)
{
m_HasEmptyBlock = false;
for(size_t blockIndex = m_Blocks.size(); blockIndex--; )
{
@ -11181,17 +11182,13 @@ VkResult VmaBlockVector::Defragment(
}
}
}
return result;
}
void VmaBlockVector::DestroyDefragmentator()
{
if(m_pDefragmentator != VMA_NULL)
{
// Destroy defragmentator.
vma_delete(m_hAllocator, m_pDefragmentator);
m_pDefragmentator = VMA_NULL;
}
return result;
}
void VmaBlockVector::MakePoolAllocationsLost(
@ -12898,7 +12895,7 @@ VkResult VmaAllocator_T::DefragmentationBegin(
VkResult result = VK_SUCCESS;
// ======== Main processing - call Defragment on block vectors.
// Main processing: Call Defragment on block vectors.
VkDeviceSize maxBytesToMove = info.maxCpuBytesToMove;
uint32_t maxAllocationsToMove = info.maxCpuAllocationsToMove;
@ -12927,23 +12924,6 @@ VkResult VmaAllocator_T::DefragmentationBegin(
maxAllocationsToMove);
}
// ======== Destroy defragmentators (regardless of result).
// Process custom pools.
for(size_t poolIndex = poolCount; poolIndex--; )
{
m_Pools[poolIndex]->m_BlockVector.DestroyDefragmentator();
}
// Process standard memory.
for(uint32_t memTypeIndex = GetMemoryTypeCount(); memTypeIndex--; )
{
if((m_MemProps.memoryTypes[memTypeIndex].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0)
{
m_pBlockVectors[memTypeIndex]->DestroyDefragmentator();
}
}
return result;
}