Small fix in VmaBlock::Free (thanks @dylanede for pointing this!)

This commit is contained in:
Adam Sawicki 2017-07-11 15:00:11 +02:00
parent a59788d60d
commit f30ee85a15

View File

@ -3146,12 +3146,7 @@ void VmaBlock::FreeSuballocation(VmaSuballocationList::iterator suballocItem)
void VmaBlock::Free(const VmaAllocation allocation) void VmaBlock::Free(const VmaAllocation allocation)
{ {
// If suballocation to free has offset smaller than half of allocation size, search forward.
// Otherwise search backward.
const VkDeviceSize allocationOffset = allocation->GetOffset(); const VkDeviceSize allocationOffset = allocation->GetOffset();
const bool forwardDirection = allocationOffset < (m_Size / 2);
if(forwardDirection)
{
for(VmaSuballocationList::iterator suballocItem = m_Suballocations.begin(); for(VmaSuballocationList::iterator suballocItem = m_Suballocations.begin();
suballocItem != m_Suballocations.end(); suballocItem != m_Suballocations.end();
++suballocItem) ++suballocItem)
@ -3165,23 +3160,6 @@ void VmaBlock::Free(const VmaAllocation allocation)
} }
} }
VMA_ASSERT(0 && "Not found!"); VMA_ASSERT(0 && "Not found!");
}
else
{
for(VmaSuballocationList::iterator suballocItem = m_Suballocations.begin();
suballocItem != m_Suballocations.end();
++suballocItem)
{
VmaSuballocation& suballoc = *suballocItem;
if(suballoc.offset == allocationOffset)
{
FreeSuballocation(suballocItem);
VMA_HEAVY_ASSERT(Validate());
return;
}
}
VMA_ASSERT(0 && "Not found!");
}
} }
#if VMA_STATS_STRING_ENABLED #if VMA_STATS_STRING_ENABLED