Fixed some calculations in TLSF.

Code by @medranSolus
This commit is contained in:
Adam Sawicki 2022-01-31 14:55:44 +01:00
parent 08759cbec5
commit ff99bf7dea

View File

@ -9896,7 +9896,7 @@ bool VmaBlockMetadata_TLSF::CreateAllocationRequest(
sizeForNextList += (1ULL << (VMA_BITSCAN_MSB(allocSize) - SECOND_LEVEL_INDEX)) - 1; sizeForNextList += (1ULL << (VMA_BITSCAN_MSB(allocSize) - SECOND_LEVEL_INDEX)) - 1;
} }
else else
sizeForNextList += 1 << SECOND_LEVEL_INDEX; sizeForNextList += (1 << SECOND_LEVEL_INDEX) - 1;
uint32_t nextListIndex = 0; uint32_t nextListIndex = 0;
uint32_t prevListIndex = 0; uint32_t prevListIndex = 0;
@ -10246,7 +10246,12 @@ uint32_t VmaBlockMetadata_TLSF::GetListIndex(uint8_t memoryClass, uint16_t secon
{ {
if (memoryClass == 0) if (memoryClass == 0)
return secondIndex; return secondIndex;
return static_cast<uint32_t>(memoryClass - 1) * (1 << SECOND_LEVEL_INDEX) + secondIndex + 4;
const uint32_t index = static_cast<uint32_t>(memoryClass - 1) * (1 << SECOND_LEVEL_INDEX) + secondIndex;
if (IsVirtual())
return index + (1 << SECOND_LEVEL_INDEX);
else
return index + 4;
} }
uint32_t VmaBlockMetadata_TLSF::GetListIndex(VkDeviceSize size) const uint32_t VmaBlockMetadata_TLSF::GetListIndex(VkDeviceSize size) const