mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
synced 2024-11-05 12:20:07 +00:00
parent
85a2580529
commit
14469a5eea
@ -11229,14 +11229,15 @@ VmaVirtualBlock_T::VmaVirtualBlock_T(const VmaVirtualBlockCreateInfo& createInfo
|
|||||||
const uint32_t algorithm = createInfo.flags & VMA_VIRTUAL_BLOCK_CREATE_ALGORITHM_MASK;
|
const uint32_t algorithm = createInfo.flags & VMA_VIRTUAL_BLOCK_CREATE_ALGORITHM_MASK;
|
||||||
switch (algorithm)
|
switch (algorithm)
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
VMA_ASSERT(0);
|
|
||||||
case 0:
|
case 0:
|
||||||
m_Metadata = vma_new(GetAllocationCallbacks(), VmaBlockMetadata_TLSF)(VK_NULL_HANDLE, 1, true);
|
m_Metadata = vma_new(GetAllocationCallbacks(), VmaBlockMetadata_TLSF)(VK_NULL_HANDLE, 1, true);
|
||||||
break;
|
break;
|
||||||
case VMA_VIRTUAL_BLOCK_CREATE_LINEAR_ALGORITHM_BIT:
|
case VMA_VIRTUAL_BLOCK_CREATE_LINEAR_ALGORITHM_BIT:
|
||||||
m_Metadata = vma_new(GetAllocationCallbacks(), VmaBlockMetadata_Linear)(VK_NULL_HANDLE, 1, true);
|
m_Metadata = vma_new(GetAllocationCallbacks(), VmaBlockMetadata_Linear)(VK_NULL_HANDLE, 1, true);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
VMA_ASSERT(0);
|
||||||
|
m_Metadata = vma_new(GetAllocationCallbacks(), VmaBlockMetadata_TLSF)(VK_NULL_HANDLE, 1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Metadata->Init(createInfo.size);
|
m_Metadata->Init(createInfo.size);
|
||||||
@ -11720,14 +11721,16 @@ void VmaDeviceMemoryBlock::Init(
|
|||||||
|
|
||||||
switch (algorithm)
|
switch (algorithm)
|
||||||
{
|
{
|
||||||
|
case 0:
|
||||||
|
m_pMetadata = vma_new(hAllocator, VmaBlockMetadata_TLSF)(hAllocator->GetAllocationCallbacks(),
|
||||||
|
bufferImageGranularity, false); // isVirtual
|
||||||
|
break;
|
||||||
case VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT:
|
case VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT:
|
||||||
m_pMetadata = vma_new(hAllocator, VmaBlockMetadata_Linear)(hAllocator->GetAllocationCallbacks(),
|
m_pMetadata = vma_new(hAllocator, VmaBlockMetadata_Linear)(hAllocator->GetAllocationCallbacks(),
|
||||||
bufferImageGranularity, false); // isVirtual
|
bufferImageGranularity, false); // isVirtual
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
VMA_ASSERT(0);
|
VMA_ASSERT(0);
|
||||||
// Fall-through.
|
|
||||||
case 0:
|
|
||||||
m_pMetadata = vma_new(hAllocator, VmaBlockMetadata_TLSF)(hAllocator->GetAllocationCallbacks(),
|
m_pMetadata = vma_new(hAllocator, VmaBlockMetadata_TLSF)(hAllocator->GetAllocationCallbacks(),
|
||||||
bufferImageGranularity, false); // isVirtual
|
bufferImageGranularity, false); // isVirtual
|
||||||
}
|
}
|
||||||
@ -12973,13 +12976,12 @@ VmaDefragmentationContext_T::VmaDefragmentationContext_T(
|
|||||||
{
|
{
|
||||||
case 0: // Default algorithm
|
case 0: // Default algorithm
|
||||||
m_Algorithm = VMA_DEFRAGMENTATION_FLAG_ALGORITHM_BALANCED_BIT;
|
m_Algorithm = VMA_DEFRAGMENTATION_FLAG_ALGORITHM_BALANCED_BIT;
|
||||||
case VMA_DEFRAGMENTATION_FLAG_ALGORITHM_BALANCED_BIT:
|
|
||||||
{
|
|
||||||
m_AlgorithmState = vma_new_array(hAllocator, StateBalanced, m_BlockVectorCount);
|
m_AlgorithmState = vma_new_array(hAllocator, StateBalanced, m_BlockVectorCount);
|
||||||
break;
|
break;
|
||||||
}
|
case VMA_DEFRAGMENTATION_FLAG_ALGORITHM_BALANCED_BIT:
|
||||||
|
m_AlgorithmState = vma_new_array(hAllocator, StateBalanced, m_BlockVectorCount);
|
||||||
|
break;
|
||||||
case VMA_DEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT:
|
case VMA_DEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT:
|
||||||
{
|
|
||||||
if (hAllocator->GetBufferImageGranularity() > 1)
|
if (hAllocator->GetBufferImageGranularity() > 1)
|
||||||
{
|
{
|
||||||
m_AlgorithmState = vma_new_array(hAllocator, StateExtensive, m_BlockVectorCount);
|
m_AlgorithmState = vma_new_array(hAllocator, StateExtensive, m_BlockVectorCount);
|
||||||
@ -12987,7 +12989,6 @@ VmaDefragmentationContext_T::VmaDefragmentationContext_T(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
VmaDefragmentationContext_T::~VmaDefragmentationContext_T()
|
VmaDefragmentationContext_T::~VmaDefragmentationContext_T()
|
||||||
{
|
{
|
||||||
@ -13234,9 +13235,9 @@ VkResult VmaDefragmentationContext_T::DefragmentPassEnd(VmaDefragmentationPassMo
|
|||||||
// Move blocks with immovable allocations according to algorithm
|
// Move blocks with immovable allocations according to algorithm
|
||||||
if (immovableBlocks.size() > 0)
|
if (immovableBlocks.size() > 0)
|
||||||
{
|
{
|
||||||
switch (m_Algorithm)
|
do
|
||||||
{
|
{
|
||||||
case VMA_DEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT:
|
if(m_Algorithm == VMA_DEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT)
|
||||||
{
|
{
|
||||||
if (m_AlgorithmState != VMA_NULL)
|
if (m_AlgorithmState != VMA_NULL)
|
||||||
{
|
{
|
||||||
@ -13276,8 +13277,7 @@ VkResult VmaDefragmentationContext_T::DefragmentPassEnd(VmaDefragmentationPassMo
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
{
|
|
||||||
// Move to the beginning
|
// Move to the beginning
|
||||||
for (const FragmentedBlock& block : immovableBlocks)
|
for (const FragmentedBlock& block : immovableBlocks)
|
||||||
{
|
{
|
||||||
@ -13293,9 +13293,7 @@ VkResult VmaDefragmentationContext_T::DefragmentPassEnd(VmaDefragmentationPassMo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
} while (false);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bulk-map destination blocks
|
// Bulk-map destination blocks
|
||||||
@ -13313,14 +13311,15 @@ bool VmaDefragmentationContext_T::ComputeDefragmentation(VmaBlockVector& vector,
|
|||||||
{
|
{
|
||||||
case VMA_DEFRAGMENTATION_FLAG_ALGORITHM_FAST_BIT:
|
case VMA_DEFRAGMENTATION_FLAG_ALGORITHM_FAST_BIT:
|
||||||
return ComputeDefragmentation_Fast(vector);
|
return ComputeDefragmentation_Fast(vector);
|
||||||
default:
|
|
||||||
VMA_ASSERT(0);
|
|
||||||
case VMA_DEFRAGMENTATION_FLAG_ALGORITHM_BALANCED_BIT:
|
case VMA_DEFRAGMENTATION_FLAG_ALGORITHM_BALANCED_BIT:
|
||||||
return ComputeDefragmentation_Balanced(vector, index, true);
|
return ComputeDefragmentation_Balanced(vector, index, true);
|
||||||
case VMA_DEFRAGMENTATION_FLAG_ALGORITHM_FULL_BIT:
|
case VMA_DEFRAGMENTATION_FLAG_ALGORITHM_FULL_BIT:
|
||||||
return ComputeDefragmentation_Full(vector);
|
return ComputeDefragmentation_Full(vector);
|
||||||
case VMA_DEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT:
|
case VMA_DEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT:
|
||||||
return ComputeDefragmentation_Extensive(vector, index);
|
return ComputeDefragmentation_Extensive(vector, index);
|
||||||
|
default:
|
||||||
|
VMA_ASSERT(0);
|
||||||
|
return ComputeDefragmentation_Balanced(vector, index, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13386,10 +13385,10 @@ bool VmaDefragmentationContext_T::ReallocWithinBlock(VmaBlockVector& vector, Vma
|
|||||||
continue;
|
continue;
|
||||||
case CounterStatus::End:
|
case CounterStatus::End:
|
||||||
return true;
|
return true;
|
||||||
default:
|
|
||||||
VMA_ASSERT(0);
|
|
||||||
case CounterStatus::Pass:
|
case CounterStatus::Pass:
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
VMA_ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkDeviceSize offset = moveData.move.srcAllocation->GetOffset();
|
VkDeviceSize offset = moveData.move.srcAllocation->GetOffset();
|
||||||
@ -13475,10 +13474,10 @@ bool VmaDefragmentationContext_T::ComputeDefragmentation_Fast(VmaBlockVector& ve
|
|||||||
continue;
|
continue;
|
||||||
case CounterStatus::End:
|
case CounterStatus::End:
|
||||||
return true;
|
return true;
|
||||||
default:
|
|
||||||
VMA_ASSERT(0);
|
|
||||||
case CounterStatus::Pass:
|
case CounterStatus::Pass:
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
VMA_ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check all previous blocks for free space
|
// Check all previous blocks for free space
|
||||||
@ -13522,10 +13521,10 @@ bool VmaDefragmentationContext_T::ComputeDefragmentation_Balanced(VmaBlockVector
|
|||||||
continue;
|
continue;
|
||||||
case CounterStatus::End:
|
case CounterStatus::End:
|
||||||
return true;
|
return true;
|
||||||
default:
|
|
||||||
VMA_ASSERT(0);
|
|
||||||
case CounterStatus::Pass:
|
case CounterStatus::Pass:
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
VMA_ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check all previous blocks for free space
|
// Check all previous blocks for free space
|
||||||
@ -13609,10 +13608,10 @@ bool VmaDefragmentationContext_T::ComputeDefragmentation_Full(VmaBlockVector& ve
|
|||||||
continue;
|
continue;
|
||||||
case CounterStatus::End:
|
case CounterStatus::End:
|
||||||
return true;
|
return true;
|
||||||
default:
|
|
||||||
VMA_ASSERT(0);
|
|
||||||
case CounterStatus::Pass:
|
case CounterStatus::Pass:
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
VMA_ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check all previous blocks for free space
|
// Check all previous blocks for free space
|
||||||
@ -13700,10 +13699,10 @@ bool VmaDefragmentationContext_T::ComputeDefragmentation_Extensive(VmaBlockVecto
|
|||||||
continue;
|
continue;
|
||||||
case CounterStatus::End:
|
case CounterStatus::End:
|
||||||
return true;
|
return true;
|
||||||
default:
|
|
||||||
VMA_ASSERT(0);
|
|
||||||
case CounterStatus::Pass:
|
case CounterStatus::Pass:
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
VMA_ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check all previous blocks for free space
|
// Check all previous blocks for free space
|
||||||
@ -13741,14 +13740,15 @@ bool VmaDefragmentationContext_T::ComputeDefragmentation_Extensive(VmaBlockVecto
|
|||||||
case StateExtensive::Operation::FindFreeBlockBuffer:
|
case StateExtensive::Operation::FindFreeBlockBuffer:
|
||||||
vectorState.operation = StateExtensive::Operation::MoveBuffers;
|
vectorState.operation = StateExtensive::Operation::MoveBuffers;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
VMA_ASSERT(0);
|
|
||||||
case StateExtensive::Operation::FindFreeBlockTexture:
|
case StateExtensive::Operation::FindFreeBlockTexture:
|
||||||
vectorState.operation = StateExtensive::Operation::MoveTextures;
|
vectorState.operation = StateExtensive::Operation::MoveTextures;
|
||||||
break;
|
break;
|
||||||
case StateExtensive::Operation::FindFreeBlockAll:
|
case StateExtensive::Operation::FindFreeBlockAll:
|
||||||
vectorState.operation = StateExtensive::Operation::MoveAll;
|
vectorState.operation = StateExtensive::Operation::MoveAll;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
VMA_ASSERT(0);
|
||||||
|
vectorState.operation = StateExtensive::Operation::MoveTextures;
|
||||||
}
|
}
|
||||||
vectorState.firstFreeBlock = last;
|
vectorState.firstFreeBlock = last;
|
||||||
// Nothing done, block found without reallocations, can perform another reallocs in same pass
|
// Nothing done, block found without reallocations, can perform another reallocs in same pass
|
||||||
@ -13886,10 +13886,10 @@ bool VmaDefragmentationContext_T::MoveDataToFreeBlocks(VmaSuballocationType curr
|
|||||||
continue;
|
continue;
|
||||||
case CounterStatus::End:
|
case CounterStatus::End:
|
||||||
return true;
|
return true;
|
||||||
default:
|
|
||||||
VMA_ASSERT(0);
|
|
||||||
case CounterStatus::Pass:
|
case CounterStatus::Pass:
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
VMA_ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move only single type of resources at once
|
// Move only single type of resources at once
|
||||||
|
Loading…
Reference in New Issue
Block a user