Skip to content

layers: Check dedicated export handle types at allocation - #13245

Merged
spencer-lunarg merged 1 commit into
KhronosGroup:mainfrom
apollo-2006:dedicated-export-alloc
Sep 30, 2026
Merged

spencer-lunarg merged 1 commit into
KhronosGroup:mainfrom
apollo-2006:dedicated-export-alloc

Conversation

@apollo-2006

@apollo-2006 apollo-2006 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #10507, picking up from the discussion there. As was pointed out on the issue, 00639 itself is always satisfied once VkMemoryDedicatedAllocateInfo names a buffer or image, but that's also exactly when the export handle types can be checked against the resource at vkAllocateMemory. So this is a first go at that check, using UNASSIGNED- VUIDs so the spec side can settle the wording:

  • UNASSIGNED-VkMemoryAllocateInfo-pNext-dedicated-buffer-export
  • UNASSIGNED-VkMemoryAllocateInfo-pNext-dedicated-image-export

When the allocation is dedicated and exported, it checks that each handle type in VkExportMemoryAllocateInfo::handleTypes is reported as exportable for the dedicated buffer or image, and, once they all are, that they're compatible with each other. It's essentially what 09860 checks at bind time today, just done a little earlier, with the resource the allocation is actually meant for.

A few notes on how I went about it:

  • The external memory queries that HasExternalMemoryImportSupport already did (including the DRM format modifier path for images) now live in GetExternalMemoryProperties, so the import checks and the new check share them.
  • For dedicated memory, I skipped the bind-time 09860 exportable/compatible check so the same mistake doesn't get reported twice. 00639 and the other bind-time checks are unchanged, and non-dedicated memory is still checked at bind time exactly as before. If you'd rather keep both reports, I'm happy to drop that part.
  • Tensors (VkMemoryDedicatedAllocateInfoTensorARM) aren't covered here, but I'd be glad to add them in a follow-up if that would be useful.

Tests:

  • NegativeExternalMemorySync.DedicatedBufferExportUnsupportedHandleType and DedicatedImageExportUnsupportedHandleType always allocate dedicated memory with an unsupported handle type and expect the new VUIDs at vkAllocateMemory. They fail on main and pass with this change on the mock ICD, lavapipe and RADV (RX 9070 XT).
  • PositiveExternalMemorySync.DedicatedExport allocates and binds valid dedicated exports for a buffer and an image.
  • BufferMemoryWith{Unsupported,Incompatible}HandleType(s) and ImageMemoryWith{Unsupported,Incompatible}HandleType(s) only use a dedicated allocation when the driver requires one, so they now expect the new VUID in that case and 09860 at bind otherwise. Between the three drivers, both paths get exercised.
  • Full suite with the mock ICD and max_profile.json: 6067 passed, no failures. Full suite on lavapipe and RADV: the same results as main apart from the new tests (RADV only differs in one test that's flaky on main too).

Very open to reshaping any of this to fit however you'd like the spec change to read.

@apollo-2006
apollo-2006 requested a review from a team as a code owner September 28, 2026 15:39
@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

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

@arno-lunarg arno-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.

LGTM

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

Author 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 136825.

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build # 24715 running.

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build # 24715 failed.

@spencer-lunarg

Copy link
Copy Markdown
Contributor

hitting

[ RUN      ] NegativeAndroidHardwareBuffer.ExportMemoryAllocateImage
/home/lunarg/.jenkins/vz0/Release64/Vulkan-ValidationLayers/tests/framework/error_monitor.cpp:327: Failure
Failed
Validation Error: [ UNASSIGNED-VkMemoryAllocateInfo-pNext-dedicated-image-export ] | MessageID = 0xf2edc553
vkAllocateMemory(): pAllocateInfo->pNext<VkExportMemoryAllocateInfo>.handleTypes (VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID) includes VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID, which is not reported as exportable for the dedicated VkImage 0x1f000000001f.
Objects: 1
    [0] VkImage 0x1f000000001f

... when I get time this week, will debug on my local device, need to understand why the AHB is not marked exportable when it clearly should be

@apollo-2006
apollo-2006 force-pushed the dedicated-export-alloc branch from 6ac4e89 to 0f1cb25 Compare September 30, 2026 00:20
@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

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

@apollo-2006

apollo-2006 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

I think I found it: that test's image uses an external format (VK_FORMAT_UNDEFINED with VkExternalFormatANDROID), so there's no real format to query export support with, and the check ends up calling it not exportable. I pushed a small fix that skips images with an external Android format (HasAHBFormat()), so hopefully that saves you the device debugging. I can't run the AHB tests here though, so if CI still isn't happy, a look on your device would be super appreciated (when you have the time :) )

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build queued with queue ID 137173.

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build # 24720 running.

@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build # 24720 passed.

@spencer-lunarg
spencer-lunarg merged commit 04cbe10 into KhronosGroup:main Sep 30, 2026
21 checks passed
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.

VkMemoryAllocateInfo dedicated allocation related VUs are incorrectly validated at vkBind*Memory time

4 participants