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

Function TestMappingHysteresis

src/Tests.cpp:8467–8632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8465}
8466
8467static void TestMappingHysteresis()
8468{
8469 /*
8470 We have no way to check here if hysteresis worked as expected,
8471 but at least we provoke some cases and make sure it doesn't crash or assert.
8472 You can always check details with the debugger.
8473 */
8474
8475 wprintf(L"Test mapping hysteresis\n");
8476
8477 VkBufferCreateInfo bufCreateInfo = {VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO};
8478 bufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
8479 bufCreateInfo.size = 0x10000;
8480
8481 VmaAllocationCreateInfo templateAllocCreateInfo = {};
8482 templateAllocCreateInfo.usage = VMA_MEMORY_USAGE_AUTO;
8483 templateAllocCreateInfo.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT;
8484
8485 VmaPoolCreateInfo poolCreateInfo = {};
8486 poolCreateInfo.blockSize = 10 * MEGABYTE;
8487 poolCreateInfo.minBlockCount = poolCreateInfo.maxBlockCount = 1;
8488 TEST(vmaFindMemoryTypeIndexForBufferInfo(g_hAllocator,
8489 &bufCreateInfo, &templateAllocCreateInfo, &poolCreateInfo.memoryTypeIndex) == VK_SUCCESS);
8490
8491 constexpr uint32_t BUF_COUNT = 30;
8492 bool endOfScenarios = false;
8493 for(uint32_t scenarioIndex = 0; !endOfScenarios; ++scenarioIndex)
8494 {
8495 VmaPool pool;
8496 TEST(vmaCreatePool(g_hAllocator, &poolCreateInfo, &pool) == VK_SUCCESS);
8497
8498 BufferInfo buf;
8499 VmaAllocationInfo allocInfo;
8500
8501 std::vector<BufferInfo> bufs;
8502
8503 // Scenario: Create + destroy buffers without mapping. Hysteresis should not launch.
8504 if(scenarioIndex == 0)
8505 {
8506 VmaAllocationCreateInfo allocCreateInfo = {};
8507 allocCreateInfo.pool = pool;
8508
8509 for(uint32_t bufIndex = 0; bufIndex < BUF_COUNT; ++bufIndex)
8510 {
8511 TEST(vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo, &buf.Buffer, &buf.Allocation, &allocInfo) == VK_SUCCESS);
8512 TEST(allocInfo.pMappedData == nullptr);
8513 vmaDestroyBuffer(g_hAllocator, buf.Buffer, buf.Allocation);
8514 }
8515 }
8516 // Scenario:
8517 // - Create one buffer mapped that stays there.
8518 // - Create + destroy mapped buffers back and forth. Hysteresis should launch.
8519 else if(scenarioIndex == 1)
8520 {
8521 VmaAllocationCreateInfo allocCreateInfo = {};
8522 allocCreateInfo.pool = pool;
8523 allocCreateInfo.flags = VMA_ALLOCATION_CREATE_MAPPED_BIT;
8524

Callers 1

TestFunction · 0.85

Calls 11

TESTEnum · 0.85
vmaCreatePoolFunction · 0.85
vmaCreateBufferFunction · 0.85
vmaDestroyBufferFunction · 0.85
vmaMapMemoryFunction · 0.85
vmaUnmapMemoryFunction · 0.85
vmaDestroyPoolFunction · 0.85
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected