From c2c49478e9f2e03023f37ccd18237252827d1008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=BC=C3=9Fenbach?= Date: Fri, 6 Dec 2024 09:56:10 +0100 Subject: [PATCH] Re-add compare operators of vk-handles, needed for 32bit builds. (#2010) --- VulkanHppGenerator.cpp | 61 +++++++++++++++++++++++++++++++++++---- vulkan/vulkan_handles.hpp | 51 ++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 5 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index ea228d6..95f386b 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -228,11 +228,62 @@ void VulkanHppGenerator::generateHandlesHppFile() const namespace VULKAN_HPP_NAMESPACE { -${structForwardDeclarations} -${handleForwardDeclarations} -${uniqueHandles} -${handles} + ${structForwardDeclarations} + ${handleForwardDeclarations} + ${uniqueHandles} + ${handles} } // namespace VULKAN_HPP_NAMESPACE + +// operators to compare vk::-handles +# if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) +template ::value, int>::type = 0> +bool operator<=>( T const & lhs, T const & rhs ) +{ + return static_cast( lhs ) <=> static_cast( rhs ); +} +#else +template ::value, int>::type = 0> +bool operator==( T const & lhs, T const & rhs ) +{ + return static_cast( lhs ) == static_cast( rhs ); +} + +template ::value, int>::type = 0> +bool operator!=( T const & lhs, T const & rhs ) +{ + return static_cast( lhs ) != static_cast( rhs ); +} + +template ::value, int>::type = 0> +bool operator<( T const & lhs, T const & rhs ) +{ + return static_cast( lhs ) < static_cast( rhs ); +} +#endif + +template ::value, int>::type = 0> +bool operator==( T const & v, std::nullptr_t ) +{ + return !v; +} + +template ::value, int>::type = 0> +bool operator==( std::nullptr_t, T const & v ) +{ + return !v; +} + +template ::value, int>::type = 0> +bool operator!=( T const & v, std::nullptr_t ) +{ + return !!v; +} + +template ::value, int>::type = 0> +bool operator!=( std::nullptr_t, T const & v ) +{ + return !!v; +} #endif )"; @@ -8018,7 +8069,7 @@ ${typesafeConversionConditionalEnd} return *this; } -${commands} + ${commands} ${typesafeExplicitKeyword}operator Vk${className}() const VULKAN_HPP_NOEXCEPT { return m_${memberName}; diff --git a/vulkan/vulkan_handles.hpp b/vulkan/vulkan_handles.hpp index 617126a..4e8aafd 100644 --- a/vulkan/vulkan_handles.hpp +++ b/vulkan/vulkan_handles.hpp @@ -17707,4 +17707,55 @@ namespace VULKAN_HPP_NAMESPACE #endif /* VULKAN_HPP_DISABLE_ENHANCED_MODE */ } // namespace VULKAN_HPP_NAMESPACE + +// operators to compare vk::-handles +#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) +template ::value, int>::type = 0> +bool operator<=>( T const & lhs, T const & rhs ) +{ + return static_cast( lhs ) <=> static_cast( rhs ); +} +#else +template ::value, int>::type = 0> +bool operator==( T const & lhs, T const & rhs ) +{ + return static_cast( lhs ) == static_cast( rhs ); +} + +template ::value, int>::type = 0> +bool operator!=( T const & lhs, T const & rhs ) +{ + return static_cast( lhs ) != static_cast( rhs ); +} + +template ::value, int>::type = 0> +bool operator<( T const & lhs, T const & rhs ) +{ + return static_cast( lhs ) < static_cast( rhs ); +} +#endif + +template ::value, int>::type = 0> +bool operator==( T const & v, std::nullptr_t ) +{ + return !v; +} + +template ::value, int>::type = 0> +bool operator==( std::nullptr_t, T const & v ) +{ + return !v; +} + +template ::value, int>::type = 0> +bool operator!=( T const & v, std::nullptr_t ) +{ + return !!v; +} + +template ::value, int>::type = 0> +bool operator!=( std::nullptr_t, T const & v ) +{ + return !!v; +} #endif