Try combine _freelists when freeing to reduce chance of running out of images.

This commit is contained in:
duncanspumpkin 2016-07-16 14:12:15 +01:00
parent 1e1546d87c
commit 5426b655fe
1 changed files with 16 additions and 1 deletions

View File

@ -99,7 +99,22 @@ static void FreeImageList(uint32 baseImageId, uint32 count)
bool contains = AllocatedListContains(baseImageId, count);
Guard::Assert(contains);
#endif
for (auto it = _freeLists.begin(); it != _freeLists.end(); it++)
{
if (it->BaseId + count == baseImageId)
{
it->Count += count;
return;
}
else if (baseImageId + count == it->BaseId)
{
it->BaseId = baseImageId;
it->Count += count;
return;
}
}
// TODO validate that this was an allocated list
_freeLists.push_back({ baseImageId, count });
}