Simplified and corrected structure alias handling. (#1538)

This commit is contained in:
Andreas Süßenbach 2023-03-21 11:22:48 +01:00 committed by GitHub
parent c45c87b559
commit a11116394a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 44 deletions

View File

@ -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 + ">" ); 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<std::string> sTypeValues; std::set<std::string> sTypeValues;
for ( auto const & structure : m_structs ) for ( auto const & structure : m_structs )
{ {
@ -9271,8 +9260,7 @@ ${hashSum}
}; };
${leave})"; ${leave})";
auto [enter, leave] = auto [enter, leave] = generateProtection( getProtectFromType( structure.first ) );
generateProtection( m_structsAliasesInverse.find( structure.first ) == m_structsAliasesInverse.end() ? getProtectFromType( structure.first ) : "" );
std::string structureType = stripPrefix( structure.first, "Vk" ); std::string structureType = stripPrefix( structure.first, "Vk" );
std::string structureName = startLowerCase( structureType ); std::string structureName = startLowerCase( structureType );
@ -9398,8 +9386,7 @@ ${structs}
std::string VulkanHppGenerator::generateStructure( std::pair<std::string, StructureData> const & structure ) const std::string VulkanHppGenerator::generateStructure( std::pair<std::string, StructureData> const & structure ) const
{ {
auto [enter, leave] = auto [enter, leave] = generateProtection( getProtectFromType( structure.first ) );
generateProtection( m_structsAliasesInverse.find( structure.first ) == m_structsAliasesInverse.end() ? getProtectFromType( structure.first ) : "" );
std::string str = "\n" + enter; std::string str = "\n" + enter;
@ -9519,12 +9506,11 @@ ${members}
str += replaceWithMap( cppTypeTemplate, { { "sTypeValue", sTypeValue }, { "structureType", structureType } } ); str += replaceWithMap( cppTypeTemplate, { { "sTypeValue", sTypeValue }, { "structureType", structureType } } );
} }
auto aliasIt = m_structsAliasesInverse.find( structure.first ); for ( auto const & alias : m_structsAliases )
if ( aliasIt != m_structsAliasesInverse.end() )
{ {
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::vector<Requir
} }
} }
auto [subEnter, subLeave] = auto [subEnter, subLeave] = generateProtection( getProtectFromType( itExtend->first ) );
generateProtection( m_structsAliasesInverse.find( itExtend->first ) == m_structsAliasesInverse.end() ? getProtectFromType( itExtend->first ) : "" );
if ( enter != subEnter ) if ( enter != subEnter )
{ {
@ -9644,12 +9629,12 @@ std::string VulkanHppGenerator::generateStructForwardDeclarations( std::vector<R
{ {
std::string structureType = stripPrefix( structIt->first, "Vk" ); std::string structureType = stripPrefix( structIt->first, "Vk" );
str += ( structIt->second.isUnion ? " union " : " struct " ) + structureType + ";\n"; 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<size_t> const
std::string VulkanHppGenerator::generateUnion( std::pair<std::string, StructureData> const & structure ) const std::string VulkanHppGenerator::generateUnion( std::pair<std::string, StructureData> const & structure ) const
{ {
auto [enter, leave] = auto [enter, leave] = generateProtection( getProtectFromType( structure.first ) );
generateProtection( m_structsAliasesInverse.find( structure.first ) == m_structsAliasesInverse.end() ? getProtectFromType( structure.first ) : "" );
std::string unionName = stripPrefix( structure.first, "Vk" ); std::string unionName = stripPrefix( structure.first, "Vk" );
bool firstMember = true; 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" ); checkForError( m_types.insert( { name, { TypeCategory::Struct, line } } ).second, line, "struct <" + name + "> already specified" );
assert( m_structsAliases.find( name ) == m_structsAliases.end() ); assert( m_structsAliases.find( name ) == m_structsAliases.end() );
m_structsAliases[name] = { alias, line }; m_structsAliases[name] = { alias, line };
checkForError( m_structsAliasesInverse[alias].insert( name ).second, line, "structure alias <" + name + "> already used with structure <" + alias + ">" );
} }
else else

View File

@ -1028,7 +1028,6 @@ private:
std::set<std::string> m_RAIISpecialFunctions; std::set<std::string> m_RAIISpecialFunctions;
std::map<std::string, StructureData> m_structs; std::map<std::string, StructureData> m_structs;
std::map<std::string, AliasData> m_structsAliases; std::map<std::string, AliasData> m_structsAliases;
std::map<std::string, std::set<std::string>> m_structsAliasesInverse;
std::map<std::string, TagData> m_tags; std::map<std::string, TagData> m_tags;
std::map<std::string, TypeData> m_types; std::map<std::string, TypeData> m_types;
std::string m_typesafeCheck; std::string m_typesafeCheck;

View File

@ -4324,6 +4324,7 @@ namespace std
} }
}; };
# if defined( VK_USE_PLATFORM_SCI )
template <> template <>
struct hash<VULKAN_HPP_NAMESPACE::PhysicalDeviceExternalMemorySciBufFeaturesNV> struct hash<VULKAN_HPP_NAMESPACE::PhysicalDeviceExternalMemorySciBufFeaturesNV>
{ {
@ -4338,6 +4339,7 @@ namespace std
return seed; return seed;
} }
}; };
# endif /*VK_USE_PLATFORM_SCI*/
# if defined( VK_USE_PLATFORM_SCI ) # if defined( VK_USE_PLATFORM_SCI )
template <> template <>

View File

@ -31295,6 +31295,7 @@ namespace VULKAN_HPP_NAMESPACE
using Type = PhysicalDeviceExternalMemoryHostPropertiesEXT; using Type = PhysicalDeviceExternalMemoryHostPropertiesEXT;
}; };
#if defined( VK_USE_PLATFORM_SCI )
struct PhysicalDeviceExternalMemorySciBufFeaturesNV struct PhysicalDeviceExternalMemorySciBufFeaturesNV
{ {
using NativeType = VkPhysicalDeviceExternalMemorySciBufFeaturesNV; using NativeType = VkPhysicalDeviceExternalMemorySciBufFeaturesNV;
@ -31302,7 +31303,7 @@ namespace VULKAN_HPP_NAMESPACE
static const bool allowDuplicate = false; static const bool allowDuplicate = false;
static VULKAN_HPP_CONST_OR_CONSTEXPR StructureType structureType = StructureType::ePhysicalDeviceExternalMemorySciBufFeaturesNV; 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_CONSTEXPR PhysicalDeviceExternalMemorySciBufFeaturesNV( VULKAN_HPP_NAMESPACE::Bool32 sciBufImport_ = {},
VULKAN_HPP_NAMESPACE::Bool32 sciBufExport_ = {}, VULKAN_HPP_NAMESPACE::Bool32 sciBufExport_ = {},
void * pNext_ = nullptr ) VULKAN_HPP_NOEXCEPT void * pNext_ = nullptr ) VULKAN_HPP_NOEXCEPT
@ -31320,7 +31321,7 @@ namespace VULKAN_HPP_NAMESPACE
} }
PhysicalDeviceExternalMemorySciBufFeaturesNV & operator=( PhysicalDeviceExternalMemorySciBufFeaturesNV const & rhs ) VULKAN_HPP_NOEXCEPT = default; 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 PhysicalDeviceExternalMemorySciBufFeaturesNV & operator=( VkPhysicalDeviceExternalMemorySciBufFeaturesNV const & rhs ) VULKAN_HPP_NOEXCEPT
{ {
@ -31328,7 +31329,7 @@ namespace VULKAN_HPP_NAMESPACE
return *this; 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 VULKAN_HPP_CONSTEXPR_14 PhysicalDeviceExternalMemorySciBufFeaturesNV & setPNext( void * pNext_ ) VULKAN_HPP_NOEXCEPT
{ {
pNext = pNext_; pNext = pNext_;
@ -31346,7 +31347,7 @@ namespace VULKAN_HPP_NAMESPACE
sciBufExport = sciBufExport_; sciBufExport = sciBufExport_;
return *this; return *this;
} }
#endif /*VULKAN_HPP_NO_STRUCT_SETTERS*/ # endif /*VULKAN_HPP_NO_STRUCT_SETTERS*/
operator VkPhysicalDeviceExternalMemorySciBufFeaturesNV const &() const VULKAN_HPP_NOEXCEPT operator VkPhysicalDeviceExternalMemorySciBufFeaturesNV const &() const VULKAN_HPP_NOEXCEPT
{ {
@ -31358,7 +31359,7 @@ namespace VULKAN_HPP_NAMESPACE
return *reinterpret_cast<VkPhysicalDeviceExternalMemorySciBufFeaturesNV *>( this ); return *reinterpret_cast<VkPhysicalDeviceExternalMemorySciBufFeaturesNV *>( this );
} }
#if defined( VULKAN_HPP_USE_REFLECT ) # if defined( VULKAN_HPP_USE_REFLECT )
# if 14 <= VULKAN_HPP_CPP_VERSION # if 14 <= VULKAN_HPP_CPP_VERSION
auto auto
# else # else
@ -31368,11 +31369,11 @@ namespace VULKAN_HPP_NAMESPACE
{ {
return std::tie( sType, pNext, sciBufImport, sciBufExport ); 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; auto operator<=>( PhysicalDeviceExternalMemorySciBufFeaturesNV const & ) const = default;
#else # else
bool operator==( PhysicalDeviceExternalMemorySciBufFeaturesNV const & rhs ) const VULKAN_HPP_NOEXCEPT bool operator==( PhysicalDeviceExternalMemorySciBufFeaturesNV const & rhs ) const VULKAN_HPP_NOEXCEPT
{ {
# if defined( VULKAN_HPP_USE_REFLECT ) # if defined( VULKAN_HPP_USE_REFLECT )
@ -31386,7 +31387,7 @@ namespace VULKAN_HPP_NAMESPACE
{ {
return !operator==( rhs ); return !operator==( rhs );
} }
#endif # endif
public: public:
VULKAN_HPP_NAMESPACE::StructureType sType = StructureType::ePhysicalDeviceExternalMemorySciBufFeaturesNV; VULKAN_HPP_NAMESPACE::StructureType sType = StructureType::ePhysicalDeviceExternalMemorySciBufFeaturesNV;
@ -31402,6 +31403,7 @@ namespace VULKAN_HPP_NAMESPACE
}; };
using PhysicalDeviceExternalSciBufFeaturesNV = PhysicalDeviceExternalMemorySciBufFeaturesNV; using PhysicalDeviceExternalSciBufFeaturesNV = PhysicalDeviceExternalMemorySciBufFeaturesNV;
#endif /*VK_USE_PLATFORM_SCI*/
#if defined( VK_USE_PLATFORM_SCI ) #if defined( VK_USE_PLATFORM_SCI )
struct PhysicalDeviceExternalSciSync2FeaturesNV struct PhysicalDeviceExternalSciSync2FeaturesNV