Skip to content

Add spaceship operator for vk handles#2498

Merged
asuessenbach merged 1 commit intoKhronosGroup:mainfrom
YaaZ:handle-spaceship
Feb 23, 2026
Merged

Add spaceship operator for vk handles#2498
asuessenbach merged 1 commit intoKhronosGroup:mainfrom
YaaZ:handle-spaceship

Conversation

@YaaZ
Copy link
Copy Markdown
Contributor

@YaaZ YaaZ commented Feb 21, 2026

Some comparisons rely on implicit conversions (#2001), which do not work when VULKAN_HPP_TYPESAFE_CONVERSION=0 (which is default on 32-bit platforms).
Specifically, compilation fails with VULKAN_HPP_TYPESAFE_CONVERSION=0 and VULKAN_HPP_HAS_SPACESHIP_OPERATOR, because structs try to use the spaceship operator for comparing their member handles.
For instance, vk::PipelineShaderStageCreateInfo:

vulkan/vulkan_structs.hpp(27059): error C2678: binary '<=>': no operator found which takes a left-hand operand of type 'const vk::ShaderModule' (or there is no acceptable conversion)
vulkan/vulkan_structs.hpp(27059): note: could be 'built-in C++ operator<=>(int, int)'
vulkan/vulkan_structs.hpp(27059): note: '<=>': cannot convert argument 1 from 'const vk::ShaderModule' to 'int'
vulkan/vulkan_structs.hpp(27059): note: or       'built-in C++ operator<=>(VkShaderModule, VkShaderModule)'
vulkan/vulkan_structs.hpp(27059): note: '<=>': cannot convert argument 1 from 'const vk::ShaderModule' to 'VkShaderModule'

Note that I did not run the generator - clang-format gave me a crazy diff for some reason, so I patched vulkan_handles.hpp by hand.

@asuessenbach
Copy link
Copy Markdown
Contributor

Looks good, even with manual adjustments in vulkan.hpp.

Have you used clang-format 21.1.0?

@asuessenbach asuessenbach merged commit a0a4c22 into KhronosGroup:main Feb 23, 2026
25 checks passed
@YaaZ
Copy link
Copy Markdown
Contributor Author

YaaZ commented Feb 23, 2026

No, mine is 18.1.8, gonna update it.

@YaaZ
Copy link
Copy Markdown
Contributor Author

YaaZ commented Feb 23, 2026

Right, 21.1.8 gives a clean diff, thanks.

@YaaZ YaaZ deleted the handle-spaceship branch February 23, 2026 23:50
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.

2 participants