mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2025-05-14 16:58:34 +00:00
Remove redundant if:
currentBlock and prevPhysical block can't be free at the same time at this moment.
This commit is contained in:
parent
72c309a83b
commit
4ad5e3b4c1
1 changed files with 10 additions and 29 deletions
|
@ -9318,29 +9318,12 @@ void VmaBlockMetadata_TLSF::Alloc(
|
|||
VkDeviceSize debugMargin = GetDebugMargin();
|
||||
VkDeviceSize missingAlignment = offset - currentBlock->offset;
|
||||
|
||||
// Append missing alignment to prev block or create new one
|
||||
// Create new block for missing alignment
|
||||
if (missingAlignment)
|
||||
{
|
||||
Block* prevBlock = currentBlock->prevPhysical;
|
||||
VMA_ASSERT(prevBlock != VMA_NULL && "There should be no missing alignment at offset 0!");
|
||||
|
||||
if (prevBlock->IsFree() && prevBlock->size != debugMargin)
|
||||
{
|
||||
uint32_t oldList = GetListIndex(prevBlock->size);
|
||||
prevBlock->size += missingAlignment;
|
||||
// Check if new size crosses list bucket
|
||||
if (oldList != GetListIndex(prevBlock->size))
|
||||
{
|
||||
prevBlock->size -= missingAlignment;
|
||||
RemoveFreeBlock(prevBlock);
|
||||
prevBlock->size += missingAlignment;
|
||||
InsertFreeBlock(prevBlock);
|
||||
}
|
||||
else
|
||||
m_BlocksFreeSize += missingAlignment;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block* newBlock = m_BlockAllocator.Alloc();
|
||||
currentBlock->prevPhysical = newBlock;
|
||||
prevBlock->nextPhysical = newBlock;
|
||||
|
@ -9349,9 +9332,7 @@ void VmaBlockMetadata_TLSF::Alloc(
|
|||
newBlock->size = missingAlignment;
|
||||
newBlock->offset = currentBlock->offset;
|
||||
newBlock->MarkTaken();
|
||||
|
||||
InsertFreeBlock(newBlock);
|
||||
}
|
||||
|
||||
currentBlock->size -= missingAlignment;
|
||||
currentBlock->offset += missingAlignment;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue