Change requiredIn in TypeData from std::string to std::set<std::string> (#1514)

+ some member data renaming
This commit is contained in:
Andreas Süßenbach 2023-02-20 20:01:34 +01:00 committed by GitHub
parent f7efd5e55e
commit 71acf3515b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 716 additions and 789 deletions

View File

@ -562,7 +562,7 @@ void VulkanHppGenerator::addCommand( std::string const & name, CommandData & com
checkForError( m_commands.insert( std::make_pair( name, commandData ) ).second, commandData.xmlLine, "already encountered command <" + name + ">" ); checkForError( m_commands.insert( std::make_pair( name, commandData ) ).second, commandData.xmlLine, "already encountered command <" + name + ">" );
} }
void VulkanHppGenerator::addMissingFlagBits( std::vector<RequireData> & requireData, std::string const & referencedIn ) void VulkanHppGenerator::addMissingFlagBits( std::vector<RequireData> & requireData, std::string const & requiredIn )
{ {
for ( auto & require : requireData ) for ( auto & require : requireData )
{ {
@ -591,7 +591,7 @@ void VulkanHppGenerator::addMissingFlagBits( std::vector<RequireData> & requireD
m_enums.insert( std::make_pair( flagBits, EnumData{ .isBitmask = true, .xmlLine = 0 } ) ); m_enums.insert( std::make_pair( flagBits, EnumData{ .isBitmask = true, .xmlLine = 0 } ) );
assert( m_types.find( flagBits ) == m_types.end() ); assert( m_types.find( flagBits ) == m_types.end() );
m_types.insert( std::make_pair( flagBits, TypeData{ .category = TypeCategory::Bitmask, .referencedIn = referencedIn } ) ); m_types.insert( std::make_pair( flagBits, TypeData{ .category = TypeCategory::Bitmask, .requiredIn = { requiredIn } } ) );
} }
else else
{ {
@ -769,11 +769,11 @@ void VulkanHppGenerator::checkBitmaskCorrectness() const
{ {
for ( auto const & bitmask : m_bitmasks ) for ( auto const & bitmask : m_bitmasks )
{ {
// check that a bitmask is referenced somewhere // check that a bitmask is required somewhere
// I think, it's not forbidden to not reference a bitmask, but it would probably be not intended? // I think, it's not forbidden to not reference a bitmask, but it would probably be not intended?
auto typeIt = m_types.find( bitmask.first ); auto typeIt = m_types.find( bitmask.first );
assert( typeIt != m_types.end() ); assert( typeIt != m_types.end() );
checkForError( !typeIt->second.referencedIn.empty(), bitmask.second.xmlLine, "bitmask <" + bitmask.first + "> not listed in any feature or extension" ); checkForError( !typeIt->second.requiredIn.empty(), bitmask.second.xmlLine, "bitmask <" + bitmask.first + "> not required in any feature or extension" );
// check that the requirement is an enum // check that the requirement is an enum
if ( !bitmask.second.requirements.empty() ) if ( !bitmask.second.requirements.empty() )
@ -805,7 +805,7 @@ void VulkanHppGenerator::checkCommandCorrectness() const
{ {
// check that a command is referenced somewhere // check that a command is referenced somewhere
// I think, it's not forbidden to not reference a function, but it would probably be not intended? // I think, it's not forbidden to not reference a function, but it would probably be not intended?
checkForError( !command.second.referencedIn.empty(), command.second.xmlLine, "command <" + command.first + "> not listed in any feature or extension" ); checkForError( !command.second.requiredIn.empty(), command.second.xmlLine, "command <" + command.first + "> not required in any feature or extension" );
// check for unknown error or succes codes // check for unknown error or succes codes
for ( auto const & ec : command.second.errorCodes ) for ( auto const & ec : command.second.errorCodes )
@ -860,11 +860,11 @@ void VulkanHppGenerator::checkEnumCorrectness() const
{ {
for ( auto const & e : m_enums ) for ( auto const & e : m_enums )
{ {
// check that a bitmask is referenced somewhere // check that a bitmask is required somewhere
// it's not forbidden to not reference a bitmask, and in fact that happens! So just warn here // it's not forbidden to not reference a bitmask, and in fact that happens! So just warn here
auto typeIt = m_types.find( e.first ); auto typeIt = m_types.find( e.first );
assert( typeIt != m_types.end() ); assert( typeIt != m_types.end() );
checkForWarning( !typeIt->second.referencedIn.empty(), e.second.xmlLine, "enum <" + e.first + "> not listed in any feature or extension" ); checkForWarning( !typeIt->second.requiredIn.empty(), e.second.xmlLine, "enum <" + e.first + "> not required in any feature or extension" );
// check that the aliasNames are known enum values or known aliases // check that the aliasNames are known enum values or known aliases
for ( auto const & alias : e.second.aliases ) for ( auto const & alias : e.second.aliases )
@ -944,10 +944,10 @@ void VulkanHppGenerator::checkEnumCorrectness( std::vector<RequireData> const &
{ {
auto requireTypeIt = m_types.find( bitmaskIt->second.requirements ); auto requireTypeIt = m_types.find( bitmaskIt->second.requirements );
assert( requireTypeIt != m_types.end() ); assert( requireTypeIt != m_types.end() );
checkForError( !requireTypeIt->second.referencedIn.empty(), checkForError( !requireTypeIt->second.requiredIn.empty(),
bitmaskIt->second.xmlLine, bitmaskIt->second.xmlLine,
"bitmask <" + bitmaskIt->first + "> requires <" + bitmaskIt->second.requirements + "bitmask <" + bitmaskIt->first + "> requires <" + bitmaskIt->second.requirements +
"> which is not listed for any feature or extension!" ); "> which is not required by any feature or extension!" );
} }
} }
else else
@ -1129,40 +1129,39 @@ void VulkanHppGenerator::checkHandleCorrectness() const
void VulkanHppGenerator::checkStructCorrectness() const void VulkanHppGenerator::checkStructCorrectness() const
{ {
for ( auto const & structAlias : m_structureAliases ) for ( auto const & structAlias : m_structsAliases )
{ {
checkForError( ( m_structures.find( structAlias.second.alias ) != m_structures.end() ) || checkForError( ( m_structs.find( structAlias.second.alias ) != m_structs.end() ) ||
( m_removedStructs.find( structAlias.second.alias ) != m_removedStructs.end() ), ( m_removedStructs.find( structAlias.second.alias ) != m_removedStructs.end() ),
structAlias.second.xmlLine, structAlias.second.xmlLine,
"unknown struct alias <" + structAlias.second.alias + ">" ); "unknown struct alias <" + structAlias.second.alias + ">" );
} }
for ( auto const & structAliasInverse : m_structureAliasesInverse ) for ( auto const & structAliasInverse : m_structsAliasesInverse )
{ {
if ( ( m_structures.find( structAliasInverse.first ) == m_structures.end() ) && if ( ( m_structs.find( structAliasInverse.first ) == m_structs.end() ) && ( m_removedStructs.find( structAliasInverse.first ) == m_removedStructs.end() ) )
( m_removedStructs.find( structAliasInverse.first ) == m_removedStructs.end() ) )
{ {
assert( !structAliasInverse.second.empty() ); assert( !structAliasInverse.second.empty() );
auto aliasIt = m_structureAliases.find( *structAliasInverse.second.begin() ); auto aliasIt = m_structsAliases.find( *structAliasInverse.second.begin() );
assert( aliasIt != m_structureAliases.end() ); assert( aliasIt != m_structsAliases.end() );
checkForError( false, aliasIt->second.xmlLine, "struct <" + aliasIt->first + "> uses unknown alias <" + aliasIt->second.alias + ">" ); checkForError( false, aliasIt->second.xmlLine, "struct <" + aliasIt->first + "> uses unknown alias <" + aliasIt->second.alias + ">" );
} }
} }
std::set<std::string> sTypeValues; std::set<std::string> sTypeValues;
for ( auto const & structure : m_structures ) for ( auto const & structure : m_structs )
{ {
// check that a struct is referenced somewhere // check that a struct is referenced somewhere
// I think, it's not forbidden to not reference a struct, but it would probably be not intended? // I think, it's not forbidden to not reference a struct, but it would probably be not intended?
auto typeIt = m_types.find( structure.first ); auto typeIt = m_types.find( structure.first );
assert( typeIt != m_types.end() ); assert( typeIt != m_types.end() );
checkForError( checkForError(
!typeIt->second.referencedIn.empty(), structure.second.xmlLine, "structure <" + structure.first + "> not listed in any feature or extension" ); !typeIt->second.requiredIn.empty(), structure.second.xmlLine, "structure <" + structure.first + "> not required by any feature or extension" );
// check for existence of all structs that are extended by this struct // check for existence of all structs that are extended by this struct
for ( auto const & extend : structure.second.structExtends ) for ( auto const & extend : structure.second.structExtends )
{ {
checkForError( ( m_structures.find( extend ) != m_structures.end() ) || ( m_structureAliases.find( extend ) != m_structureAliases.end() ), checkForError( ( m_structs.find( extend ) != m_structs.end() ) || ( m_structsAliases.find( extend ) != m_structsAliases.end() ),
structure.second.xmlLine, structure.second.xmlLine,
"struct <" + structure.first + "> extends unknown <" + extend + ">" ); "struct <" + structure.first + "> extends unknown <" + extend + ">" );
} }
@ -1200,9 +1199,9 @@ void VulkanHppGenerator::checkStructMemberCorrectness( std::string const &
{ {
auto typeIt = m_types.find( member.type.type ); auto typeIt = m_types.find( member.type.type );
assert( typeIt != m_types.end() ); assert( typeIt != m_types.end() );
checkForError( !typeIt->second.referencedIn.empty(), checkForError( !typeIt->second.requiredIn.empty(),
member.xmlLine, member.xmlLine,
"struct member type <" + member.type.type + "> used in struct <" + structureName + "> is never listed for any feature or extension" ); "struct member type <" + member.type.type + "> used in struct <" + structureName + "> is never required for any feature or extension" );
} }
// if a member specifies a selector, that member is a union and the selector is an enum // if a member specifies a selector, that member is a union and the selector is an enum
@ -1213,8 +1212,8 @@ void VulkanHppGenerator::checkStructMemberCorrectness( std::string const &
assert( selectorIt != members.end() ); assert( selectorIt != members.end() );
auto selectorEnumIt = m_enums.find( selectorIt->type.type ); auto selectorEnumIt = m_enums.find( selectorIt->type.type );
assert( selectorEnumIt != m_enums.end() ); assert( selectorEnumIt != m_enums.end() );
auto unionIt = m_structures.find( member.type.type ); auto unionIt = m_structs.find( member.type.type );
assert( ( unionIt != m_structures.end() ) && unionIt->second.isUnion ); assert( ( unionIt != m_structs.end() ) && unionIt->second.isUnion );
for ( auto const & unionMember : unionIt->second.members ) for ( auto const & unionMember : unionIt->second.members )
{ {
// check that each union member has a selection, that is a value of the seleting enum // check that each union member has a selection, that is a value of the seleting enum
@ -1326,9 +1325,9 @@ std::string VulkanHppGenerator::combineDataTypes( std::map<size_t, VectorParamDa
bool VulkanHppGenerator::containsArray( std::string const & type ) const bool VulkanHppGenerator::containsArray( std::string const & type ) const
{ {
// a simple recursive check if a type is or contains an array // a simple recursive check if a type is or contains an array
auto structureIt = m_structures.find( type ); auto structureIt = m_structs.find( type );
bool found = false; bool found = false;
if ( structureIt != m_structures.end() ) if ( structureIt != m_structs.end() )
{ {
for ( auto memberIt = structureIt->second.members.begin(); memberIt != structureIt->second.members.end() && !found; ++memberIt ) for ( auto memberIt = structureIt->second.members.begin(); memberIt != structureIt->second.members.end() && !found; ++memberIt )
{ {
@ -1341,9 +1340,9 @@ bool VulkanHppGenerator::containsArray( std::string const & type ) const
bool VulkanHppGenerator::containsFuncPointer( std::string const & type ) const bool VulkanHppGenerator::containsFuncPointer( std::string const & type ) const
{ {
// a simple recursive check if a type contains a funcpointer // a simple recursive check if a type contains a funcpointer
auto structureIt = m_structures.find( type ); auto structureIt = m_structs.find( type );
bool found = false; bool found = false;
if ( structureIt != m_structures.end() ) if ( structureIt != m_structs.end() )
{ {
for ( auto memberIt = structureIt->second.members.begin(); memberIt != structureIt->second.members.end() && !found; ++memberIt ) for ( auto memberIt = structureIt->second.members.begin(); memberIt != structureIt->second.members.end() && !found; ++memberIt )
{ {
@ -1369,9 +1368,9 @@ bool VulkanHppGenerator::containsFloatingPoints( std::vector<MemberData> const &
bool VulkanHppGenerator::containsUnion( std::string const & type ) const bool VulkanHppGenerator::containsUnion( std::string const & type ) const
{ {
// a simple recursive check if a type is or contains a union // a simple recursive check if a type is or contains a union
auto structureIt = m_structures.find( type ); auto structureIt = m_structs.find( type );
bool found = false; bool found = false;
if ( structureIt != m_structures.end() ) if ( structureIt != m_structs.end() )
{ {
found = structureIt->second.isUnion; found = structureIt->second.isUnion;
for ( auto memberIt = structureIt->second.members.begin(); memberIt != structureIt->second.members.end() && !found; ++memberIt ) for ( auto memberIt = structureIt->second.members.begin(); memberIt != structureIt->second.members.end() && !found; ++memberIt )
@ -1526,8 +1525,8 @@ std::vector<std::map<std::string, VulkanHppGenerator::CommandData>::const_iterat
if ( pd.type.type != destructorParam.type.type ) if ( pd.type.type != destructorParam.type.type )
{ {
// check if the destructor param type equals a structure member type // check if the destructor param type equals a structure member type
auto structureIt = m_structures.find( pd.type.type ); auto structureIt = m_structs.find( pd.type.type );
return ( structureIt != m_structures.end() ) && return ( structureIt != m_structs.end() ) &&
( findStructMemberItByType( destructorParam.type.type, structureIt->second.members ) != structureIt->second.members.end() ); ( findStructMemberItByType( destructorParam.type.type, structureIt->second.members ) != structureIt->second.members.end() );
} }
return true; return true;
@ -1666,9 +1665,9 @@ std::string VulkanHppGenerator::determineSubStruct( std::pair<std::string, Struc
( std::find_if_not( sd.second.members.begin(), sd.second.members.end(), isMember ) == sd.second.members.end() ); ( std::find_if_not( sd.second.members.begin(), sd.second.members.end(), isMember ) == sd.second.members.end() );
}; };
// look for a struct in m_structures that starts identically to structure // look for a struct in m_structs that starts identically to structure
auto structIt = std::find_if( m_structures.begin(), m_structures.end(), isSubStruct ); auto structIt = std::find_if( m_structs.begin(), m_structs.end(), isSubStruct );
return ( structIt == m_structures.end() ) ? "" : structIt->first; return ( structIt == m_structs.end() ) ? "" : structIt->first;
} }
return ""; return "";
} }
@ -5607,17 +5606,16 @@ ${widthDivisorCases}
{ "texelsPerBlockCases", texelsPerBlockCases } } ); { "texelsPerBlockCases", texelsPerBlockCases } } );
} }
std::string VulkanHppGenerator::generateFunctionPointerCheck( std::string const & function, std::set<std::string> const & referencedIn ) const std::string VulkanHppGenerator::generateFunctionPointerCheck( std::string const & function, std::set<std::string> const & requiredIn ) const
{ {
std::string functionPointerCheck; std::string functionPointerCheck;
if ( !referencedIn.empty() ) if ( !requiredIn.empty() )
{ {
std::string message = "Function <" + function + "> needs <" + *referencedIn.begin() + ">"; std::string message = "Function <" + function + "> requires <" + *requiredIn.begin() + ">";
for ( auto it = std::next( referencedIn.begin() ); it != referencedIn.end(); ++it ) for ( auto it = std::next( requiredIn.begin() ); it != requiredIn.end(); ++it )
{ {
message += " or <" + *it + ">"; message += " or <" + *it + ">";
} }
message += " enabled!";
functionPointerCheck = "VULKAN_HPP_ASSERT( getDispatcher()->" + function + " && \"" + message + "\" );"; functionPointerCheck = "VULKAN_HPP_ASSERT( getDispatcher()->" + function + " && \"" + message + "\" );";
} }
@ -6584,10 +6582,12 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandDeclarations( std::pair
} }
if ( !firstLevelCommands.empty() || !secondLevelCommands.empty() ) if ( !firstLevelCommands.empty() || !secondLevelCommands.empty() )
{ {
std::string handleProtect = getProtectFromType( handle.first );
std::string titleProtect = getProtectFromTitle( extIt.second->first );
std::string enter, leave; std::string enter, leave;
if ( extIt.second->first != m_types.find( handle.first )->second.referencedIn ) if ( !titleProtect.empty() && ( titleProtect != handleProtect ) )
{ {
std::tie( enter, leave ) = generateProtection( getProtectFromTitle( extIt.second->first ) ); std::tie( enter, leave ) = generateProtection( titleProtect );
} }
functionDeclarations += "\n" + enter + " //=== " + extIt.second->first + " ===\n"; functionDeclarations += "\n" + enter + " //=== " + extIt.second->first + " ===\n";
for ( auto const & command : firstLevelCommands ) for ( auto const & command : firstLevelCommands )
@ -6685,7 +6685,7 @@ ${vectorSizeCheck}
{ "dataDeclarations", dataDeclarations }, { "dataDeclarations", dataDeclarations },
{ "dataPreparation", dataPreparation }, { "dataPreparation", dataPreparation },
{ "dataSizeChecks", dataSizeChecks }, { "dataSizeChecks", dataSizeChecks },
{ "functionPointerCheck", generateFunctionPointerCheck( name, commandData.referencedIn ) }, { "functionPointerCheck", generateFunctionPointerCheck( name, commandData.requiredIn ) },
{ "nodiscard", nodiscard }, { "nodiscard", nodiscard },
{ "noexcept", noexceptString }, { "noexcept", noexceptString },
{ "resultCheck", resultCheck }, { "resultCheck", resultCheck },
@ -6856,7 +6856,7 @@ std::pair<std::string, std::string> VulkanHppGenerator::generateRAIIHandleConstr
// there is a non-const parameter with handle type : the to-be-constructed handle // there is a non-const parameter with handle type : the to-be-constructed handle
// check for additional enter/leave guards for the constructors // check for additional enter/leave guards for the constructors
auto [constructorEnter, constructorLeave] = generateProtection( getProtectFromTitles( constructorIt->second.referencedIn ) ); auto [constructorEnter, constructorLeave] = generateProtection( getProtectFromTitles( constructorIt->second.requiredIn ) );
if ( constructorEnter == enter ) if ( constructorEnter == enter )
{ {
constructorEnter.clear(); constructorEnter.clear();
@ -7186,8 +7186,8 @@ std::string
#endif #endif
for ( auto constructorParam : constructorIt->second.params ) for ( auto constructorParam : constructorIt->second.params )
{ {
auto structureIt = m_structures.find( constructorParam.type.type ); auto structureIt = m_structs.find( constructorParam.type.type );
if ( structureIt != m_structures.end() ) if ( structureIt != m_structs.end() )
{ {
auto structureMemberIt = findStructMemberItByType( destructorParam.type.type, structureIt->second.members ); auto structureMemberIt = findStructMemberItByType( destructorParam.type.type, structureIt->second.members );
if ( structureMemberIt != structureIt->second.members.end() ) if ( structureMemberIt != structureIt->second.members.end() )
@ -7488,8 +7488,8 @@ std::string VulkanHppGenerator::generateRAIIHandleConstructorVector( std::pair<s
constructorIt->second.params.begin(), constructorIt->second.params.end(), [&lenParts]( ParamData const & pd ) { return pd.name == lenParts[0]; } ); constructorIt->second.params.begin(), constructorIt->second.params.end(), [&lenParts]( ParamData const & pd ) { return pd.name == lenParts[0]; } );
#if !defined( NDEBUG ) #if !defined( NDEBUG )
assert( lenIt != constructorIt->second.params.end() ); assert( lenIt != constructorIt->second.params.end() );
auto structureIt = m_structures.find( lenIt->type.type ); auto structureIt = m_structs.find( lenIt->type.type );
assert( structureIt != m_structures.end() ); assert( structureIt != m_structs.end() );
assert( isStructMember( lenParts[1], structureIt->second.members ) ); assert( isStructMember( lenParts[1], structureIt->second.members ) );
assert( constructorIt->second.successCodes.size() == 1 ); assert( constructorIt->second.successCodes.size() == 1 );
#endif #endif
@ -8013,8 +8013,8 @@ std::string VulkanHppGenerator::generateRAIIHandleSingularConstructorArguments(
#endif #endif
for ( auto const & constructorParam : constructorIt->second.params ) for ( auto const & constructorParam : constructorIt->second.params )
{ {
auto structureIt = m_structures.find( constructorParam.type.type ); auto structureIt = m_structs.find( constructorParam.type.type );
if ( structureIt != m_structures.end() ) if ( structureIt != m_structs.end() )
{ {
auto memberIt = findStructMemberItByType( destructorParam.type.type, structureIt->second.members ); auto memberIt = findStructMemberItByType( destructorParam.type.type, structureIt->second.members );
if ( memberIt != structureIt->second.members.end() ) if ( memberIt != structureIt->second.members.end() )
@ -8499,19 +8499,22 @@ std::string VulkanHppGenerator::generateSizeCheck( std::vector<std::vector<Membe
std::string VulkanHppGenerator::generateStaticAssertions() const std::string VulkanHppGenerator::generateStaticAssertions() const
{ {
std::string staticAssertions; std::string staticAssertions;
std::set<std::string> listedStructs;
for ( auto const & feature : m_features ) for ( auto const & feature : m_features )
{ {
staticAssertions += generateStaticAssertions( feature.second.requireData, feature.first ); staticAssertions += generateStaticAssertions( feature.second.requireData, feature.first, listedStructs );
} }
for ( auto const & extIt : m_extensionsByNumber ) for ( auto const & extIt : m_extensionsByNumber )
{ {
staticAssertions += generateStaticAssertions( extIt.second->second.requireData, extIt.second->first ); staticAssertions += generateStaticAssertions( extIt.second->second.requireData, extIt.second->first, listedStructs );
} }
return staticAssertions; return staticAssertions;
} }
std::string VulkanHppGenerator::generateStaticAssertions( std::vector<RequireData> const & requireData, std::string const & title ) const std::string VulkanHppGenerator::generateStaticAssertions( std::vector<RequireData> const & requireData,
std::string const & title,
std::set<std::string> & listedStructs ) const
{ {
std::string str; std::string str;
for ( auto const & require : requireData ) for ( auto const & require : requireData )
@ -8529,8 +8532,8 @@ VULKAN_HPP_STATIC_ASSERT( std::is_nothrow_move_constructible<VULKAN_HPP_NAMESPAC
} }
else else
{ {
auto structIt = m_structures.find( type ); auto structIt = m_structs.find( type );
if ( structIt != m_structures.end() ) if ( ( structIt != m_structs.end() ) && listedStructs.insert( type ).second )
{ {
std::string const assertionTemplate = R"( std::string const assertionTemplate = R"(
VULKAN_HPP_STATIC_ASSERT( sizeof( VULKAN_HPP_NAMESPACE::${structureType} ) == sizeof( Vk${structureType} ), "struct and wrapper have different size!" ); VULKAN_HPP_STATIC_ASSERT( sizeof( VULKAN_HPP_NAMESPACE::${structureType} ) == sizeof( Vk${structureType} ), "struct and wrapper have different size!" );
@ -8552,8 +8555,8 @@ std::string VulkanHppGenerator::generateStruct( std::pair<std::string, Structure
std::string str; std::string str;
for ( auto const & member : structure.second.members ) for ( auto const & member : structure.second.members )
{ {
auto structIt = m_structures.find( member.type.type ); auto structIt = m_structs.find( member.type.type );
if ( ( structIt != m_structures.end() ) && ( structure.first != member.type.type ) && ( listedStructs.find( member.type.type ) == listedStructs.end() ) ) if ( ( structIt != m_structs.end() ) && ( structure.first != member.type.type ) && ( listedStructs.find( member.type.type ) == listedStructs.end() ) )
{ {
str += generateStruct( *structIt, listedStructs ); str += generateStruct( *structIt, listedStructs );
} }
@ -8561,8 +8564,8 @@ std::string VulkanHppGenerator::generateStruct( std::pair<std::string, Structure
if ( !structure.second.subStruct.empty() ) if ( !structure.second.subStruct.empty() )
{ {
auto structureIt = m_structures.find( structure.second.subStruct ); auto structureIt = m_structs.find( structure.second.subStruct );
if ( ( structureIt != m_structures.end() ) && ( listedStructs.find( structureIt->first ) == listedStructs.end() ) ) if ( ( structureIt != m_structs.end() ) && ( listedStructs.find( structureIt->first ) == listedStructs.end() ) )
{ {
str += generateStruct( *structureIt, listedStructs ); str += generateStruct( *structureIt, listedStructs );
} }
@ -8926,8 +8929,8 @@ std::string VulkanHppGenerator::generateStructHashStructure( std::pair<std::stri
std::string str; std::string str;
for ( auto const & member : structure.second.members ) for ( auto const & member : structure.second.members )
{ {
auto structIt = m_structures.find( member.type.type ); auto structIt = m_structs.find( member.type.type );
if ( ( structIt != m_structures.end() ) && ( structure.first != member.type.type ) && ( listedStructs.find( member.type.type ) == listedStructs.end() ) ) if ( ( structIt != m_structs.end() ) && ( structure.first != member.type.type ) && ( listedStructs.find( member.type.type ) == listedStructs.end() ) )
{ {
str += generateStructHashStructure( *structIt, listedStructs ); str += generateStructHashStructure( *structIt, listedStructs );
} }
@ -8948,7 +8951,7 @@ ${hashSum}
${leave})"; ${leave})";
auto [enter, leave] = auto [enter, leave] =
generateProtection( m_structureAliasesInverse.find( structure.first ) == m_structureAliasesInverse.end() ? 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 );
@ -8984,7 +8987,7 @@ ${hashes}
// Note reordering structs or handles by features and extensions is not possible! // Note reordering structs or handles by features and extensions is not possible!
std::set<std::string> listedStructs; std::set<std::string> listedStructs;
std::string hashes; std::string hashes;
for ( auto const & structure : m_structures ) for ( auto const & structure : m_structs )
{ {
if ( listedStructs.find( structure.first ) == listedStructs.end() ) if ( listedStructs.find( structure.first ) == listedStructs.end() )
{ {
@ -9062,7 +9065,7 @@ ${structs}
// Note reordering structs or handles by features and extensions is not possible! // Note reordering structs or handles by features and extensions is not possible!
std::set<std::string> listedStructs; std::set<std::string> listedStructs;
std::string structs; std::string structs;
for ( auto const & structure : m_structures ) for ( auto const & structure : m_structs )
{ {
if ( listedStructs.find( structure.first ) == listedStructs.end() ) if ( listedStructs.find( structure.first ) == listedStructs.end() )
{ {
@ -9075,7 +9078,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( m_structureAliasesInverse.find( structure.first ) == m_structureAliasesInverse.end() ? 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;
@ -9195,8 +9198,8 @@ ${members}
str += replaceWithMap( cppTypeTemplate, { { "sTypeValue", sTypeValue }, { "structureType", structureType } } ); str += replaceWithMap( cppTypeTemplate, { { "sTypeValue", sTypeValue }, { "structureType", structureType } } );
} }
auto aliasIt = m_structureAliasesInverse.find( structure.first ); auto aliasIt = m_structsAliasesInverse.find( structure.first );
if ( aliasIt != m_structureAliasesInverse.end() ) if ( aliasIt != m_structsAliasesInverse.end() )
{ {
for ( std::string const & alias : aliasIt->second ) for ( std::string const & alias : aliasIt->second )
{ {
@ -9240,31 +9243,28 @@ std::string VulkanHppGenerator::generateStructExtendsStructs( std::vector<Requir
{ {
for ( auto const & type : require.types ) for ( auto const & type : require.types )
{ {
auto structIt = m_structures.find( type ); auto structIt = m_structs.find( type );
if ( structIt != m_structures.end() ) if ( ( structIt != m_structs.end() ) && listedStructs.insert( type ).second )
{ {
assert( listedStructs.find( type ) == listedStructs.end() );
listedStructs.insert( type );
auto [enter, leave] = generateProtection( getProtectFromTitle( title ) ); auto [enter, leave] = generateProtection( getProtectFromTitle( title ) );
// append all allowed structure chains // append all allowed structure chains
for ( auto extendName : structIt->second.structExtends ) for ( auto extendName : structIt->second.structExtends )
{ {
std::map<std::string, StructureData>::const_iterator itExtend = m_structures.find( extendName ); std::map<std::string, StructureData>::const_iterator itExtend = m_structs.find( extendName );
if ( itExtend == m_structures.end() ) if ( itExtend == m_structs.end() )
{ {
// look if the extendName acutally is an alias of some other structure // look if the extendName acutally is an alias of some other structure
auto aliasIt = m_structureAliases.find( extendName ); auto aliasIt = m_structsAliases.find( extendName );
if ( aliasIt != m_structureAliases.end() ) if ( aliasIt != m_structsAliases.end() )
{ {
itExtend = m_structures.find( aliasIt->second.alias ); itExtend = m_structs.find( aliasIt->second.alias );
assert( itExtend != m_structures.end() ); assert( itExtend != m_structs.end() );
} }
} }
auto [subEnter, subLeave] = generateProtection( auto [subEnter, subLeave] =
m_structureAliasesInverse.find( itExtend->first ) == m_structureAliasesInverse.end() ? getProtectFromType( itExtend->first ) : "" ); generateProtection( m_structsAliasesInverse.find( itExtend->first ) == m_structsAliasesInverse.end() ? getProtectFromType( itExtend->first ) : "" );
if ( enter != subEnter ) if ( enter != subEnter )
{ {
@ -9295,33 +9295,36 @@ std::string VulkanHppGenerator::generateStructForwardDeclarations() const
${forwardDeclarations} ${forwardDeclarations}
)"; )";
std::string forwardDeclarations; std::string forwardDeclarations;
std::set<std::string> listedStructs;
for ( auto const & feature : m_features ) for ( auto const & feature : m_features )
{ {
forwardDeclarations += generateStructForwardDeclarations( feature.second.requireData, feature.first ); forwardDeclarations += generateStructForwardDeclarations( feature.second.requireData, feature.first, listedStructs );
} }
for ( auto const & extIt : m_extensionsByNumber ) for ( auto const & extIt : m_extensionsByNumber )
{ {
forwardDeclarations += generateStructForwardDeclarations( extIt.second->second.requireData, extIt.second->first ); forwardDeclarations += generateStructForwardDeclarations( extIt.second->second.requireData, extIt.second->first, listedStructs );
} }
return replaceWithMap( fowardDeclarationsTemplate, { { "forwardDeclarations", forwardDeclarations } } ); return replaceWithMap( fowardDeclarationsTemplate, { { "forwardDeclarations", forwardDeclarations } } );
} }
std::string VulkanHppGenerator::generateStructForwardDeclarations( std::vector<RequireData> const & requireData, std::string const & title ) const std::string VulkanHppGenerator::generateStructForwardDeclarations( std::vector<RequireData> const & requireData,
std::string const & title,
std::set<std::string> & listedStructs ) const
{ {
std::string str; std::string str;
for ( auto const & require : requireData ) for ( auto const & require : requireData )
{ {
for ( auto const & type : require.types ) for ( auto const & type : require.types )
{ {
auto structIt = m_structures.find( type ); auto structIt = m_structs.find( type );
if ( structIt != m_structures.end() ) if ( ( structIt != m_structs.end() ) && listedStructs.insert( type ).second )
{ {
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_structureAliasesInverse.find( type ); auto inverseIt = m_structsAliasesInverse.find( type );
if ( inverseIt != m_structureAliasesInverse.end() ) if ( inverseIt != m_structsAliasesInverse.end() )
{ {
for ( auto alias : inverseIt->second ) for ( auto alias : inverseIt->second )
{ {
@ -9440,15 +9443,14 @@ std::string VulkanHppGenerator::generateStructSetter( std::string const & struct
assignment = member.name + " = " + member.name + "_"; assignment = member.name + " = " + member.name + "_";
} }
str += str += replaceWithMap( templateString,
replaceWithMap( templateString, { { "assignment", assignment },
{ { "assignment", assignment }, { "constexpr", isReinterpretation ? "" : "VULKAN_HPP_CONSTEXPR_14 " },
{ "constexpr", isReinterpretation ? "" : "VULKAN_HPP_CONSTEXPR_14 " }, { "memberName", member.name },
{ "memberName", member.name }, { "MemberName", startUpperCase( member.name ) },
{ "MemberName", startUpperCase( member.name ) }, { "memberType", memberType },
{ "memberType", memberType }, { "reference", ( member.type.postfix.empty() && ( m_structs.find( member.type.type ) != m_structs.end() ) ) ? "const & " : "" },
{ "reference", ( member.type.postfix.empty() && ( m_structures.find( member.type.type ) != m_structures.end() ) ) ? "const & " : "" }, { "structureName", structureName } } );
{ "structureName", structureName } } );
if ( hasLen( memberData, member ) ) if ( hasLen( memberData, member ) )
{ {
@ -9519,8 +9521,8 @@ std::string VulkanHppGenerator::generateStructSubConstructor( std::pair<std::str
{ {
if ( !structData.second.subStruct.empty() ) if ( !structData.second.subStruct.empty() )
{ {
auto const & subStruct = m_structures.find( structData.second.subStruct ); auto const & subStruct = m_structs.find( structData.second.subStruct );
assert( subStruct != m_structures.end() ); assert( subStruct != m_structs.end() );
std::string subStructArgumentName = startLowerCase( stripPrefix( subStruct->first, "Vk" ) ); std::string subStructArgumentName = startLowerCase( stripPrefix( subStruct->first, "Vk" ) );
@ -9680,7 +9682,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( m_structureAliasesInverse.find( structure.first ) == m_structureAliasesInverse.end() ? 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;
@ -10047,8 +10049,8 @@ std::string VulkanHppGenerator::getPlatform( std::string const & title ) const
std::pair<std::string, std::string> VulkanHppGenerator::getPoolTypeAndName( std::string const & type ) const std::pair<std::string, std::string> VulkanHppGenerator::getPoolTypeAndName( std::string const & type ) const
{ {
auto structIt = m_structures.find( type ); auto structIt = m_structs.find( type );
assert( structIt != m_structures.end() ); assert( structIt != m_structs.end() );
auto memberIt = std::find_if( auto memberIt = std::find_if(
structIt->second.members.begin(), structIt->second.members.end(), []( MemberData const & md ) { return md.name.find( "Pool" ) != std::string::npos; } ); structIt->second.members.begin(), structIt->second.members.end(), []( MemberData const & md ) { return md.name.find( "Pool" ) != std::string::npos; } );
assert( memberIt != structIt->second.members.end() ); assert( memberIt != structIt->second.members.end() );
@ -10104,7 +10106,7 @@ std::string VulkanHppGenerator::getProtectFromType( std::string const & type ) c
{ {
auto typeIt = m_types.find( type ); auto typeIt = m_types.find( type );
assert( typeIt != m_types.end() ); assert( typeIt != m_types.end() );
return getProtectFromTitle( typeIt->second.referencedIn ); return getProtectFromTitles( typeIt->second.requiredIn );
} }
std::string VulkanHppGenerator::getVectorSize( std::vector<ParamData> const & params, std::string VulkanHppGenerator::getVectorSize( std::vector<ParamData> const & params,
@ -10217,8 +10219,8 @@ bool VulkanHppGenerator::isLenByStructMember( std::string const & name, std::vec
if ( paramIt != params.end() ) if ( paramIt != params.end() )
{ {
#if !defined( NDEBUG ) #if !defined( NDEBUG )
auto structureIt = m_structures.find( paramIt->type.type ); auto structureIt = m_structs.find( paramIt->type.type );
assert( structureIt != m_structures.end() ); assert( structureIt != m_structs.end() );
assert( isStructMember( nameParts[1], structureIt->second.members ) ); assert( isStructMember( nameParts[1], structureIt->second.members ) );
#endif #endif
return true; return true;
@ -10239,8 +10241,8 @@ bool VulkanHppGenerator::isLenByStructMember( std::string const & name, ParamDat
if ( ( nameParts.size() == 2 ) && ( nameParts[0] == param.name ) ) if ( ( nameParts.size() == 2 ) && ( nameParts[0] == param.name ) )
{ {
#if !defined( NDEBUG ) #if !defined( NDEBUG )
auto structureIt = m_structures.find( param.type.type ); auto structureIt = m_structs.find( param.type.type );
assert( structureIt != m_structures.end() ); assert( structureIt != m_structs.end() );
assert( isStructMember( nameParts[1], structureIt->second.members ) ); assert( isStructMember( nameParts[1], structureIt->second.members ) );
#endif #endif
return true; return true;
@ -10281,16 +10283,16 @@ bool VulkanHppGenerator::isStructureChainAnchor( std::string const & type ) cons
{ {
if ( type.starts_with( "Vk" ) ) if ( type.starts_with( "Vk" ) )
{ {
auto it = m_structures.find( type ); auto it = m_structs.find( type );
if ( it == m_structures.end() ) if ( it == m_structs.end() )
{ {
auto aliasIt = m_structureAliases.find( type ); auto aliasIt = m_structsAliases.find( type );
if ( aliasIt != m_structureAliases.end() ) if ( aliasIt != m_structsAliases.end() )
{ {
it = m_structures.find( aliasIt->second.alias ); it = m_structs.find( aliasIt->second.alias );
} }
} }
if ( it != m_structures.end() ) if ( it != m_structs.end() )
{ {
return m_extendedStructs.find( it->first ) != m_extendedStructs.end(); return m_extendedStructs.find( it->first ) != m_extendedStructs.end();
} }
@ -10506,7 +10508,7 @@ std::pair<bool, VulkanHppGenerator::ParamData> VulkanHppGenerator::readCommandsC
std::vector<std::string> validStructs = tokenize( attribute.second, "," ); std::vector<std::string> validStructs = tokenize( attribute.second, "," );
for ( auto const & vs : validStructs ) for ( auto const & vs : validStructs )
{ {
checkForError( m_structures.find( vs ) != m_structures.end(), line, "unknown struct <" + vs + "> listed in attribute <validstructs>" ); checkForError( m_structs.find( vs ) != m_structs.end(), line, "unknown struct <" + vs + "> listed in attribute <validstructs>" );
} }
} }
} }
@ -10981,32 +10983,24 @@ void VulkanHppGenerator::readExtensionsExtensionRequireType( tinyxml2::XMLElemen
checkAttributes( line, attributes, { { "name", {} } }, { { "comment", {} } } ); checkAttributes( line, attributes, { { "name", {} } }, { { "comment", {} } } );
checkElements( line, getChildElements( element ), {} ); checkElements( line, getChildElements( element ), {} );
std::string name; std::string name = attributes.find( "name" )->second;
for ( auto const & attribute : attributes )
{
if ( attribute.first == "name" )
{
name = attribute.second;
}
}
assert( !name.empty() );
auto typeIt = m_types.find( name ); auto typeIt = m_types.find( name );
checkForError( typeIt != m_types.end(), line, "failed to find required type <" + name + ">" ); checkForError( typeIt != m_types.end(), line, "failed to find required type <" + name + ">" );
if ( typeIt->second.referencedIn.empty() ) std::string platform = getPlatform( extensionName );
for ( auto const & requiredIn : typeIt->second.requiredIn )
{ {
typeIt->second.referencedIn = extensionName; std::string requiredInPlatform = getPlatform( requiredIn );
assert( std::find( requireData.types.begin(), requireData.types.end(), name ) == requireData.types.end() ); checkForError( requiredInPlatform == platform,
requireData.types.push_back( name );
}
else
{
checkForError( getPlatform( typeIt->second.referencedIn ) == getPlatform( extensionName ),
line, line,
"type <" + name + "> is referenced in extensions <" + typeIt->second.referencedIn + "> and <" + extensionName + "type <" + name + "> is required in <" + requiredIn + "> and <" + extensionName + "> and thus protected by different platforms <" +
"> and thus protected by different platforms <" + getPlatform( typeIt->second.referencedIn ) + "> and <" + getPlatform( extensionName ) + requiredInPlatform + "> and <" + platform + ">!" );
">!" );
} }
checkForError( std::find( requireData.types.begin(), requireData.types.end(), name ) == requireData.types.end(),
line,
"type <" + name + "> already required for <" + extensionName + ">" );
typeIt->second.requiredIn.insert( extensionName );
requireData.types.push_back( name );
} }
void VulkanHppGenerator::readFeature( tinyxml2::XMLElement const * element ) void VulkanHppGenerator::readFeature( tinyxml2::XMLElement const * element )
@ -11120,9 +11114,11 @@ void VulkanHppGenerator::readFeatureRequireCommandRemove( tinyxml2::XMLElement c
std::string name = attributes.find( "name" )->second; std::string name = attributes.find( "name" )->second;
auto commandIt = m_commands.find( name ); auto commandIt = m_commands.find( name );
checkForError( commandIt != m_commands.end(), line, "unknown required command <" + name + ">" ); checkForError( commandIt != m_commands.end(), line, "unknown to be removed command <" + name + ">" );
checkForError( if ( !commandIt->second.requiredIn.empty() )
commandIt->second.referencedIn.empty(), line, "command <" + name + "> already listed with feature <" + *commandIt->second.referencedIn.begin() + ">" ); {
checkForError( false, line, "to be removed command <" + name + "> already required in <" + *commandIt->second.requiredIn.begin() + ">" );
}
m_commands.erase( commandIt ); m_commands.erase( commandIt );
} }
@ -11170,10 +11166,12 @@ void VulkanHppGenerator::readFeatureRequireType( tinyxml2::XMLElement const *
{ {
auto typeIt = m_types.find( name ); auto typeIt = m_types.find( name );
checkForError( typeIt != m_types.end(), line, "feature <" + featureIt->first + "> requires unknown type <" + name + ">" ); checkForError( typeIt != m_types.end(), line, "feature <" + featureIt->first + "> requires unknown type <" + name + ">" );
checkForError( typeIt->second.referencedIn.empty() || ( typeIt->second.referencedIn == featureIt->first ), if ( !typeIt->second.requiredIn.empty() )
line, {
"type <" + name + "> already listed on feature <" + typeIt->second.referencedIn + ">" ); assert( typeIt->second.requiredIn.size() == 1 );
typeIt->second.referencedIn = featureIt->first; checkForError( false, line, "type <" + name + "> already required by feature <" + *typeIt->second.requiredIn.begin() + ">" );
}
checkForError( typeIt->second.requiredIn.insert( featureIt->first ).second, line, "type <" + name + "> already required by this feature" );
requireData.types.push_back( name ); requireData.types.push_back( name );
} }
@ -11557,18 +11555,18 @@ void VulkanHppGenerator::readRequireCommand( tinyxml2::XMLElement const * elemen
checkForError( commandIt != m_commands.end(), line, "title <" + title + "> requires unknown command <" + name + ">" ); checkForError( commandIt != m_commands.end(), line, "title <" + title + "> requires unknown command <" + name + ">" );
std::string platform = getPlatform( title ); std::string platform = getPlatform( title );
for ( auto const & referencedIn : commandIt->second.referencedIn ) for ( auto const & requiredIn : commandIt->second.requiredIn )
{ {
std::string referencedPlatform = getPlatform( referencedIn ); std::string requiredInPlatform = getPlatform( requiredIn );
checkForError( referencedPlatform == platform, checkForError( requiredInPlatform == platform,
line, line,
"command <" + name + "> is referenced in <" + referencedIn + "> and <" + title + "> and thus protected by different platforms <" + "command <" + name + "> is required in <" + requiredIn + "> and <" + title + "> and thus protected by different platforms <" +
referencedPlatform + "> and <" + platform + ">!" ); requiredInPlatform + "> and <" + platform + ">!" );
} }
checkForError( std::find( requireData.commands.begin(), requireData.commands.end(), name ) == requireData.commands.end(), checkForError( std::find( requireData.commands.begin(), requireData.commands.end(), name ) == requireData.commands.end(),
line, line,
"command <" + name + "> already listed for <" + title + ">" ); "command <" + name + "> already required for <" + title + ">" );
commandIt->second.referencedIn.insert( title ); commandIt->second.requiredIn.insert( title );
requireData.commands.push_back( name ); requireData.commands.push_back( name );
} }
@ -11729,19 +11727,7 @@ void VulkanHppGenerator::readRequireEnum( tinyxml2::XMLElement const * element,
if ( !extends.empty() ) if ( !extends.empty() )
{ {
auto enumIt = m_enums.find( extends ); auto enumIt = m_enums.find( extends );
if ( enumIt == m_enums.end() ) checkForError( enumIt != m_enums.end(), line, "trying to extend unknown enum <" + extends + ">" );
{
// need to re-add a previously removed enum !!
enumIt = m_removedEnums.find( extends );
checkForError( enumIt != m_removedEnums.end(), line, "feature extends unknown enum <" + extends + ">" );
enumIt = m_enums.insert( *enumIt ).first;
auto typeIt = m_removedTypes.find( extends );
assert( ( m_types.find( extends ) == m_types.end() ) || ( typeIt != m_removedTypes.end() ) );
typeIt->second.referencedIn = extensionName;
m_types[extends] = typeIt->second;
m_removedTypes.erase( typeIt );
}
// add this enum name to the list of values // add this enum name to the list of values
checkForError( bitpos.empty() + offset.empty() + value.empty() == 2, checkForError( bitpos.empty() + offset.empty() + value.empty() == 2,
@ -11825,7 +11811,7 @@ void VulkanHppGenerator::readRequireTypeRemove( tinyxml2::XMLElement const * ele
auto typeIt = m_types.find( name ); auto typeIt = m_types.find( name );
if ( typeIt != m_types.end() ) if ( typeIt != m_types.end() )
{ {
assert( typeIt->second.referencedIn.empty() ); assert( typeIt->second.requiredIn.empty() );
assert( m_removedTypes.find( name ) == m_removedTypes.end() ); assert( m_removedTypes.find( name ) == m_removedTypes.end() );
switch ( typeIt->second.category ) switch ( typeIt->second.category )
@ -11853,20 +11839,20 @@ void VulkanHppGenerator::readRequireTypeRemove( tinyxml2::XMLElement const * ele
break; break;
case TypeCategory::Struct: case TypeCategory::Struct:
{ {
auto structIt = m_structures.find( name ); auto structIt = m_structs.find( name );
if ( structIt == m_structures.end() ) if ( structIt == m_structs.end() )
{ {
auto aliasIt = m_structureAliases.find( name ); auto aliasIt = m_structsAliases.find( name );
if ( aliasIt != m_structureAliases.end() ) if ( aliasIt != m_structsAliases.end() )
{ {
name = aliasIt->second.alias; name = aliasIt->second.alias;
structIt = m_structures.find( name ); structIt = m_structs.find( name );
} }
} }
if ( structIt != m_structures.end() ) if ( structIt != m_structs.end() )
{ {
m_removedStructs.insert( name ); m_removedStructs.insert( name );
m_structures.erase( structIt ); m_structs.erase( structIt );
} }
else else
{ {
@ -11985,8 +11971,8 @@ void VulkanHppGenerator::readSPIRVCapabilitiesSPIRVCapabilityEnableProperty( int
} }
assert( !member.empty() && !property.empty() && !value.empty() ); assert( !member.empty() && !property.empty() && !value.empty() );
auto propertyIt = m_structures.find( property ); auto propertyIt = m_structs.find( property );
checkForError( propertyIt != m_structures.end(), xmlLine, "unknown property <" + property + "> specified for SPIR-V capability" ); checkForError( propertyIt != m_structs.end(), xmlLine, "unknown property <" + property + "> specified for SPIR-V capability" );
auto memberIt = findStructMemberIt( member, propertyIt->second.members ); auto memberIt = findStructMemberIt( member, propertyIt->second.members );
checkForError( memberIt != propertyIt->second.members.end(), xmlLine, "unknown member <" + member + "> specified for SPIR-V capability" ); checkForError( memberIt != propertyIt->second.members.end(), xmlLine, "unknown member <" + member + "> specified for SPIR-V capability" );
if ( memberIt->type.type == "VkBool32" ) if ( memberIt->type.type == "VkBool32" )
@ -12028,8 +12014,7 @@ void VulkanHppGenerator::readSPIRVCapabilitiesSPIRVCapabilityEnableStruct( int x
} }
else if ( attribute.first == "struct" ) else if ( attribute.first == "struct" )
{ {
checkForError( ( m_structures.find( attribute.second ) != m_structures.end() ) || checkForError( ( m_structs.find( attribute.second ) != m_structs.end() ) || ( m_structsAliases.find( attribute.second ) != m_structsAliases.end() ),
( m_structureAliases.find( attribute.second ) != m_structureAliases.end() ),
xmlLine, xmlLine,
"unknown structure <" + attribute.second + "> specified for SPIR-V capability" ); "unknown structure <" + attribute.second + "> specified for SPIR-V capability" );
checkForError( attributes.find( "feature" ) != attributes.end(), checkForError( attributes.find( "feature" ) != attributes.end(),
@ -12642,8 +12627,8 @@ void VulkanHppGenerator::readTypesTypeStruct( tinyxml2::XMLElement const * eleme
} }
checkForError( checkForError(
m_structureAliases.insert( std::make_pair( name, StructureAliasData( alias, line ) ) ).second, line, "structure alias <" + name + "> already used" ); m_structsAliases.insert( std::make_pair( name, StructureAliasData( alias, line ) ) ).second, line, "structure alias <" + name + "> already used" );
checkForError( m_structureAliasesInverse[alias].insert( name ).second, line, "structure alias <" + name + "> already used with structure <" + alias + ">" ); checkForError( m_structsAliasesInverse[alias].insert( name ).second, line, "structure alias <" + name + "> already used with structure <" + alias + ">" );
checkForError( m_types.insert( std::make_pair( name, TypeData{ .category = TypeCategory::Struct } ) ).second, checkForError( m_types.insert( std::make_pair( name, TypeData{ .category = TypeCategory::Struct } ) ).second,
line, line,
"struct <" + name + "> already specified as a type" ); "struct <" + name + "> already specified as a type" );
@ -12689,8 +12674,8 @@ void VulkanHppGenerator::readTypesTypeStruct( tinyxml2::XMLElement const * eleme
// make this warn a check, as soon as vk.xml has been fixed on attribute "allowduplicate" ! // make this warn a check, as soon as vk.xml has been fixed on attribute "allowduplicate" !
checkForWarning( !allowDuplicate || !structExtends.empty(), line, "attribute <allowduplicate> is true, but no structures are listed in <structextends>" ); checkForWarning( !allowDuplicate || !structExtends.empty(), line, "attribute <allowduplicate> is true, but no structures are listed in <structextends>" );
checkForError( m_structures.find( name ) == m_structures.end(), line, "struct <" + name + "> already specfied" ); checkForError( m_structs.find( name ) == m_structs.end(), line, "struct <" + name + "> already specfied" );
std::map<std::string, StructureData>::iterator it = m_structures.insert( std::make_pair( name, StructureData( structExtends, line ) ) ).first; std::map<std::string, StructureData>::iterator it = m_structs.insert( std::make_pair( name, StructureData( structExtends, line ) ) ).first;
it->second.allowDuplicate = allowDuplicate; it->second.allowDuplicate = allowDuplicate;
it->second.isUnion = isUnion; it->second.isUnion = isUnion;
it->second.returnedOnly = returnedOnly; it->second.returnedOnly = returnedOnly;

View File

@ -176,7 +176,7 @@ private:
std::vector<std::string> errorCodes; std::vector<std::string> errorCodes;
std::string handle; std::string handle;
std::vector<ParamData> params; std::vector<ParamData> params;
std::set<std::string> referencedIn; std::set<std::string> requiredIn;
std::string returnType; std::string returnType;
std::vector<std::string> successCodes; std::vector<std::string> successCodes;
int xmlLine; int xmlLine;
@ -407,8 +407,8 @@ private:
struct TypeData struct TypeData
{ {
TypeCategory category = TypeCategory::Unknown; TypeCategory category = TypeCategory::Unknown;
std::string referencedIn = {}; std::set<std::string> requiredIn = {};
}; };
struct VectorParamData struct VectorParamData
@ -419,7 +419,7 @@ private:
private: private:
void addCommand( std::string const & name, CommandData & commandData ); void addCommand( std::string const & name, CommandData & commandData );
void addMissingFlagBits( std::vector<RequireData> & requireData, std::string const & referencedIn ); void addMissingFlagBits( std::vector<RequireData> & requireData, std::string const & requiredIn );
std::string addTitleAndProtection( std::string const & title, std::string const & strIf, std::string const & strElse = {} ) const; std::string addTitleAndProtection( std::string const & title, std::string const & strIf, std::string const & strElse = {} ) const;
bool allVectorSizesSupported( std::vector<ParamData> const & params, std::map<size_t, VectorParamData> const & vectorParams ) const; bool allVectorSizesSupported( std::vector<ParamData> const & params, std::map<size_t, VectorParamData> const & vectorParams ) const;
void appendDispatchLoaderDynamicCommands( std::vector<RequireData> const & requireData, void appendDispatchLoaderDynamicCommands( std::vector<RequireData> const & requireData,
@ -705,7 +705,7 @@ private:
std::string generateEnumToString( std::pair<std::string, EnumData> const & enumData ) const; std::string generateEnumToString( std::pair<std::string, EnumData> const & enumData ) const;
std::string generateFailureCheck( std::vector<std::string> const & successCodes ) const; std::string generateFailureCheck( std::vector<std::string> const & successCodes ) const;
std::string generateFormatTraits() const; std::string generateFormatTraits() const;
std::string generateFunctionPointerCheck( std::string const & function, std::set<std::string> const & referencedIn ) const; std::string generateFunctionPointerCheck( std::string const & function, std::set<std::string> const & requiredIn ) const;
std::string generateHandle( std::pair<std::string, HandleData> const & handle, std::set<std::string> & listedHandles ) const; std::string generateHandle( std::pair<std::string, HandleData> const & handle, std::set<std::string> & listedHandles ) const;
std::string generateHandleCommandDeclarations( std::set<std::string> const & commands ) const; std::string generateHandleCommandDeclarations( std::set<std::string> const & commands ) const;
std::string generateHandleDependencies( std::pair<std::string, HandleData> const & handle, std::set<std::string> & listedHandles ) const; std::string generateHandleDependencies( std::pair<std::string, HandleData> const & handle, std::set<std::string> & listedHandles ) const;
@ -856,7 +856,7 @@ private:
std::string std::string
generateSizeCheck( std::vector<std::vector<MemberData>::const_iterator> const & arrayIts, std::string const & structName, bool mutualExclusiveLens ) const; generateSizeCheck( std::vector<std::vector<MemberData>::const_iterator> const & arrayIts, std::string const & structName, bool mutualExclusiveLens ) const;
std::string generateStaticAssertions() const; std::string generateStaticAssertions() const;
std::string generateStaticAssertions( std::vector<RequireData> const & requireData, std::string const & title ) const; std::string generateStaticAssertions( std::vector<RequireData> const & requireData, std::string const & title, std::set<std::string> & listedStructs ) const;
std::string generateStruct( std::pair<std::string, StructureData> const & structure, std::set<std::string> & listedStructs ) const; std::string generateStruct( std::pair<std::string, StructureData> const & structure, std::set<std::string> & listedStructs ) const;
std::string generateStructCompareOperators( std::pair<std::string, StructureData> const & structure ) const; std::string generateStructCompareOperators( std::pair<std::string, StructureData> const & structure ) const;
std::string generateStructConstructors( std::pair<std::string, StructureData> const & structData ) const; std::string generateStructConstructors( std::pair<std::string, StructureData> const & structData ) const;
@ -871,7 +871,8 @@ private:
std::string std::string
generateStructExtendsStructs( std::vector<RequireData> const & requireData, std::set<std::string> & listedStructs, std::string const & title ) const; generateStructExtendsStructs( std::vector<RequireData> const & requireData, std::set<std::string> & listedStructs, std::string const & title ) const;
std::string generateStructForwardDeclarations() const; std::string generateStructForwardDeclarations() const;
std::string generateStructForwardDeclarations( std::vector<RequireData> const & requireData, std::string const & title ) const; std::string
generateStructForwardDeclarations( std::vector<RequireData> const & requireData, std::string const & title, std::set<std::string> & listedStructs ) const;
std::tuple<std::string, std::string, std::string, std::string> generateStructMembers( std::pair<std::string, StructureData> const & structData ) const; std::tuple<std::string, std::string, std::string, std::string> generateStructMembers( std::pair<std::string, StructureData> const & structData ) const;
std::string generateStructSetter( std::string const & structureName, std::vector<MemberData> const & memberData, size_t index ) const; std::string generateStructSetter( std::string const & structureName, std::vector<MemberData> const & memberData, size_t index ) const;
std::string generateStructSubConstructor( std::pair<std::string, StructureData> const & structData ) const; std::string generateStructSubConstructor( std::pair<std::string, StructureData> const & structData ) const;
@ -1014,9 +1015,9 @@ private:
std::set<std::string> m_removedFeatures; std::set<std::string> m_removedFeatures;
std::set<std::string> m_removedStructs; std::set<std::string> m_removedStructs;
std::map<std::string, TypeData> m_removedTypes; std::map<std::string, TypeData> m_removedTypes;
std::map<std::string, StructureData> m_structures; std::map<std::string, StructureData> m_structs;
std::map<std::string, StructureAliasData> m_structureAliases; std::map<std::string, StructureAliasData> m_structsAliases;
std::map<std::string, std::set<std::string>> m_structureAliasesInverse; std::map<std::string, std::set<std::string>> m_structsAliasesInverse;
std::set<std::string> m_tags; std::set<std::string> m_tags;
std::map<std::string, TypeData> m_types; std::map<std::string, TypeData> m_types;
std::string m_typesafeCheck; std::string m_typesafeCheck;

File diff suppressed because it is too large Load Diff