From e43eab99ec640529e2e5183f938230f4c662ef96 Mon Sep 17 00:00:00 2001 From: Johannes Schneider Date: Wed, 10 Jul 2024 14:11:12 +0200 Subject: [PATCH] Remove unused code --- src/Tests.cpp | 106 ------------------------------------------- src/VulkanSample.cpp | 11 ----- 2 files changed, 117 deletions(-) diff --git a/src/Tests.cpp b/src/Tests.cpp index 7540478..5a6f63b 100644 --- a/src/Tests.cpp +++ b/src/Tests.cpp @@ -7826,112 +7826,6 @@ static void BasicTestTLSF() vmaDestroyVirtualBlock(block); } -#if 0 -static void BasicTestBuddyAllocator() -{ - wprintf(L"Basic test buddy allocator\n"); - - RandomNumberGenerator rand{76543}; - - VkBufferCreateInfo sampleBufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO }; - sampleBufCreateInfo.size = 1024; // Whatever. - sampleBufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; - - VmaAllocationCreateInfo sampleAllocCreateInfo = {}; - - VmaPoolCreateInfo poolCreateInfo = {}; - VkResult res = vmaFindMemoryTypeIndexForBufferInfo(g_hAllocator, &sampleBufCreateInfo, &sampleAllocCreateInfo, &poolCreateInfo.memoryTypeIndex); - TEST(res == VK_SUCCESS); - - // Deliberately adding 1023 to test usable size smaller than memory block size. - poolCreateInfo.blockSize = 1024 * 1024 + 1023; - poolCreateInfo.flags = VMA_POOL_CREATE_BUDDY_ALGORITHM_BIT; - //poolCreateInfo.minBlockCount = poolCreateInfo.maxBlockCount = 1; - - VmaPool pool = nullptr; - res = vmaCreatePool(g_hAllocator, &poolCreateInfo, &pool); - TEST(res == VK_SUCCESS); - - VkBufferCreateInfo bufCreateInfo = sampleBufCreateInfo; - - VmaAllocationCreateInfo allocCreateInfo = {}; - allocCreateInfo.pool = pool; - - std::vector bufInfo; - BufferInfo newBufInfo; - VmaAllocationInfo allocInfo; - - bufCreateInfo.size = 1024 * 256; - res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo, - &newBufInfo.Buffer, &newBufInfo.Allocation, &allocInfo); - TEST(res == VK_SUCCESS); - bufInfo.push_back(newBufInfo); - - bufCreateInfo.size = 1024 * 512; - res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo, - &newBufInfo.Buffer, &newBufInfo.Allocation, &allocInfo); - TEST(res == VK_SUCCESS); - bufInfo.push_back(newBufInfo); - - bufCreateInfo.size = 1024 * 128; - res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo, - &newBufInfo.Buffer, &newBufInfo.Allocation, &allocInfo); - TEST(res == VK_SUCCESS); - bufInfo.push_back(newBufInfo); - - // Test very small allocation, smaller than minimum node size. - bufCreateInfo.size = 1; - res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo, - &newBufInfo.Buffer, &newBufInfo.Allocation, &allocInfo); - TEST(res == VK_SUCCESS); - bufInfo.push_back(newBufInfo); - - // Test some small allocation with alignment requirement. - { - VkMemoryRequirements memReq; - memReq.alignment = 256; - memReq.memoryTypeBits = UINT32_MAX; - memReq.size = 32; - - newBufInfo.Buffer = VK_NULL_HANDLE; - res = vmaAllocateMemory(g_hAllocator, &memReq, &allocCreateInfo, - &newBufInfo.Allocation, &allocInfo); - TEST(res == VK_SUCCESS); - TEST(allocInfo.offset % memReq.alignment == 0); - bufInfo.push_back(newBufInfo); - } - - //SaveAllocatorStatsToFile(L"TEST.json"); - - VmaDetailedStatistics stats = {}; - vmaCalculatePoolStatistics(g_hAllocator, pool, &stats); - int DBG = 0; // Set breakpoint here to inspect `stats`. - - // Allocate enough new buffers to surely fall into second block. - for(uint32_t i = 0; i < 32; ++i) - { - bufCreateInfo.size = 1024 * (rand.Generate() % 32 + 1); - res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo, - &newBufInfo.Buffer, &newBufInfo.Allocation, &allocInfo); - TEST(res == VK_SUCCESS); - bufInfo.push_back(newBufInfo); - } - - SaveAllocatorStatsToFile(L"BuddyTest01.json"); - - // Destroy the buffers in random order. - while(!bufInfo.empty()) - { - const size_t indexToDestroy = rand.Generate() % bufInfo.size(); - const BufferInfo& currBufInfo = bufInfo[indexToDestroy]; - vmaDestroyBuffer(g_hAllocator, currBufInfo.Buffer, currBufInfo.Allocation); - bufInfo.erase(bufInfo.begin() + indexToDestroy); - } - - vmaDestroyPool(g_hAllocator, pool); -} -#endif // #if 0 - static void BasicTestAllocatePages() { wprintf(L"Basic test allocate pages\n"); diff --git a/src/VulkanSample.cpp b/src/VulkanSample.cpp index dd7da16..08da708 100644 --- a/src/VulkanSample.cpp +++ b/src/VulkanSample.cpp @@ -1583,17 +1583,6 @@ static void PrintMemoryTypes() } } -#if 0 -template -inline VkDeviceSize MapSum(It beg, It end, MapFunc mapFunc) -{ - VkDeviceSize result = 0; - for(It it = beg; it != end; ++it) - result += mapFunc(*it); - return result; -} -#endif - static bool CanCreateVertexBuffer(uint32_t allowedMemoryTypeBits) { VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };