Skip to content

Commit e168191

Browse files
Added test for defragmentation of empty pool.
1 parent 9a4f508 commit e168191

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/Tests.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,23 @@ void TestDefragmentationSimple()
12401240
VmaPool pool;
12411241
ERR_GUARD_VULKAN( vmaCreatePool(g_hAllocator, &poolCreateInfo, &pool) );
12421242

1243+
// Defragmentation of empty pool.
1244+
{
1245+
VmaDefragmentationInfo2 defragInfo = {};
1246+
defragInfo.maxCpuBytesToMove = VK_WHOLE_SIZE;
1247+
defragInfo.maxCpuAllocationsToMove = UINT32_MAX;
1248+
defragInfo.poolCount = 1;
1249+
defragInfo.pPools = &pool;
1250+
1251+
VmaDefragmentationStats defragStats = {};
1252+
VmaDefragmentationContext defragCtx = nullptr;
1253+
VkResult res = vmaDefragmentationBegin(g_hAllocator, &defragInfo, &defragStats, &defragCtx);
1254+
TEST(res >= VK_SUCCESS);
1255+
vmaDefragmentationEnd(g_hAllocator, defragCtx);
1256+
TEST(defragStats.allocationsMoved == 0 && defragStats.bytesFreed == 0 &&
1257+
defragStats.bytesMoved == 0 && defragStats.deviceMemoryBlocksFreed == 0);
1258+
}
1259+
12431260
std::vector<AllocInfo> allocations;
12441261

12451262
// persistentlyMappedOption = 0 - not persistently mapped.

0 commit comments

Comments
 (0)