Skip to content

scripts: Never chain VkFormatProperties3 and VkFormatProperties3KHR together - #1046

Closed
cgopinathc wants to merge 1 commit into
KhronosGroup:mainfrom
cgopinathc:fix-duplicate-format-properties3-stype
Closed

cgopinathc wants to merge 1 commit into
KhronosGroup:mainfrom
cgopinathc:fix-duplicate-format-properties3-stype

Conversation

@cgopinathc

Copy link
Copy Markdown
Contributor

Fixes #1045

Problem

Since transform --pull aliases was enabled for the transform_android step, expand_format_struct() emits both VkFormatProperties3 and VkFormatProperties3KHR for every VkFormatProperties entry. gen_profiles_solution.py only special-cases the KHR spelling, so the core name falls through and the generated library chains two structs with the same sType into the vkGetPhysicalDeviceFormatProperties2 pNext chain:

VkFormatProperties3KHR formatProperties3KHR{ VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3_KHR, nullptr };
VkFormatProperties3    formatProperties3   { VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3, &formatProperties3KHR };

This violates VUID-VkFormatProperties2-sType-unique and the outcome is driver dependent: PowerVR fills both copies, Arm Mali fills only the first and leaves the duplicate zeroed, so the comparator reports the format as unsupported. On Mali devices VP_ANDROID_15_requirements — and every profile inheriting it — is falsely reported as NOT SUPPORTED on VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT even though all bits are present.

Fix

  • scripts/source/format_flag_converter.py — expand_format_struct() now emits a single 64-bit struct: VkFormatProperties3 on Vulkan ≥ 1.3, otherwise VkFormatProperties3KHR when VK_KHR_format_feature_flags2 is enabled, otherwise none.
  • scripts/gen_profiles_solution.py — treat the core and KHR names as the same struct when building the format chain, and compare the single chained struct against capabilities written under either name, so a profile that still lists both can never produce a duplicate-sType chain.
  • scripts/tests/test_format_flags.py — regression test testExpandFormatStructSingle64BitAlias covering the version / extension combinations and KHR-named input normalisation.

Verification

Generated header now contains one VkFormatProperties3[KHR] per format chain (previously two), with the comparators for both 4444 formats intact.

Android profiles checker app results:

Profile Pixel 7 Pro (Mali-G710 r54p2) Pixel 9 Pro Fold (Mali-G715 r56p0) Pixel 10 Pro (PowerVR DXT)
VP_ANDROID_15_requirements ✅ (was ❌) ✅ (was ❌) ✅ unchanged
VP_ANDROID_16_requirements ✅ (was ❌) ✅ (was ❌) ✅ unchanged
VP_ANDROID_17_requirements ❌ genuine missing extensions ✅ (was ❌) ✅ unchanged

scripts/tests: 200 pass / 7 skipped. The 4 pre-existing failures in test_profiles_json_utils are unrelated and identical on main.

…ogether

'vkprofiles transform --pull aliases' expanded every VkFormatProperties
entry into both VkFormatProperties3 and VkFormatProperties3KHR. The two
names are aliases sharing a single sType, and gen_profiles_solution.py
only special-cased the KHR spelling, so the generated library chained two
structs with identical sType into one vkGetPhysicalDeviceFormatProperties2
pNext chain. That violates VUID-VkFormatProperties2-sType-unique and makes
the result driver dependent:

  - PowerVR fills every struct in the chain, so both copies pass.
  - Mali fills only the first struct of a given sType; the duplicate stays
    zeroed and the comparator reports the format as unsupported.

On Mali devices (Pixel 7 Pro / Mali-G710, Pixel 9 Pro Fold / Mali-G715)
this caused VP_ANDROID_15_requirements, and every profile that inherits
it, to be reported as NOT SUPPORTED on VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT
even though the device meets every requirement. The 'transform_android'
step started pulling aliases in 0b8bb3e / 5219d14 (Sept 2026); builds
generated straight from profiles/Android were unaffected.

Fix at the source and harden the generator:

  * format_flag_converter.py: expand_format_struct() now emits a single
    64-bit struct - VkFormatProperties3 on Vulkan >= 1.3, otherwise
    VkFormatProperties3KHR when VK_KHR_format_feature_flags2 is enabled.
  * gen_profiles_solution.py: treat the core and KHR names as the same
    struct when building the format chain, and compare the single chained
    struct against capabilities written under either name, so a profile
    that still lists both can never produce a duplicate-sType chain.
  * test_format_flags.py: add regression test covering the version /
    extension combinations.

Verified with the Android profiles checker app: cheetah and comet now
report VP_ANDROID_15/16 (and 17 on comet) as SUPPORTED; blazer unchanged.
@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

User cgopinathc not on autobuild list. Waiting for curator authorization before starting CI build.

1 similar comment
@ci-tester-lunarg

Copy link
Copy Markdown
Collaborator

User cgopinathc not on autobuild list. Waiting for curator authorization before starting CI build.

@christophe-lunarg

Copy link
Copy Markdown
Collaborator

Hi @cgopinathc !

Something is not clear to me. Using transform --pull aliases is particularly useful for Vulkan Profiles layer usage. This way, when Vulkan application developers query a feature or property from the Vulkan application, the Vulkan developer can do it from the approach desired (from any aliased the structure and member).

In the case of the Vulkan profiles API library generation, transform --pull aliases is also useful too but more to construct the Vulkan "bundle" structures because stripping all the duplicated structures that cause Vulkan validation errors.

As a result, after calling, transform --pull aliases, I would expect the C++ libraries to be build with vkprofiles library --strip to avoid having multiple VkFormatProperties* structures. This seems to work at least to some level as we can see in the tests here:

#1047.

If you could share reproduction cases, that would be great.

@cgopinathc

Copy link
Copy Markdown
Contributor Author

Hi @christophe-lunarg,

Thanks for taking a look — you're right that library --strip dedupes the profile JSON, and the #1047 tests confirm that. The problem is one stage later: gen_profiles_solution.py re-expands the format struct names when it builds the pNext chain, so the duplicate comes back in the generated C++ regardless of what the JSON looks like.

Same two steps the Android pipeline / vkprofiles_graph.json run

python3 scripts/vkprofiles.py transform --registry $REG/vk.xml
--input profiles/Android --output /tmp/t
--pull requirements ignore-unsupported aliases --strip helper-values --format flatten

python3 scripts/vkprofiles.py library --registry $REG/vk.xml
--input /tmp/t --input-profiles VP_ANDROID_15_requirements,VP_ANDROID_vulkan_profile_2022
--output /tmp/inc --mode header-only --strip --intermediate /tmp/im --config debug

After this we could compare the chains of VkFormatProperties3KHR and VkFormatProperties3

If we can fix only the gen_profiles_solution.py, that would be enough to fix the bug, what do you think?

@christophe-lunarg

Copy link
Copy Markdown
Collaborator

Hi @christophe-lunarg,

Thanks for taking a look — you're right that library --strip dedupes the profile JSON, and the #1047 tests confirm that. The problem is one stage later: gen_profiles_solution.py re-expands the format struct names when it builds the pNext chain, so the duplicate comes back in the generated C++ regardless of what the JSON looks like.

Same two steps the Android pipeline / vkprofiles_graph.json run

python3 scripts/vkprofiles.py transform --registry $REG/vk.xml --input profiles/Android --output /tmp/t --pull requirements ignore-unsupported aliases --strip helper-values --format flatten

python3 scripts/vkprofiles.py library --registry $REG/vk.xml --input /tmp/t --input-profiles VP_ANDROID_15_requirements,VP_ANDROID_vulkan_profile_2022 --output /tmp/inc --mode header-only --strip --intermediate /tmp/im --config debug

After this we could compare the chains of VkFormatProperties3KHR and VkFormatProperties3

If we can fix only the gen_profiles_solution.py, that would be enough to fix the bug, what do you think?

I am investigating. I think there are multiple issues. The "strip" duplicated VkFormatProperties* has issues.
I did a first PR #1055, but I need to do a second for the stripping.

@christophe-lunarg

Copy link
Copy Markdown
Collaborator

I believe this is resolved with #1055

Let me know what you think !

@christophe-lunarg

Copy link
Copy Markdown
Collaborator

I am closing for now but if I am missing something, please reopen !

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.

library: Generated library chains VkFormatProperties3 and VkFormatProperties3KHR together

3 participants