Skip to content

Commit

Permalink
tests: Update tests hitting vuid 01445
Browse files Browse the repository at this point in the history
  • Loading branch information
ziga-lunarg committed Dec 24, 2024
1 parent 76e3cef commit 2ede2aa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
22 changes: 21 additions & 1 deletion tests/unit/external_memory_sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,9 @@ TEST_F(NegativeExternalMemorySync, ImportMemoryHandleType) {
m_errorMonitor->SetDesiredError("VUID-vkBindImageMemory-memory-02989");
m_errorMonitor->SetUnexpectedError("VUID-VkBindImageMemoryInfo-pNext-01617");
m_errorMonitor->SetUnexpectedError("VUID-VkBindImageMemoryInfo-pNext-01615");
if (image_dedicated_allocation) {
m_errorMonitor->SetDesiredError("VUID-vkBindImageMemory-image-01445");
}
vk::BindImageMemory(device(), image_import.handle(), memory_image_import.handle(), 0);
m_errorMonitor->VerifyFound();

Expand All @@ -1358,6 +1361,9 @@ TEST_F(NegativeExternalMemorySync, ImportMemoryHandleType) {
m_errorMonitor->SetDesiredError("VUID-VkBindImageMemoryInfo-memory-02989");
m_errorMonitor->SetUnexpectedError("VUID-VkBindImageMemoryInfo-pNext-01617");
m_errorMonitor->SetUnexpectedError("VUID-VkBindImageMemoryInfo-pNext-01615");
if (image_dedicated_allocation) {
m_errorMonitor->SetDesiredError("VUID-VkBindImageMemoryInfo-image-01445");
}
vk::BindImageMemory2(device(), 1, &bind_image_info);
m_errorMonitor->VerifyFound();
}
Expand Down Expand Up @@ -2049,7 +2055,21 @@ TEST_F(NegativeExternalMemorySync, ImageDedicatedAllocation) {

m_errorMonitor->SetDesiredError("VUID-VkMemoryAllocateInfo-pNext-00639");
// pNext chain contains VkExportMemoryAllocateInfo but not VkMemoryDedicatedAllocateInfo
vkt::Image image(*m_device, image_info, 0, &export_memory_info);
vkt::Image image;
image.InitNoMemory(*m_device, image_info);
{
VkImageMemoryRequirementsInfo2 image_memory_requirements_info = vku::InitStructHelper();
image_memory_requirements_info.image = image.handle();
VkMemoryDedicatedRequirements memory_dedicated_requirements = vku::InitStructHelper();

VkMemoryRequirements2 memory_requirements = vku::InitStructHelper(&memory_dedicated_requirements);
vk::GetImageMemoryRequirements2(device(), &image_memory_requirements_info, &memory_requirements);

if (memory_dedicated_requirements.requiresDedicatedAllocation) {
m_errorMonitor->SetDesiredError("VUID-vkBindImageMemory-image-01445");
}
}
image.AllocateAndBindMemory(*m_device, 0, &export_memory_info);
m_errorMonitor->VerifyFound();
}

Expand Down
15 changes: 11 additions & 4 deletions tests/unit/wsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,22 @@ TEST_F(NegativeWsi, BindImageMemorySwapchain) {

vkt::Image image_from_swapchain(*m_device, image_create_info, vkt::no_mem);

VkMemoryRequirements mem_reqs = {};
vk::GetImageMemoryRequirements(device(), image_from_swapchain.handle(), &mem_reqs);
VkImageMemoryRequirementsInfo2 image_memory_requirements_info = vku::InitStructHelper();
image_memory_requirements_info.image = image_from_swapchain.handle();
VkMemoryDedicatedRequirements memory_dedicated_requirements = vku::InitStructHelper();

VkMemoryRequirements2 mem_reqs = vku::InitStructHelper(&memory_dedicated_requirements);
vk::GetImageMemoryRequirements2(device(), &image_memory_requirements_info, &mem_reqs);

VkMemoryAllocateInfo alloc_info = vku::InitStructHelper();
alloc_info.memoryTypeIndex = 0;
alloc_info.allocationSize = mem_reqs.size;
alloc_info.allocationSize = mem_reqs.memoryRequirements.size;
if (alloc_info.allocationSize == 0) {
GTEST_SKIP() << "Driver seems to not be returning an valid allocation size and need to end test";
}

vkt::DeviceMemory mem;
bool pass = m_device->Physical().SetMemoryType(mem_reqs.memoryTypeBits, &alloc_info, 0);
bool pass = m_device->Physical().SetMemoryType(mem_reqs.memoryRequirements.memoryTypeBits, &alloc_info, 0);
// some devices don't give us good memory requirements for the swapchain image
if (pass) {
mem.init(*m_device, alloc_info);
Expand Down Expand Up @@ -174,6 +178,9 @@ TEST_F(NegativeWsi, BindImageMemorySwapchain) {
m_errorMonitor->SetDesiredError("VUID-VkBindImageMemoryInfo-pNext-01631");
}
m_errorMonitor->SetDesiredError("VUID-VkBindImageMemorySwapchainInfoKHR-imageIndex-01644");
if (memory_dedicated_requirements.requiresDedicatedAllocation) {
m_errorMonitor->SetDesiredError("VUID-VkBindImageMemoryInfo-image-01445");
}
vk::BindImageMemory2(device(), 1, &bind_info);
m_errorMonitor->VerifyFound();

Expand Down

0 comments on commit 2ede2aa

Please sign in to comment.