From 26eaa3b2edb0889d803a1f99a8d23fc47457a84e Mon Sep 17 00:00:00 2001 From: Adam Sawicki Date: Thu, 18 Feb 2021 15:53:18 +0100 Subject: [PATCH] A fix in TestPool_Benchmark for GPUs with only 256 MB of DEVICE_LOCAL memory --- src/SparseBindingTest.cpp | 2 ++ src/Tests.cpp | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/SparseBindingTest.cpp b/src/SparseBindingTest.cpp index e7bc5897..4468d2ce 100644 --- a/src/SparseBindingTest.cpp +++ b/src/SparseBindingTest.cpp @@ -588,6 +588,8 @@ void TestSparseBinding() // Free remaining images. images.clear(); + + wprintf(L"Done.\n"); } #endif // #ifdef _WIN32 diff --git a/src/Tests.cpp b/src/Tests.cpp index ff2136d5..82db70a7 100644 --- a/src/Tests.cpp +++ b/src/Tests.cpp @@ -4414,13 +4414,22 @@ static void TestPool_Benchmark( poolCreateInfo.blockSize = config.PoolSize; poolCreateInfo.frameInUseCount = 1; - VmaAllocationCreateInfo dummyAllocCreateInfo = {}; - dummyAllocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; - vmaFindMemoryTypeIndex(g_hAllocator, memoryTypeBits, &dummyAllocCreateInfo, &poolCreateInfo.memoryTypeIndex); + VmaPool pool = VK_NULL_HANDLE; + VkResult res; + // Loop over memory types because we sometimes allocate a big block here, + // while the most eligible DEVICE_LOCAL heap may be only 256 MB on some GPUs. + while(memoryTypeBits) + { + VmaAllocationCreateInfo dummyAllocCreateInfo = {}; + dummyAllocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; + vmaFindMemoryTypeIndex(g_hAllocator, memoryTypeBits, &dummyAllocCreateInfo, &poolCreateInfo.memoryTypeIndex); - VmaPool pool; - VkResult res = vmaCreatePool(g_hAllocator, &poolCreateInfo, &pool); - TEST(res == VK_SUCCESS); + res = vmaCreatePool(g_hAllocator, &poolCreateInfo, &pool); + if(res == VK_SUCCESS) + break; + memoryTypeBits &= ~(1u << poolCreateInfo.memoryTypeIndex); + } + TEST(pool); // Start time measurement - after creating pool and initializing data structures. time_point timeBeg = std::chrono::high_resolution_clock::now();