KhronosGroup / KhronosGroup/Vulkan-ValidationLayers
Warn when `VkExternalImageFormatProperties` is present without `VkPhysicalDeviceExternalImageFormatInfo`
- Dominant language
- C++
- Stars
- 1k
- Forks
- 504
- Avg merge
- 11h 35m
- Merged PRs (30d)
- 224
Description
**Describe the situation in which you encountered the missing validation**
When having [`VkExternalImageFormatProperties`](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkExternalImageFormatProperties.html) in [`VkImageFormatProperties2`](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkImageFormatProperties2.html)
and calling [`vkGetPhysicalDeviceImageFormatProperties2()`](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties2.html), all its fields remain uninitialized.
When reading [the description of the contained `VkExternalMemoryProperties` structure](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkExternalMemoryProperties.html#_description) more closely, the `handleType` referenced in the `# Members` section above appears to refer to [`VkPhysicalDeviceExternalImageFormatInfo`](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceExternalImageFormatInfo.html): it turns out this struct must be extending [`VkPhysicalDeviceImageFormatInfo2`](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceImageFormatInfo2.html) and set to the **specific handle type one wishes to import or export** before _its features and compatibility with other handle types_ are exposed.
In short, I expected a VUID to be raised when `VkExternalImageFormatProperties` is in the `pNext` chain of `VkImageFormatProperties2` **without having `VkPhysicalDeviceExternalImageFormatInfo` in the `pNext` chain of `VkPhysicalDeviceImageFormatInfo2`** while calling `vkGetPhysicalDeviceImageFormatProperties2()`.
(while this becomes obvious when reading the documentation properly, too-quickly skimming it lead at least me to believe that `VkExternalMemoryProperties::compatibleHandleTypes` was going to be filled with all the handle types that the image might be imported/exported as...)
Perhaps such validation is not possible because of the following mention in [`VkPhysicalDeviceExternalImageFormatInfo`'s description](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceExternalImageFormatInfo.html#_description):
> If handleType is 0, [vkGetPhysicalDeviceImageFormatProperties2](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties2.html) will behave as if [VkPhysicalDeviceExternalImageFormatInfo](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceExternalImageFormatInfo.html) was not present, and [VkExternalImageFormatProperties](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkExternalImageFormatProperties.html) will be ignored.
I.e. it is expected to be _silently ignored_ (😞) when the struct is missing or its `handleType` set to `0`?
~**Valid Usage IDs requested**~
~There doesn't seem to be a VUID for this yet, because of the "will be ignored" clause above?~
EDIT after SI meeting: no VU should be issued retroactively, only a warning would be nice to be issued. This is what I requested initially by filing to the VVL repository.
**Additional context**
Perhaps the documentation would have been easier to read if mentions of `handleType` were actually linking through to `VkPhysicalDeviceExternalImageFormatInfo::handleType`, and perhaps this struct should be mentioned in the `# Name` section or `# C Specification`, i.e. extending:
> VkExternalMemoryProperties - Structure specifying external memory handle type capabilities
To something like:
> VkExternalMemoryProperties - Structure specifying external memory handle type capabilities for an external handle specified in/by stype:VkPhysicalDeviceExternalImageFormatInfo
After all [`VkPhysicalDeviceExternalImageFormatInfo`](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceExternalImageFormatInfo.html) mentions `VkExternalImageFormatProperties` (but the link is broken?), there's just no obvious link in reverse.
---
And maybe the surrounding [`VkExternalImageFormatProperties`](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkExternalImageFormatProperties.html) should mention the same?
Contributor guide
Assessment
This issue has not been assessed yet.