Skip to content

Commit 2518f52

Browse files
authored
Simplify handling of structextends (#1866)
1 parent c1fb252 commit 2518f52

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

VulkanHppGenerator.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12531,7 +12531,7 @@ bool VulkanHppGenerator::isStructureChainAnchor( std::string const & type ) cons
1253112531
auto it = findByNameOrAlias( m_structs, type );
1253212532
if ( it != m_structs.end() )
1253312533
{
12534-
return m_extendedStructs.contains( it->first );
12534+
return it->second.isExtended;
1253512535
}
1253612536
}
1253712537
return false;
@@ -12605,6 +12605,19 @@ bool VulkanHppGenerator::isTypeUsed( std::string const & type ) const
1260512605
return false;
1260612606
}
1260712607

12608+
void VulkanHppGenerator::markExtendedStructs()
12609+
{
12610+
for (auto const& s : m_structs)
12611+
{
12612+
for (auto const& extends : s.second.structExtends)
12613+
{
12614+
auto structIt = m_structs.find( extends );
12615+
checkForError( structIt != m_structs.end(), s.second.xmlLine, "struct <" + s.first + "> extends unknown struct <" + extends + ">" );
12616+
structIt->second.isExtended = true;
12617+
}
12618+
}
12619+
}
12620+
1260812621
bool VulkanHppGenerator::needsStructureChainResize( std::map<size_t, VectorParamData> const & vectorParams,
1260912622
std::vector<size_t> const & chainedReturnParams ) const
1261012623
{
@@ -13760,6 +13773,7 @@ void VulkanHppGenerator::readRegistry( tinyxml2::XMLElement const * element )
1376013773
else if ( value == "types" )
1376113774
{
1376213775
readTypes( child );
13776+
markExtendedStructs();
1376313777
}
1376413778
}
1376513779
}
@@ -14954,7 +14968,6 @@ void VulkanHppGenerator::readTypeStruct( tinyxml2::XMLElement const * element, b
1495414968
checkForError( m_types.insert( { name, TypeData{ TypeCategory::Struct, {}, line } } ).second, line, "struct <" + name + "> already specified" );
1495514969
checkForError( m_structsAliases.insert( { name, { alias, line } } ).second, line, "struct alias <" + name + "> already listed" );
1495614970
}
14957-
1495814971
else
1495914972
{
1496014973
checkAttributes( line,
@@ -15075,8 +15088,6 @@ void VulkanHppGenerator::readTypeStruct( tinyxml2::XMLElement const * element, b
1507515088
}
1507615089
}
1507715090
}
15078-
15079-
m_extendedStructs.insert( structureData.structExtends.begin(), structureData.structExtends.end() );
1508015091
}
1508115092
}
1508215093

VulkanHppGenerator.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ class VulkanHppGenerator
366366
{
367367
std::map<std::string, int> aliases = {};
368368
bool allowDuplicate = {};
369+
bool isExtended = {};
369370
bool isUnion = {};
370371
bool returnedOnly = {};
371372
bool mutualExclusiveLens = {};
@@ -953,6 +954,7 @@ class VulkanHppGenerator
953954
bool isSupportedFeature( std::string const & name ) const;
954955
bool isTypeRequired( std::string const & type ) const;
955956
bool isTypeUsed( std::string const & type ) const;
957+
void markExtendedStructs();
956958
bool needsStructureChainResize( std::map<size_t, VectorParamData> const & vectorParams, std::vector<size_t> const & chainedReturnParams ) const;
957959
std::pair<bool, std::map<size_t, std::vector<size_t>>> needsVectorSizeCheck( std::vector<ParamData> const & params,
958960
std::map<size_t, VectorParamData> const & vectorParams,
@@ -1042,7 +1044,6 @@ class VulkanHppGenerator
10421044
std::map<std::string, DefineData> m_defines;
10431045
DefinesPartition m_definesPartition; // partition defined macros into mutually-exclusive sets of callees, callers, and values
10441046
std::map<std::string, EnumData> m_enums;
1045-
std::set<std::string> m_extendedStructs; // structs which are referenced by the structextends tag
10461047
std::vector<ExtensionData> m_extensions;
10471048
std::map<std::string, ExternalTypeData> m_externalTypes;
10481049
std::vector<FeatureData> m_features;

0 commit comments

Comments
 (0)