Skip to content

Commit

Permalink
tests: Update tests hitting vuid 01444 and 01445
Browse files Browse the repository at this point in the history
  • Loading branch information
ziga-lunarg committed Dec 26, 2024
1 parent 1a0cde8 commit 5f1c37a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 9 deletions.
11 changes: 9 additions & 2 deletions tests/unit/android_hardware_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,8 +1072,12 @@ TEST_F(NegativeAndroidHardwareBuffer, InvalidBindBufferMemory) {
vkt::Buffer buffer(*m_device, buffer_create_info, vkt::no_mem);

// Try to get memory requirements prior to binding memory
VkMemoryRequirements mem_reqs;
vk::GetBufferMemoryRequirements(device(), buffer.handle(), &mem_reqs);
VkBufferMemoryRequirementsInfo2 buffer_memory_requirements_info = vku::InitStructHelper();
buffer_memory_requirements_info.buffer = buffer.handle();
VkMemoryDedicatedRequirements memory_dedicated_requirements = vku::InitStructHelper();
VkMemoryRequirements2 mem_reqs2 = vku::InitStructHelper(&memory_dedicated_requirements);
vk::GetBufferMemoryRequirements2(device(), &buffer_memory_requirements_info, &mem_reqs2);
VkMemoryRequirements mem_reqs = mem_reqs2.memoryRequirements;

VkImportAndroidHardwareBufferInfoANDROID import_ahb_Info = vku::InitStructHelper();
import_ahb_Info.buffer = ahb.handle();
Expand All @@ -1098,6 +1102,9 @@ TEST_F(NegativeAndroidHardwareBuffer, InvalidBindBufferMemory) {
VkDeviceSize buffer_offset = (mem_reqs.size - 1) & ~(mem_reqs.alignment - 1);
if (buffer_offset > 0) {
m_errorMonitor->SetDesiredError("VUID-vkBindBufferMemory-size-01037");
if (memory_dedicated_requirements.requiresDedicatedAllocation) {
m_errorMonitor->SetDesiredError("VUID-vkBindBufferMemory-buffer-01444");
}
vk::BindBufferMemory(device(), buffer.handle(), memory.handle(), buffer_offset);
m_errorMonitor->VerifyFound();
}
Expand Down
36 changes: 33 additions & 3 deletions tests/unit/external_memory_sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,20 @@ TEST_F(NegativeExternalMemorySync, ExportBufferHandleType) {
// Create export memory with a different handle type
auto export_memory_info = vku::InitStruct<VkExportMemoryAllocateInfo>(dedicated_allocation ? &dedicated_info : nullptr);
export_memory_info.handleTypes = handle_type2;
VkMemoryRequirements buffer_mem_reqs;
vk::GetBufferMemoryRequirements(device(), buffer.handle(), &buffer_mem_reqs);
VkBufferMemoryRequirementsInfo2 buffer_memory_requirements_info = vku::InitStructHelper();
buffer_memory_requirements_info.buffer = buffer.handle();
VkMemoryDedicatedRequirements memory_dedicated_requirements = vku::InitStructHelper();
VkMemoryRequirements2 mem_reqs2 = vku::InitStructHelper(&memory_dedicated_requirements);
vk::GetBufferMemoryRequirements2(device(), &buffer_memory_requirements_info, &mem_reqs2);
VkMemoryRequirements buffer_mem_reqs = mem_reqs2.memoryRequirements;
const auto alloc_info = vkt::DeviceMemory::GetResourceAllocInfo(*m_device, buffer_mem_reqs, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
&export_memory_info);
const auto memory = vkt::DeviceMemory(*m_device, alloc_info);

m_errorMonitor->SetDesiredError("VUID-vkBindBufferMemory-memory-02726");
if (memory_dedicated_requirements.requiresDedicatedAllocation) {
m_errorMonitor->SetDesiredError("VUID-vkBindBufferMemory-buffer-01444");
}
vk::BindBufferMemory(device(), buffer.handle(), memory.handle(), 0);
m_errorMonitor->VerifyFound();

Expand All @@ -444,6 +451,9 @@ TEST_F(NegativeExternalMemorySync, ExportBufferHandleType) {
bind_buffer_info.memory = memory.handle();

m_errorMonitor->SetDesiredError("VUID-VkBindBufferMemoryInfo-memory-02726");
if (memory_dedicated_requirements.requiresDedicatedAllocation) {
m_errorMonitor->SetDesiredError("VUID-VkBindBufferMemoryInfo-buffer-01444");
}
vk::BindBufferMemory2(device(), 1, &bind_buffer_info);
m_errorMonitor->VerifyFound();
}
Expand Down Expand Up @@ -1347,6 +1357,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 +1371,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 +2065,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 5f1c37a

Please sign in to comment.