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

Function TestPool_Benchmark

src/Tests.cpp:5479–5934  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5477}
5478
5479static void TestPool_Benchmark(
5480 PoolTestResult& outResult,
5481 const PoolTestConfig& config)
5482{
5483 TEST(config.ThreadCount > 0);
5484
5485 RandomNumberGenerator mainRand{config.RandSeed};
5486
5487 uint32_t allocationSizeProbabilitySum = std::accumulate(
5488 config.AllocationSizes.begin(),
5489 config.AllocationSizes.end(),
5490 0u,
5491 [](uint32_t sum, const AllocationSize& allocSize) {
5492 return sum + allocSize.Probability;
5493 });
5494
5495 VkBufferCreateInfo bufferTemplateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
5496 bufferTemplateInfo.size = 256; // Whatever.
5497 bufferTemplateInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
5498
5499 VkImageCreateInfo imageTemplateInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO };
5500 imageTemplateInfo.imageType = VK_IMAGE_TYPE_2D;
5501 imageTemplateInfo.extent.width = 256; // Whatever.
5502 imageTemplateInfo.extent.height = 256; // Whatever.
5503 imageTemplateInfo.extent.depth = 1;
5504 imageTemplateInfo.mipLevels = 1;
5505 imageTemplateInfo.arrayLayers = 1;
5506 imageTemplateInfo.format = VK_FORMAT_R8G8B8A8_UNORM;
5507 imageTemplateInfo.tiling = VK_IMAGE_TILING_OPTIMAL; // LINEAR if CPU memory.
5508 imageTemplateInfo.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
5509 imageTemplateInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; // TRANSFER_SRC if CPU memory.
5510 imageTemplateInfo.samples = VK_SAMPLE_COUNT_1_BIT;
5511
5512 uint32_t bufferMemoryTypeBits = UINT32_MAX;
5513 {
5514 VkBuffer dummyBuffer;
5515 VkResult res = vkCreateBuffer(g_hDevice, &bufferTemplateInfo, g_Allocs, &dummyBuffer);
5516 TEST(res == VK_SUCCESS);
5517
5518 VkMemoryRequirements memReq;
5519 vkGetBufferMemoryRequirements(g_hDevice, dummyBuffer, &memReq);
5520 bufferMemoryTypeBits = memReq.memoryTypeBits;
5521
5522 vkDestroyBuffer(g_hDevice, dummyBuffer, g_Allocs);
5523 }
5524
5525 uint32_t imageMemoryTypeBits = UINT32_MAX;
5526 {
5527 VkImage dummyImage;
5528 VkResult res = vkCreateImage(g_hDevice, &imageTemplateInfo, g_Allocs, &dummyImage);
5529 TEST(res == VK_SUCCESS);
5530
5531 VkMemoryRequirements memReq;
5532 vkGetImageMemoryRequirements(g_hDevice, dummyImage, &memReq);
5533 imageMemoryTypeBits = memReq.memoryTypeBits;
5534
5535 vkDestroyImage(g_hDevice, dummyImage, g_Allocs);
5536 }

Callers 2

PerformCustomPoolTestFunction · 0.85
PerformPoolTestsFunction · 0.85

Calls 15

TESTEnum · 0.85
PrintWarningFunction · 0.85
vmaGetMemoryPropertiesFunction · 0.85
vmaFindMemoryTypeIndexFunction · 0.85
vmaCreatePoolFunction · 0.85
vmaCreateBufferFunction · 0.85
SetDebugUtilsObjectNameFunction · 0.85
vmaCreateImageFunction · 0.85
vmaGetAllocationInfoFunction · 0.85
vmaSetCurrentFrameIndexFunction · 0.85
vmaDestroyPoolFunction · 0.85
UsesBuffersMethod · 0.80

Tested by

no test coverage detected