Skip to content

Commit

Permalink
Re-add compare operators of vk-handles, needed for 32bit builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
asuessenbach committed Dec 5, 2024
1 parent 20ecea9 commit b99af3b
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 5 deletions.
61 changes: 56 additions & 5 deletions VulkanHppGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator<=>( T const & lhs, T const & rhs )
{
return static_cast<typename T::NativeType>( lhs ) <=> static_cast<typename T::NativeType>( rhs );
}
#else
template <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator==( T const & lhs, T const & rhs )
{
return static_cast<typename T::NativeType>( lhs ) == static_cast<typename T::NativeType>( rhs );
}

template <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator!=( T const & lhs, T const & rhs )
{
return static_cast<typename T::NativeType>( lhs ) != static_cast<typename T::NativeType>( rhs );
}

template <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator<( T const & lhs, T const & rhs )
{
return static_cast<typename T::NativeType>( lhs ) < static_cast<typename T::NativeType>( rhs );
}
#endif

template <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator==( T const & v, std::nullptr_t )
{
return !v;
}

template <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator==( std::nullptr_t, T const & v )
{
return !v;
}

template <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator!=( T const & v, std::nullptr_t )
{
return !!v;
}

template <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator!=( std::nullptr_t, T const & v )
{
return !!v;
}
#endif
)";

Expand Down Expand Up @@ -8018,7 +8069,7 @@ std::string VulkanHppGenerator::generateHandle( std::pair<std::string, HandleDat
return *this;
}

${commands}
${commands}
${typesafeExplicitKeyword}operator Vk${className}() const VULKAN_HPP_NOEXCEPT
{
return m_${memberName};
Expand Down
51 changes: 51 additions & 0 deletions vulkan/vulkan_handles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator<=>( T const & lhs, T const & rhs )
{
return static_cast<typename T::NativeType>( lhs ) <=> static_cast<typename T::NativeType>( rhs );
}
#else
template <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator==( T const & lhs, T const & rhs )
{
return static_cast<typename T::NativeType>( lhs ) == static_cast<typename T::NativeType>( rhs );
}

template <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator!=( T const & lhs, T const & rhs )
{
return static_cast<typename T::NativeType>( lhs ) != static_cast<typename T::NativeType>( rhs );
}

template <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator<( T const & lhs, T const & rhs )
{
return static_cast<typename T::NativeType>( lhs ) < static_cast<typename T::NativeType>( rhs );
}
#endif

template <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator==( T const & v, std::nullptr_t )
{
return !v;
}

template <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator==( std::nullptr_t, T const & v )
{
return !v;
}

template <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator!=( T const & v, std::nullptr_t )
{
return !!v;
}

template <typename T, typename std::enable_if<VULKAN_HPP_NAMESPACE::isVulkanHandleType<T>::value, int>::type = 0>
bool operator!=( std::nullptr_t, T const & v )
{
return !!v;
}
#endif

0 comments on commit b99af3b

Please sign in to comment.