Skip to content

Commit 6fbb28e

Browse files
Improvement in TestAllocationAliasing
1 parent cde4946 commit 6fbb28e

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/Tests.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6259,15 +6259,39 @@ static void TestAllocationAliasing()
62596259
VkImage aliasingImage;
62606260
imageInfo.extent.width = 480;
62616261
imageInfo.extent.height = 256;
6262-
res = vkCreateImage(g_hDevice, &imageInfo, nullptr, &aliasingImage);
6262+
res = vkCreateImage(g_hDevice, &imageInfo, g_Allocs, &aliasingImage);
62636263
TEST(res == VK_SUCCESS);
62646264
// Now with VMA_ALLOCATION_CREATE_CAN_ALIAS_BIT flag validation error is no more
62656265
res = vmaBindImageMemory(g_hAllocator, allocation, aliasingImage);
62666266
TEST(res == VK_SUCCESS);
62676267

6268-
vkDestroyImage(g_hDevice, aliasingImage, nullptr);
6268+
vkDestroyImage(g_hDevice, aliasingImage, g_Allocs);
62696269
vmaDestroyImage(g_hAllocator, originalImage, allocation);
62706270
}
6271+
6272+
// Test creating buffer without DEDICATED flag, but large enought to end up as dedicated.
6273+
allocationCreateInfo.flags = VMA_ALLOCATION_CREATE_CAN_ALIAS_BIT;
6274+
6275+
VkBufferCreateInfo bufCreateInfo = {VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO};
6276+
bufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
6277+
bufCreateInfo.size = 300 * MEGABYTE;
6278+
6279+
{
6280+
VkBuffer origBuf;
6281+
VmaAllocation alloc;
6282+
VmaAllocationInfo allocInfo;
6283+
VkResult res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocationCreateInfo, &origBuf, &alloc, &allocInfo);
6284+
TEST(res == VK_SUCCESS && origBuf && alloc);
6285+
TEST(allocInfo.offset == 0); // Dedicated
6286+
6287+
VkBuffer aliasingBuf;
6288+
bufCreateInfo.size = 200 * MEGABYTE;
6289+
res = vmaCreateAliasingBuffer(g_hAllocator, alloc, &bufCreateInfo, &aliasingBuf);
6290+
TEST(res == VK_SUCCESS && aliasingBuf);
6291+
6292+
vkDestroyBuffer(g_hDevice, aliasingBuf, g_Allocs);
6293+
vmaDestroyBuffer(g_hAllocator, origBuf, alloc);
6294+
}
62716295
}
62726296

62736297
static void TestMapping()

0 commit comments

Comments
 (0)