From 440307e6bce4bd51bf684d239446c980c4ca3bf2 Mon Sep 17 00:00:00 2001 From: Adam Sawicki Date: Thu, 18 Oct 2018 15:05:19 +0200 Subject: [PATCH] Fixed TestDefragmentationGpu() - it was test that was buggy. Defragmentation of GPU memory is working!!! - a major milestone :D --- src/Tests.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Tests.cpp b/src/Tests.cpp index cbf15b6..cc2fb3e 100644 --- a/src/Tests.cpp +++ b/src/Tests.cpp @@ -1460,7 +1460,9 @@ static void TestDefragmentationGpu() VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO }; bufCreateInfo.size = bufSize; - bufCreateInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; + bufCreateInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | + VK_BUFFER_USAGE_TRANSFER_DST_BIT | + VK_BUFFER_USAGE_TRANSFER_SRC_BIT; VmaAllocationCreateInfo allocCreateInfo = {}; allocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; @@ -1495,20 +1497,22 @@ static void TestDefragmentationGpu() // Defragment using GPU only. { const size_t allocCount = allocations.size(); + std::vector allocationPtrs(allocCount); std::vector allocationChanged(allocCount); for(size_t i = 0; i < allocCount; ++i) { allocationPtrs[i] = allocations[i].m_Allocation; - allocationChanged[i] = VK_FALSE; } + memset(allocationChanged.data(), 0, allocCount * sizeof(VkBool32)); BeginSingleTimeCommands(); VmaDefragmentationInfo2 defragInfo = {}; defragInfo.allocationCount = (uint32_t)allocCount; defragInfo.pAllocations = allocationPtrs.data(); - defragInfo.maxGpuBytesToMove = 0;//VK_WHOLE_SIZE; + defragInfo.pAllocationsChanged = allocationChanged.data(); + defragInfo.maxGpuBytesToMove = VK_WHOLE_SIZE; defragInfo.maxGpuAllocationsToMove = UINT32_MAX; defragInfo.commandBuffer = g_hTemporaryCommandBuffer; @@ -1529,9 +1533,9 @@ static void TestDefragmentationGpu() } } - //TEST(stats.allocationsMoved > 0 && stats.bytesMoved > 0); - //TEST(stats.deviceMemoryBlocksFreed > 0 && stats.bytesFreed > 0); - //TEST(stats.allocationsLost == 0); + TEST(stats.allocationsMoved > 0 && stats.bytesMoved > 0); + TEST(stats.deviceMemoryBlocksFreed > 0 && stats.bytesFreed > 0); + TEST(stats.allocationsLost == 0); } ValidateGpuData(allocations.data(), allocations.size()); @@ -4686,8 +4690,6 @@ void Test() // ######################################## TestDefragmentationGpu(); - TestDefragmentationSimple(); - TestDefragmentationFull(); return; }