@@ -7826,112 +7826,6 @@ static void BasicTestTLSF()
78267826 vmaDestroyVirtualBlock (block);
78277827}
78287828
7829- #if 0
7830- static void BasicTestBuddyAllocator()
7831- {
7832- wprintf(L"Basic test buddy allocator\n");
7833-
7834- RandomNumberGenerator rand{76543};
7835-
7836- VkBufferCreateInfo sampleBufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
7837- sampleBufCreateInfo.size = 1024; // Whatever.
7838- sampleBufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
7839-
7840- VmaAllocationCreateInfo sampleAllocCreateInfo = {};
7841-
7842- VmaPoolCreateInfo poolCreateInfo = {};
7843- VkResult res = vmaFindMemoryTypeIndexForBufferInfo(g_hAllocator, &sampleBufCreateInfo, &sampleAllocCreateInfo, &poolCreateInfo.memoryTypeIndex);
7844- TEST(res == VK_SUCCESS);
7845-
7846- // Deliberately adding 1023 to test usable size smaller than memory block size.
7847- poolCreateInfo.blockSize = 1024 * 1024 + 1023;
7848- poolCreateInfo.flags = VMA_POOL_CREATE_BUDDY_ALGORITHM_BIT;
7849- //poolCreateInfo.minBlockCount = poolCreateInfo.maxBlockCount = 1;
7850-
7851- VmaPool pool = nullptr;
7852- res = vmaCreatePool(g_hAllocator, &poolCreateInfo, &pool);
7853- TEST(res == VK_SUCCESS);
7854-
7855- VkBufferCreateInfo bufCreateInfo = sampleBufCreateInfo;
7856-
7857- VmaAllocationCreateInfo allocCreateInfo = {};
7858- allocCreateInfo.pool = pool;
7859-
7860- std::vector<BufferInfo> bufInfo;
7861- BufferInfo newBufInfo;
7862- VmaAllocationInfo allocInfo;
7863-
7864- bufCreateInfo.size = 1024 * 256;
7865- res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo,
7866- &newBufInfo.Buffer, &newBufInfo.Allocation, &allocInfo);
7867- TEST(res == VK_SUCCESS);
7868- bufInfo.push_back(newBufInfo);
7869-
7870- bufCreateInfo.size = 1024 * 512;
7871- res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo,
7872- &newBufInfo.Buffer, &newBufInfo.Allocation, &allocInfo);
7873- TEST(res == VK_SUCCESS);
7874- bufInfo.push_back(newBufInfo);
7875-
7876- bufCreateInfo.size = 1024 * 128;
7877- res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo,
7878- &newBufInfo.Buffer, &newBufInfo.Allocation, &allocInfo);
7879- TEST(res == VK_SUCCESS);
7880- bufInfo.push_back(newBufInfo);
7881-
7882- // Test very small allocation, smaller than minimum node size.
7883- bufCreateInfo.size = 1;
7884- res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo,
7885- &newBufInfo.Buffer, &newBufInfo.Allocation, &allocInfo);
7886- TEST(res == VK_SUCCESS);
7887- bufInfo.push_back(newBufInfo);
7888-
7889- // Test some small allocation with alignment requirement.
7890- {
7891- VkMemoryRequirements memReq;
7892- memReq.alignment = 256;
7893- memReq.memoryTypeBits = UINT32_MAX;
7894- memReq.size = 32;
7895-
7896- newBufInfo.Buffer = VK_NULL_HANDLE;
7897- res = vmaAllocateMemory(g_hAllocator, &memReq, &allocCreateInfo,
7898- &newBufInfo.Allocation, &allocInfo);
7899- TEST(res == VK_SUCCESS);
7900- TEST(allocInfo.offset % memReq.alignment == 0);
7901- bufInfo.push_back(newBufInfo);
7902- }
7903-
7904- //SaveAllocatorStatsToFile(L"TEST.json");
7905-
7906- VmaDetailedStatistics stats = {};
7907- vmaCalculatePoolStatistics(g_hAllocator, pool, &stats);
7908- int DBG = 0; // Set breakpoint here to inspect `stats`.
7909-
7910- // Allocate enough new buffers to surely fall into second block.
7911- for(uint32_t i = 0; i < 32; ++i)
7912- {
7913- bufCreateInfo.size = 1024 * (rand.Generate() % 32 + 1);
7914- res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo,
7915- &newBufInfo.Buffer, &newBufInfo.Allocation, &allocInfo);
7916- TEST(res == VK_SUCCESS);
7917- bufInfo.push_back(newBufInfo);
7918- }
7919-
7920- SaveAllocatorStatsToFile(L"BuddyTest01.json");
7921-
7922- // Destroy the buffers in random order.
7923- while(!bufInfo.empty())
7924- {
7925- const size_t indexToDestroy = rand.Generate() % bufInfo.size();
7926- const BufferInfo& currBufInfo = bufInfo[indexToDestroy];
7927- vmaDestroyBuffer(g_hAllocator, currBufInfo.Buffer, currBufInfo.Allocation);
7928- bufInfo.erase(bufInfo.begin() + indexToDestroy);
7929- }
7930-
7931- vmaDestroyPool(g_hAllocator, pool);
7932- }
7933- #endif // #if 0
7934-
79357829static void BasicTestAllocatePages ()
79367830{
79377831 wprintf (L" Basic test allocate pages\n " );
0 commit comments