mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2025-06-03 02:17:46 +00:00
Implemented vmaMakePoolAllocationsLost for pools with linear allocator.
This commit is contained in:
parent
8cfe05fad9
commit
0ebdf0c63e
2 changed files with 68 additions and 3 deletions
|
@ -1733,7 +1733,7 @@ static void TestLinearAllocator()
|
|||
}
|
||||
|
||||
// Allocate number of buffers until pool is full again.
|
||||
// This way we make sure ring buffers wraps around.
|
||||
// This way we make sure ring buffers wraps around, front in in the middle.
|
||||
res = VK_SUCCESS;
|
||||
for(size_t i = 0; res == VK_SUCCESS; ++i)
|
||||
{
|
||||
|
@ -1786,6 +1786,35 @@ static void TestLinearAllocator()
|
|||
break;
|
||||
}
|
||||
|
||||
// Delete buffers that are lost.
|
||||
for(size_t i = bufInfo.size(); i--; )
|
||||
{
|
||||
vmaGetAllocationInfo(g_hAllocator, bufInfo[i].Allocation, &allocInfo);
|
||||
if(allocInfo.deviceMemory == VK_NULL_HANDLE)
|
||||
{
|
||||
vmaDestroyBuffer(g_hAllocator, bufInfo[i].Buffer, bufInfo[i].Allocation);
|
||||
bufInfo.erase(bufInfo.begin() + i);
|
||||
}
|
||||
}
|
||||
|
||||
// Test vmaMakePoolAllocationsLost
|
||||
{
|
||||
vmaSetCurrentFrameIndex(g_hAllocator, ++g_FrameIndex);
|
||||
|
||||
size_t lostAllocCount = SIZE_MAX;
|
||||
vmaMakePoolAllocationsLost(g_hAllocator, pool, &lostAllocCount);
|
||||
assert(lostAllocCount > 0);
|
||||
|
||||
size_t realLostAllocCount = 0;
|
||||
for(size_t i = 0; i < bufInfo.size(); ++i)
|
||||
{
|
||||
vmaGetAllocationInfo(g_hAllocator, bufInfo[i].Allocation, &allocInfo);
|
||||
if(allocInfo.deviceMemory == VK_NULL_HANDLE)
|
||||
++realLostAllocCount;
|
||||
}
|
||||
assert(realLostAllocCount == lostAllocCount);
|
||||
}
|
||||
|
||||
// Destroy all the buffers in forward order.
|
||||
for(size_t i = 0; i < bufInfo.size(); ++i)
|
||||
vmaDestroyBuffer(g_hAllocator, bufInfo[i].Buffer, bufInfo[i].Allocation);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue