Remove unused code

This commit is contained in:
Johannes Schneider 2024-07-10 14:11:12 +02:00
parent d0220181d0
commit e43eab99ec
No known key found for this signature in database
2 changed files with 0 additions and 117 deletions

View File

@ -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<BufferInfo> 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");

View File

@ -1583,17 +1583,6 @@ static void PrintMemoryTypes()
}
}
#if 0
template<typename It, typename MapFunc>
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 };