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

Function TestAllocationAliasing

src/Tests.cpp:6984–7077  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6982}
6983
6984static void TestAllocationAliasing()
6985{
6986 wprintf(L"Testing allocation aliasing...\n");
6987
6988 /*
6989 * Test whether using VMA_ALLOCATION_CREATE_CAN_ALIAS_BIT suppress validation layer error
6990 * by don't supplying VkMemoryDedicatedAllocateInfoKHR to creation of dedicated memory
6991 * that will be used to alias with some other textures.
6992 */
6993
6994 VkImageCreateInfo imageInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO };
6995 imageInfo.imageType = VK_IMAGE_TYPE_2D;
6996 imageInfo.format = VK_FORMAT_R8G8B8A8_UNORM;
6997 imageInfo.extent.depth = 1;
6998 imageInfo.mipLevels = 1;
6999 imageInfo.arrayLayers = 1;
7000 imageInfo.samples = VK_SAMPLE_COUNT_1_BIT;
7001 imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
7002 imageInfo.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
7003 imageInfo.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
7004
7005 VmaAllocationCreateInfo allocationCreateInfo = {};
7006 allocationCreateInfo.flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
7007 allocationCreateInfo.usage = VMA_MEMORY_USAGE_AUTO;
7008
7009 // Bind 2 textures together into same memory without VMA_ALLOCATION_CREATE_CAN_ALIAS_BIT and then with flag set
7010 /*
7011 {
7012 VkImage originalImage;
7013 VmaAllocation allocation;
7014 imageInfo.extent.width = 640;
7015 imageInfo.extent.height = 480;
7016 VkResult res = vmaCreateImage(g_hAllocator, &imageInfo, &allocationCreateInfo, &originalImage, &allocation, nullptr);
7017 TEST(res == VK_SUCCESS);
7018
7019 VkImage aliasingImage;
7020 imageInfo.extent.width = 480;
7021 imageInfo.extent.height = 256;
7022 res = vkCreateImage(g_hDevice, &imageInfo, nullptr, &aliasingImage);
7023 TEST(res == VK_SUCCESS);
7024 // After binding there should be inevitable validation layer error VUID-vkBindImageMemory-memory-01509
7025 res = vmaBindImageMemory(g_hAllocator, allocation, aliasingImage);
7026 TEST(res == VK_SUCCESS);
7027
7028 vkDestroyImage(g_hDevice, aliasingImage, nullptr);
7029 vmaDestroyImage(g_hAllocator, originalImage, allocation);
7030 }
7031 */
7032 allocationCreateInfo.flags |= VMA_ALLOCATION_CREATE_CAN_ALIAS_BIT;
7033 {
7034 VkImage originalImage;
7035 VmaAllocation allocation;
7036 imageInfo.extent.width = 640;
7037 imageInfo.extent.height = 480;
7038 VkResult res = vmaCreateImage(g_hAllocator, &imageInfo, &allocationCreateInfo, &originalImage, &allocation, nullptr);
7039 TEST(res == VK_SUCCESS);
7040
7041 VkImage aliasingImage;

Callers 1

TestFunction · 0.85

Calls 7

vmaCreateImageFunction · 0.85
TESTEnum · 0.85
vmaBindImageMemoryFunction · 0.85
vmaDestroyImageFunction · 0.85
vmaCreateBufferFunction · 0.85
vmaCreateAliasingBufferFunction · 0.85
vmaDestroyBufferFunction · 0.85

Tested by

no test coverage detected