Skip to content

layers: Report the import VUID of the struct that was used - #13430

Merged
spencer-lunarg merged 1 commit into
KhronosGroup:mainfrom
apollo-2006:import-support-vuid
Oct 15, 2026
Merged

spencer-lunarg merged 1 commit into
KhronosGroup:mainfrom
apollo-2006:import-support-vuid

Conversation

@apollo-2006

@apollo-2006 apollo-2006 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

While reading the external memory checks for #10507 I noticed that the bind-time "handle type must be importable" error always uses VUID-VkImportMemoryWin32HandleInfoKHR-handleType-09861, regardless of which import structure was used to import the memory. For example, on Linux, importing memory with VkImportMemoryFdInfoKHR and binding it to a buffer that cannot import that handle type would trigger this validation error:

Validation Error: [ VUID-VkImportMemoryWin32HandleInfoKHR-handleType-09861 ]
vkBindBufferMemory(): memory (VkDeviceMemory 0x...) was imported from handleType VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT but VkExternalBufferProperties does not report it as importable.

The fd and host pointer structs have their own VUIDs for the same rule (VUID-VkImportMemoryFdInfoKHR-handleType-09862, VUID-VkImportMemoryHostPointerInfoEXT-handleType-01747).

It chooses the VUID from the import struct in the memory's VkMemoryAllocateInfo chain, in the same order as GetImportHandleType, for the buffer/image/tensor binds. For Win32, the 09861 remains, so that ImportMemoryWin32BufferSupport works as before.

Tests:

  • NegativeExternalMemorySync.ImportMemoryFdBindBufferSupport and ImportMemoryFdBindImageSupport export a real DMA_BUF fd, then import it without a dedicated allocation and bind to a buffer/image which cannot import DMA_BUF. On main both get 09861; with this change they get 09862.
  • The buffer test runs on the test ICD, the image test on RADV (RX 9070 XT). Lavapipe can import DMA_BUF for both, so they are skipped.
  • The image test also allows VUID-vkBindImageMemory-image-01445: RADV requires those images to be dedicated, and the test deliberately isn't.
  • External memory tests pass on the test ICD and RADV.
  • Full suite on the test ICD with max_profile.json: 6530 pass, 0 failures.

I couldn't build the Win32 branch locally, but it's guarded the same way as GetImportHandleType. Happy to change how the VUID is picked if you'd rather do it differently.

@apollo-2006
apollo-2006 requested a review from a team as a code owner October 12, 2026 18:53
@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

User apollo-2006 not on autobuild list. Waiting for curator authorization before starting CI build.

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

User apollo-2006 not on autobuild list. Waiting for curator authorization before starting CI build.

@spencer-lunarg spencer-lunarg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix things

Comment thread layers/core_checks/cc_device_memory.cpp Resolved
Comment thread layers/core_checks/cc_device_memory.cpp Resolved
Comment thread tests/unit/external_memory_sync.cpp Resolved
@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

User apollo-2006 not on autobuild list. Waiting for curator authorization before starting CI build.

@spencer-lunarg spencer-lunarg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the final comment

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

User apollo-2006 not on autobuild list. Waiting for curator authorization before starting CI build.

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

User apollo-2006 not on autobuild list. Waiting for curator authorization before starting CI build.

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build queued with queue ID 154325.

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build # 24923 running.

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build # 24923 failed.

@spencer-lunarg

Copy link
Copy Markdown
Contributor

btw, NegativeExternalMemorySync.ImportMemoryFdBindImageSupport failed on Pixel 8, I can try to triage this when I get time later

When memory imported from an external handle is bound to a buffer,
image or tensor that can't import that handle type, the error was
always VUID-VkImportMemoryWin32HandleInfoKHR-handleType-09861, even on
Linux for memory imported with VkImportMemoryFdInfoKHR.

Report the VUID of the import structure the memory was allocated
with: 09861 for Win32 handles, 09862 for fds and 01747 for host
pointers.
@apollo-2006

Copy link
Copy Markdown
Contributor Author

Thanks for letting me know, im pretty sure its bc the image test had an image with an unsupported handle type (00990), which is allowed by RADV but likely not by Mali. The buffer test already uses the same helper, so I removed the image test - should pass CI now.

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

User apollo-2006 not on autobuild list. Waiting for curator authorization before starting CI build.

@spencer-lunarg

Copy link
Copy Markdown
Contributor

@apollo-2006 the fix I found locally was

index 4125608dd..a171ad801 100644
--- i/tests/unit/external_memory_sync.cpp
+++ w/tests/unit/external_memory_sync.cpp
@@ -2391,10 +2391,10 @@ TEST_F(NegativeExternalMemorySync, ImportMemoryFdBindImageSupport) {
     external_image_info.handleTypes = handle_type;
     auto image_info = vkt::Image::ImageCreateInfo2D(64, 64, 1, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_SAMPLED_BIT);
     image_info.pNext = &external_image_info;
-    if (FindSupportedExternalMemoryHandleTypes(Gpu(), image_info, VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) & handle_type) {
-        GTEST_SKIP() << "Need an image that can't import DMA_BUF";
+    if (!(FindSupportedExternalMemoryHandleTypes(Gpu(), image_info, VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT) & handle_type) ||
+        (FindSupportedExternalMemoryHandleTypes(Gpu(), image_info, VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) & handle_type)) {
+        GTEST_SKIP() << "Need an image that can export DMA_BUF but not import it";
     }
-    m_errorMonitor->SetAllowedFailureMsg("VUID-VkImageCreateInfo-pNext-00990");
     vkt::Image image(*m_device, image_info, vkt::no_mem);

so if you want to add it back with this patch

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

User apollo-2006 not on autobuild list. Waiting for curator authorization before starting CI build.

@apollo-2006

Copy link
Copy Markdown
Contributor Author

Nice, thanks for finding that :) added it back with your patch

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build queued with queue ID 158208.

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build # 24967 running.

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build # 24967 failed.

Comment thread tests/unit/external_memory_sync.cpp Outdated
external_image_info.handleTypes = handle_type;
auto image_info = vkt::Image::ImageCreateInfo2D(64, 64, 1, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_SAMPLED_BIT);
image_info.pNext = &external_image_info;
if (!(FindSupportedExternalMemoryHandleTypes(Gpu(), image_info, VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT) & handle_type) ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its getting things like

Failed
Validation Error: [ VUID-VkPhysicalDeviceExternalImageFormatInfo-handleType-parameter ] | MessageID = 0xd33b6c8a
vkGetPhysicalDeviceImageFormatProperties2(): pImageFormatInfo->pNext<VkPhysicalDeviceExternalImageFormatInfo>.handleType has VkExternalMemoryHandleTypeFlagBits values (VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA) that require the extensions VK_FUCHSIA_external_memory.
The Vulkan spec states: If handleType is not 0, handleType must be a valid VkExternalMemoryHandleTypeFlagBits value (https://docs.vulkan.org/spec/latest/chapters/capabilities.html#VUID-VkPhysicalDeviceExternalImageFormatInfo-handleType-parameter)
Objects: 1
    [0] VkPhysicalDevice 0xb40000796fcad670

... ok, this was my fault, I am happy to just remove the ImportMemoryFdBindImageSupport and call it a day

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, removed it :)

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

User apollo-2006 not on autobuild list. Waiting for curator authorization before starting CI build.

@spencer-lunarg
spencer-lunarg merged commit 78400fa into KhronosGroup:main Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants