From a11116394af0efd310ac3d74194dd3701295d96b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=BC=C3=9Fenbach?= Date: Tue, 21 Mar 2023 11:22:48 +0100 Subject: [PATCH] Simplified and corrected structure alias handling. (#1538) --- VulkanHppGenerator.cpp | 39 +++++++++++-------------------------- VulkanHppGenerator.hpp | 1 - vulkan/vulkansc_hash.hpp | 2 ++ vulkan/vulkansc_structs.hpp | 32 ++++++++++++++++-------------- 4 files changed, 30 insertions(+), 44 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 9a85637..1d5db59 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -1129,17 +1129,6 @@ void VulkanHppGenerator::checkStructCorrectness() const m_structs.find( structAlias.second.name ) != m_structs.end(), structAlias.second.xmlLine, "unknown struct alias <" + structAlias.second.name + ">" ); } - for ( auto const & structAliasInverse : m_structsAliasesInverse ) - { - if ( m_structs.find( structAliasInverse.first ) == m_structs.end() ) - { - assert( !structAliasInverse.second.empty() ); - auto aliasIt = m_structsAliases.find( *structAliasInverse.second.begin() ); - assert( aliasIt != m_structsAliases.end() ); - checkForError( false, aliasIt->second.xmlLine, "struct <" + aliasIt->first + "> uses unknown alias <" + aliasIt->second.name + ">" ); - } - } - std::set sTypeValues; for ( auto const & structure : m_structs ) { @@ -9271,8 +9260,7 @@ ${hashSum} }; ${leave})"; - auto [enter, leave] = - generateProtection( m_structsAliasesInverse.find( structure.first ) == m_structsAliasesInverse.end() ? getProtectFromType( structure.first ) : "" ); + auto [enter, leave] = generateProtection( getProtectFromType( structure.first ) ); std::string structureType = stripPrefix( structure.first, "Vk" ); std::string structureName = startLowerCase( structureType ); @@ -9398,8 +9386,7 @@ ${structs} std::string VulkanHppGenerator::generateStructure( std::pair const & structure ) const { - auto [enter, leave] = - generateProtection( m_structsAliasesInverse.find( structure.first ) == m_structsAliasesInverse.end() ? getProtectFromType( structure.first ) : "" ); + auto [enter, leave] = generateProtection( getProtectFromType( structure.first ) ); std::string str = "\n" + enter; @@ -9519,12 +9506,11 @@ ${members} str += replaceWithMap( cppTypeTemplate, { { "sTypeValue", sTypeValue }, { "structureType", structureType } } ); } - auto aliasIt = m_structsAliasesInverse.find( structure.first ); - if ( aliasIt != m_structsAliasesInverse.end() ) + for ( auto const & alias : m_structsAliases ) { - for ( std::string const & alias : aliasIt->second ) + if ( alias.second.name == structure.first ) { - str += " using " + stripPrefix( alias, "Vk" ) + " = " + structureType + ";\n"; + str += " using " + stripPrefix( alias.first, "Vk" ) + " = " + structureType + ";\n"; } } @@ -9584,8 +9570,7 @@ std::string VulkanHppGenerator::generateStructExtendsStructs( std::vectorfirst ) == m_structsAliasesInverse.end() ? getProtectFromType( itExtend->first ) : "" ); + auto [subEnter, subLeave] = generateProtection( getProtectFromType( itExtend->first ) ); if ( enter != subEnter ) { @@ -9644,12 +9629,12 @@ std::string VulkanHppGenerator::generateStructForwardDeclarations( std::vectorfirst, "Vk" ); str += ( structIt->second.isUnion ? " union " : " struct " ) + structureType + ";\n"; - auto inverseIt = m_structsAliasesInverse.find( type ); - if ( inverseIt != m_structsAliasesInverse.end() ) + + for ( auto const & alias : m_structsAliases ) { - for ( auto alias : inverseIt->second ) + if ( alias.second.name == type ) { - str += " using " + stripPrefix( alias, "Vk" ) + " = " + structureType + ";\n"; + str += " using " + stripPrefix( alias.first, "Vk" ) + " = " + structureType + ";\n"; } } } @@ -10011,8 +9996,7 @@ std::string VulkanHppGenerator::generateTypenameCheck( std::vector const std::string VulkanHppGenerator::generateUnion( std::pair const & structure ) const { - auto [enter, leave] = - generateProtection( m_structsAliasesInverse.find( structure.first ) == m_structsAliasesInverse.end() ? getProtectFromType( structure.first ) : "" ); + auto [enter, leave] = generateProtection( getProtectFromType( structure.first ) ); std::string unionName = stripPrefix( structure.first, "Vk" ); bool firstMember = true; @@ -12909,7 +12893,6 @@ void VulkanHppGenerator::readTypeStruct( tinyxml2::XMLElement const * element, b checkForError( m_types.insert( { name, { TypeCategory::Struct, line } } ).second, line, "struct <" + name + "> already specified" ); assert( m_structsAliases.find( name ) == m_structsAliases.end() ); m_structsAliases[name] = { alias, line }; - checkForError( m_structsAliasesInverse[alias].insert( name ).second, line, "structure alias <" + name + "> already used with structure <" + alias + ">" ); } else diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index c339dde..b4e0d42 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -1028,7 +1028,6 @@ private: std::set m_RAIISpecialFunctions; std::map m_structs; std::map m_structsAliases; - std::map> m_structsAliasesInverse; std::map m_tags; std::map m_types; std::string m_typesafeCheck; diff --git a/vulkan/vulkansc_hash.hpp b/vulkan/vulkansc_hash.hpp index 528ebab..91523a8 100644 --- a/vulkan/vulkansc_hash.hpp +++ b/vulkan/vulkansc_hash.hpp @@ -4324,6 +4324,7 @@ namespace std } }; +# if defined( VK_USE_PLATFORM_SCI ) template <> struct hash { @@ -4338,6 +4339,7 @@ namespace std return seed; } }; +# endif /*VK_USE_PLATFORM_SCI*/ # if defined( VK_USE_PLATFORM_SCI ) template <> diff --git a/vulkan/vulkansc_structs.hpp b/vulkan/vulkansc_structs.hpp index c4d8838..60c2d11 100644 --- a/vulkan/vulkansc_structs.hpp +++ b/vulkan/vulkansc_structs.hpp @@ -31295,6 +31295,7 @@ namespace VULKAN_HPP_NAMESPACE using Type = PhysicalDeviceExternalMemoryHostPropertiesEXT; }; +#if defined( VK_USE_PLATFORM_SCI ) struct PhysicalDeviceExternalMemorySciBufFeaturesNV { using NativeType = VkPhysicalDeviceExternalMemorySciBufFeaturesNV; @@ -31302,7 +31303,7 @@ namespace VULKAN_HPP_NAMESPACE static const bool allowDuplicate = false; static VULKAN_HPP_CONST_OR_CONSTEXPR StructureType structureType = StructureType::ePhysicalDeviceExternalMemorySciBufFeaturesNV; -#if !defined( VULKAN_HPP_NO_STRUCT_CONSTRUCTORS ) +# if !defined( VULKAN_HPP_NO_STRUCT_CONSTRUCTORS ) VULKAN_HPP_CONSTEXPR PhysicalDeviceExternalMemorySciBufFeaturesNV( VULKAN_HPP_NAMESPACE::Bool32 sciBufImport_ = {}, VULKAN_HPP_NAMESPACE::Bool32 sciBufExport_ = {}, void * pNext_ = nullptr ) VULKAN_HPP_NOEXCEPT @@ -31320,7 +31321,7 @@ namespace VULKAN_HPP_NAMESPACE } PhysicalDeviceExternalMemorySciBufFeaturesNV & operator=( PhysicalDeviceExternalMemorySciBufFeaturesNV const & rhs ) VULKAN_HPP_NOEXCEPT = default; -#endif /*VULKAN_HPP_NO_STRUCT_CONSTRUCTORS*/ +# endif /*VULKAN_HPP_NO_STRUCT_CONSTRUCTORS*/ PhysicalDeviceExternalMemorySciBufFeaturesNV & operator=( VkPhysicalDeviceExternalMemorySciBufFeaturesNV const & rhs ) VULKAN_HPP_NOEXCEPT { @@ -31328,7 +31329,7 @@ namespace VULKAN_HPP_NAMESPACE return *this; } -#if !defined( VULKAN_HPP_NO_STRUCT_SETTERS ) +# if !defined( VULKAN_HPP_NO_STRUCT_SETTERS ) VULKAN_HPP_CONSTEXPR_14 PhysicalDeviceExternalMemorySciBufFeaturesNV & setPNext( void * pNext_ ) VULKAN_HPP_NOEXCEPT { pNext = pNext_; @@ -31346,7 +31347,7 @@ namespace VULKAN_HPP_NAMESPACE sciBufExport = sciBufExport_; return *this; } -#endif /*VULKAN_HPP_NO_STRUCT_SETTERS*/ +# endif /*VULKAN_HPP_NO_STRUCT_SETTERS*/ operator VkPhysicalDeviceExternalMemorySciBufFeaturesNV const &() const VULKAN_HPP_NOEXCEPT { @@ -31358,35 +31359,35 @@ namespace VULKAN_HPP_NAMESPACE return *reinterpret_cast( this ); } -#if defined( VULKAN_HPP_USE_REFLECT ) -# if 14 <= VULKAN_HPP_CPP_VERSION +# if defined( VULKAN_HPP_USE_REFLECT ) +# if 14 <= VULKAN_HPP_CPP_VERSION auto -# else +# else std::tuple -# endif +# endif reflect() const VULKAN_HPP_NOEXCEPT { return std::tie( sType, pNext, sciBufImport, sciBufExport ); } -#endif +# endif -#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) +# if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) auto operator<=>( PhysicalDeviceExternalMemorySciBufFeaturesNV const & ) const = default; -#else +# else bool operator==( PhysicalDeviceExternalMemorySciBufFeaturesNV const & rhs ) const VULKAN_HPP_NOEXCEPT { -# if defined( VULKAN_HPP_USE_REFLECT ) +# if defined( VULKAN_HPP_USE_REFLECT ) return this->reflect() == rhs.reflect(); -# else +# else return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( sciBufImport == rhs.sciBufImport ) && ( sciBufExport == rhs.sciBufExport ); -# endif +# endif } bool operator!=( PhysicalDeviceExternalMemorySciBufFeaturesNV const & rhs ) const VULKAN_HPP_NOEXCEPT { return !operator==( rhs ); } -#endif +# endif public: VULKAN_HPP_NAMESPACE::StructureType sType = StructureType::ePhysicalDeviceExternalMemorySciBufFeaturesNV; @@ -31402,6 +31403,7 @@ namespace VULKAN_HPP_NAMESPACE }; using PhysicalDeviceExternalSciBufFeaturesNV = PhysicalDeviceExternalMemorySciBufFeaturesNV; +#endif /*VK_USE_PLATFORM_SCI*/ #if defined( VK_USE_PLATFORM_SCI ) struct PhysicalDeviceExternalSciSync2FeaturesNV