MCPcopy Create free account
hub / github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator / ManuallyTestLinearAllocator

Function ManuallyTestLinearAllocator

src/Tests.cpp:4744–4858  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4742}
4743
4744static void ManuallyTestLinearAllocator()
4745{
4746 VmaTotalStatistics origStats;
4747 vmaCalculateStatistics(g_hAllocator, &origStats);
4748
4749 wprintf(L"Manually test linear allocator\n");
4750
4751 RandomNumberGenerator rand{645332};
4752
4753 VkBufferCreateInfo sampleBufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
4754 sampleBufCreateInfo.size = 1024; // Whatever.
4755 sampleBufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
4756
4757 VmaAllocationCreateInfo sampleAllocCreateInfo = {};
4758 sampleAllocCreateInfo.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE;
4759
4760 VmaPoolCreateInfo poolCreateInfo = {};
4761 VkResult res = vmaFindMemoryTypeIndexForBufferInfo(g_hAllocator, &sampleBufCreateInfo, &sampleAllocCreateInfo, &poolCreateInfo.memoryTypeIndex);
4762 TEST(res == VK_SUCCESS);
4763
4764 poolCreateInfo.blockSize = 10 * 1024;
4765 poolCreateInfo.flags = VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT;
4766 poolCreateInfo.minBlockCount = poolCreateInfo.maxBlockCount = 1;
4767
4768 VmaPool pool = nullptr;
4769 res = vmaCreatePool(g_hAllocator, &poolCreateInfo, &pool);
4770 TEST(res == VK_SUCCESS);
4771
4772 VkBufferCreateInfo bufCreateInfo = sampleBufCreateInfo;
4773
4774 VmaAllocationCreateInfo allocCreateInfo = {};
4775 allocCreateInfo.pool = pool;
4776
4777 std::vector<BufferInfo> bufInfo;
4778 VmaAllocationInfo allocInfo;
4779 BufferInfo newBufInfo;
4780
4781 // Test double stack.
4782 {
4783 /*
4784 Lower: Buffer 32 B, Buffer 1024 B, Buffer 32 B
4785 Upper: Buffer 16 B, Buffer 1024 B, Buffer 128 B
4786
4787 Totally:
4788 1 block allocated
4789 10240 Vulkan bytes
4790 6 new allocations
4791 2256 bytes in allocations
4792 */
4793
4794 bufCreateInfo.size = 32;
4795 res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo,
4796 &newBufInfo.Buffer, &newBufInfo.Allocation, &allocInfo);
4797 TEST(res == VK_SUCCESS);
4798 bufInfo.push_back(newBufInfo);
4799
4800 bufCreateInfo.size = 1024;
4801 res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo,

Callers 1

TestFunction · 0.85

Calls 13

vmaCalculateStatisticsFunction · 0.85
TESTEnum · 0.85
vmaCreatePoolFunction · 0.85
vmaCreateBufferFunction · 0.85
vmaBuildStatsStringFunction · 0.85
vmaFreeStatsStringFunction · 0.85
vmaDestroyBufferFunction · 0.85
vmaDestroyPoolFunction · 0.85
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected