Skip to content

Commit 9a4f508

Browse files
Added VmaDefragmentationAlgorithm_Fast - fast path for defragmentation, a completely new algorithm.
1 parent da85ec3 commit 9a4f508

2 files changed

Lines changed: 411 additions & 29 deletions

File tree

src/Tests.cpp

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,20 +1532,9 @@ void TestDefragmentationFull()
15321532
DestroyAllAllocations(allocations);
15331533
}
15341534

1535-
static void TestDefragmentationGpu(uint32_t flags)
1535+
static void TestDefragmentationGpu()
15361536
{
1537-
const wchar_t* flagsName = L"0";
1538-
switch(flags)
1539-
{
1540-
case VMA_DEFRAGMENTATION_FAST_ALGORITHM_BIT:
1541-
flagsName = L"FAST";
1542-
break;
1543-
case VMA_DEFRAGMENTATION_OPTIMAL_ALGORITHM_BIT:
1544-
flagsName = L"OPTIMAL";
1545-
break;
1546-
}
1547-
1548-
wprintf(L"Test defragmentation GPU (%s)\n", flagsName);
1537+
wprintf(L"Test defragmentation GPU\n");
15491538
g_MemoryAliasingWarningEnabled = false;
15501539

15511540
std::vector<AllocInfo> allocations;
@@ -1608,7 +1597,7 @@ static void TestDefragmentationGpu(uint32_t flags)
16081597
UploadGpuData(allocations.data(), allocations.size());
16091598

16101599
wchar_t fileName[MAX_PATH];
1611-
swprintf_s(fileName, L"GPU_defragmentation_%s_A_before.json", flagsName);
1600+
swprintf_s(fileName, L"GPU_defragmentation_A_before.json");
16121601
SaveAllocatorStatsToFile(fileName);
16131602

16141603
// Defragment using GPU only.
@@ -1636,7 +1625,7 @@ static void TestDefragmentationGpu(uint32_t flags)
16361625
BeginSingleTimeCommands();
16371626

16381627
VmaDefragmentationInfo2 defragInfo = {};
1639-
defragInfo.flags = flags;
1628+
defragInfo.flags = 0;
16401629
defragInfo.allocationCount = (uint32_t)movableAllocCount;
16411630
defragInfo.pAllocations = allocationPtrs.data();
16421631
defragInfo.pAllocationsChanged = allocationChanged.data();
@@ -1668,7 +1657,7 @@ static void TestDefragmentationGpu(uint32_t flags)
16681657

16691658
ValidateGpuData(allocations.data(), allocations.size());
16701659

1671-
swprintf_s(fileName, L"GPU_defragmentation_%s_B_after.json", flagsName);
1660+
swprintf_s(fileName, L"GPU_defragmentation_B_after.json");
16721661
SaveAllocatorStatsToFile(fileName);
16731662

16741663
// Destroy all remaining buffers.
@@ -5019,18 +5008,16 @@ void Test()
50195008
{
50205009
wprintf(L"TESTING:\n");
50215010

5022-
if(false)
5011+
if(true)
50235012
{
50245013
// # Temporarily insert custom tests here
50255014
// ########################################
50265015
// ########################################
50275016

5017+
TestDefragmentationSimple();
5018+
TestDefragmentationFull();
5019+
TestDefragmentationGpu();
50285020
TestDefragmentationWholePool();
5029-
//TestDefragmentationSimple();
5030-
//TestDefragmentationFull();
5031-
//TestDefragmentationGpu(0);
5032-
//TestDefragmentationGpu(VMA_DEFRAGMENTATION_FAST_ALGORITHM_BIT);
5033-
//TestDefragmentationGpu(VMA_DEFRAGMENTATION_OPTIMAL_ALGORITHM_BIT);
50345021
return;
50355022
}
50365023

@@ -5067,9 +5054,7 @@ void Test()
50675054
TestDefragmentationSimple();
50685055
TestDefragmentationFull();
50695056
TestDefragmentationWholePool();
5070-
TestDefragmentationGpu(0);
5071-
TestDefragmentationGpu(VMA_DEFRAGMENTATION_FAST_ALGORITHM_BIT);
5072-
TestDefragmentationGpu(VMA_DEFRAGMENTATION_OPTIMAL_ALGORITHM_BIT);
5057+
TestDefragmentationGpu();
50735058

50745059
// # Detailed tests
50755060
FILE* file;

0 commit comments

Comments
 (0)