Extend support of video format properties (no code generated) (#1937)

This commit is contained in:
Andreas Süßenbach 2024-08-06 09:22:31 +02:00 committed by GitHub
parent dd0785dbc1
commit 6a11b182e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 102 additions and 40 deletions

View File

@ -5785,7 +5785,7 @@ std::string VulkanHppGenerator::generateCppModuleUsings() const
const auto [enterNoSmartHandle, leaveNoSmartHandle] = generateProtection( "VULKAN_HPP_NO_SMART_HANDLE", false ); const auto [enterNoSmartHandle, leaveNoSmartHandle] = generateProtection( "VULKAN_HPP_NO_SMART_HANDLE", false );
usings += "\n" + enterNoSmartHandle + noSmartHandleUsings + leaveNoSmartHandle + "\n"; usings += "\n" + enterNoSmartHandle + noSmartHandleUsings + leaveNoSmartHandle + "\n";
for ( auto const& functionName : hardCodedFunctions ) for ( auto const & functionName : hardCodedFunctions )
{ {
usings += "\n" + replaceWithMap( usingTemplate, { { "className", std::string{ functionName } } } ); usings += "\n" + replaceWithMap( usingTemplate, { { "className", std::string{ functionName } } } );
} }
@ -5863,8 +5863,7 @@ std::string VulkanHppGenerator::generateCppModuleUsings() const
usings += exceptionsLeave + "\n"; usings += exceptionsLeave + "\n";
// some hardcoded types // some hardcoded types
auto const hardCodedResultValueTypes = auto const hardCodedResultValueTypes = std::array{ "ResultValue", "ResultValueType" };
std::array{ "ResultValue", "ResultValueType" };
for ( auto const & valueType : hardCodedResultValueTypes ) for ( auto const & valueType : hardCodedResultValueTypes )
{ {
usings += replaceWithMap( usingTemplate, { { "className", valueType } } ); usings += replaceWithMap( usingTemplate, { { "className", valueType } } );
@ -9991,8 +9990,7 @@ std::tuple<std::string, std::string, std::string, std::string, std::string, std:
clearMembers += "\n m_constructorSuccessCode = VULKAN_HPP_NAMESPACE::Result::eErrorUnknown;"; clearMembers += "\n m_constructorSuccessCode = VULKAN_HPP_NAMESPACE::Result::eErrorUnknown;";
memberVariables += "\n VULKAN_HPP_NAMESPACE::Result m_constructorSuccessCode = VULKAN_HPP_NAMESPACE::Result::eErrorUnknown;"; memberVariables += "\n VULKAN_HPP_NAMESPACE::Result m_constructorSuccessCode = VULKAN_HPP_NAMESPACE::Result::eErrorUnknown;";
swapMembers += "\n std::swap( m_constructorSuccessCode, rhs.m_constructorSuccessCode );"; swapMembers += "\n std::swap( m_constructorSuccessCode, rhs.m_constructorSuccessCode );";
moveConstructorInitializerList += moveConstructorInitializerList += "m_constructorSuccessCode( VULKAN_HPP_NAMESPACE::exchange( rhs.m_constructorSuccessCode, {} ) ), ";
"m_constructorSuccessCode( VULKAN_HPP_NAMESPACE::exchange( rhs.m_constructorSuccessCode, {} ) ), ";
moveAssignmentInstructions += "\n std::swap( m_constructorSuccessCode, rhs.m_constructorSuccessCode );"; moveAssignmentInstructions += "\n std::swap( m_constructorSuccessCode, rhs.m_constructorSuccessCode );";
releaseMembers += "\n m_constructorSuccessCode = VULKAN_HPP_NAMESPACE::Result::eErrorUnknown;"; releaseMembers += "\n m_constructorSuccessCode = VULKAN_HPP_NAMESPACE::Result::eErrorUnknown;";
} }
@ -15719,10 +15717,12 @@ void VulkanHppGenerator::readVideoCapabilities( tinyxml2::XMLElement const * ele
checkAttributes( line, attributes, { { "struct", {} } }, {} ); checkAttributes( line, attributes, { { "struct", {} } }, {} );
checkElements( line, getChildElements( element ), {} ); checkElements( line, getChildElements( element ), {} );
videoCodec.capabilities = attributes.find( "struct" )->second; std::string capabilities = attributes.find( "struct" )->second;
checkForError( m_structs.contains( videoCodec.capabilities ), checkForError( std::find( videoCodec.capabilities.begin(), videoCodec.capabilities.end(), capabilities ) == videoCodec.capabilities.end(),
line, line,
"videocodec <" + videoCodec.name + "> lists unknown capabilities struct <" + videoCodec.capabilities + ">" ); "videocapabilities struct <" + capabilities + "> already listed for videoCodec <" + videoCodec.name + ">" );
checkForError( m_structs.contains( capabilities ), line, "videocodec <" + videoCodec.name + "> lists unknown capabilities struct <" + capabilities + ">" );
videoCodec.capabilities.push_back( capabilities );
} }
void VulkanHppGenerator::readVideoCodec( tinyxml2::XMLElement const * element ) void VulkanHppGenerator::readVideoCodec( tinyxml2::XMLElement const * element )
@ -15732,7 +15732,7 @@ void VulkanHppGenerator::readVideoCodec( tinyxml2::XMLElement const * element )
checkAttributes( line, attributes, { { "name", {} } }, { { "extend", {} }, { "value", {} } } ); checkAttributes( line, attributes, { { "name", {} } }, { { "extend", {} }, { "value", {} } } );
std::vector<tinyxml2::XMLElement const *> children = getChildElements( element ); std::vector<tinyxml2::XMLElement const *> children = getChildElements( element );
checkElements( line, children, { { "videocapabilities", true } }, { "videoformat", "videoprofiles" } ); checkElements( line, children, { { "videocapabilities", false } }, { "videoformat", "videoprofiles" } );
VideoCodec videoCodec; VideoCodec videoCodec;
videoCodec.xmlLine = line; videoCodec.xmlLine = line;
@ -15804,10 +15804,43 @@ void VulkanHppGenerator::readVideoFormat( tinyxml2::XMLElement const * element,
{ {
const int line = element->GetLineNum(); const int line = element->GetLineNum();
std::map<std::string, std::string> attributes = getAttributes( element ); std::map<std::string, std::string> attributes = getAttributes( element );
if ( attributes.contains( "extend" ) )
{
checkAttributes( line, attributes, { { "extend", {} } }, {} );
std::vector<tinyxml2::XMLElement const *> children = getChildElements( element );
checkElements( line, children, { { "videoformatproperties", true } } );
std::string extend = attributes.find( "extend" )->second;
std::vector<VideoFormat>::iterator videoFormatIt;
auto videoCodecIt = std::find_if( m_videoCodecs.begin(),
m_videoCodecs.end(),
[&extend, &videoFormatIt]( auto & vc )
{
videoFormatIt =
std::find_if( vc.formats.begin(), vc.formats.end(), [&extend]( auto & vf ) { return vf.name == extend; } );
return videoFormatIt != vc.formats.end();
} );
checkForError( videoCodecIt != m_videoCodecs.end(), line, "videocodec <" + videoCodec.name + "> extends unknown videoformat <" + extend + ">" );
for ( auto child : children )
{
std::string value = child->Value();
if ( value == "videoformatproperties" )
{
readVideoFormatProperties( child, videoCodecIt->name, *videoFormatIt );
}
}
}
else
{
checkAttributes( line, attributes, { { "name", {} }, { "usage", {} } }, {} ); checkAttributes( line, attributes, { { "name", {} }, { "usage", {} } }, {} );
std::vector<tinyxml2::XMLElement const *> children = getChildElements( element ); std::vector<tinyxml2::XMLElement const *> children = getChildElements( element );
checkElements( line, children, {}, { "videorequirecapabilities" } ); checkElements( line, children, {}, { "videoformatproperties", "videorequirecapabilities" } );
auto flagBitsIt = m_enums.find( "VkImageUsageFlagBits" ); auto flagBitsIt = m_enums.find( "VkImageUsageFlagBits" );
assert( flagBitsIt != m_enums.end() ); assert( flagBitsIt != m_enums.end() );
@ -15839,9 +15872,16 @@ void VulkanHppGenerator::readVideoFormat( tinyxml2::XMLElement const * element,
for ( auto child : children ) for ( auto child : children )
{ {
std::string value = child->Value(); std::string value = child->Value();
assert( value == "videorequirecapabilities" ); if ( value == "videoformatproperties" )
{
readVideoFormatProperties( child, videoCodec.name, videoCodec.formats.back() );
}
else if ( value == "videorequirecapabilities" )
{
readVideoRequireCapabilities( child, videoCodec ); readVideoRequireCapabilities( child, videoCodec );
} }
}
}
} }
void VulkanHppGenerator::readVideoProfileMember( tinyxml2::XMLElement const * element, VideoCodec & videoCodec ) void VulkanHppGenerator::readVideoProfileMember( tinyxml2::XMLElement const * element, VideoCodec & videoCodec )
@ -15932,6 +15972,26 @@ void VulkanHppGenerator::readVideoProfiles( tinyxml2::XMLElement const * element
} }
} }
void VulkanHppGenerator::readVideoFormatProperties( tinyxml2::XMLElement const * element, std::string const & videoCodec, VideoFormat & videoFormat )
{
const int line = element->GetLineNum();
std::map<std::string, std::string> attributes = getAttributes( element );
checkAttributes( line, attributes, { { "struct", {} } }, {} );
checkElements( line, getChildElements( element ), {} );
std::string formatProperties = attributes.find( "struct" )->second;
checkForError( m_structs.find( formatProperties ) != m_structs.end(),
line,
"videoCodec <" + videoCodec + "> lists unknown struct <" + formatProperties + "> as videoformatproperties" );
checkForError( std::find( videoFormat.formatProperties.begin(), videoFormat.formatProperties.end(), formatProperties ) == videoFormat.formatProperties.end(),
line,
"videoformatproperties <" + formatProperties + "> listed in videocodec <" + videoCodec + "> already listed for videoformat <" +
videoFormat.name + ">" );
videoFormat.formatProperties.push_back( formatProperties );
}
void VulkanHppGenerator::readVideoRequireCapabilities( tinyxml2::XMLElement const * element, VideoCodec & videoCodec ) void VulkanHppGenerator::readVideoRequireCapabilities( tinyxml2::XMLElement const * element, VideoCodec & videoCodec )
{ {
const int line = element->GetLineNum(); const int line = element->GetLineNum();

View File

@ -398,6 +398,7 @@ private:
struct VideoFormat struct VideoFormat
{ {
int xmlLine = {}; int xmlLine = {};
std::vector<std::string> formatProperties;
std::string name; std::string name;
std::vector<std::string> usage; std::vector<std::string> usage;
std::vector<VideoRequireCapabilities> requireCapabilities; std::vector<VideoRequireCapabilities> requireCapabilities;
@ -428,7 +429,7 @@ private:
{ {
int xmlLine = {}; int xmlLine = {};
std::string name; std::string name;
std::string capabilities; std::vector<std::string> capabilities;
std::string extend; std::string extend;
std::string value; std::string value;
std::vector<VideoFormat> formats; std::vector<VideoFormat> formats;
@ -1090,6 +1091,7 @@ private:
void readVideoProfileMember( tinyxml2::XMLElement const * element, VideoCodec & videoCodec ); void readVideoProfileMember( tinyxml2::XMLElement const * element, VideoCodec & videoCodec );
void readVideoProfile( tinyxml2::XMLElement const * element, VideoCodec & videoCodec ); void readVideoProfile( tinyxml2::XMLElement const * element, VideoCodec & videoCodec );
void readVideoProfiles( tinyxml2::XMLElement const * element, VideoCodec & videoCodec ); void readVideoProfiles( tinyxml2::XMLElement const * element, VideoCodec & videoCodec );
void readVideoFormatProperties( tinyxml2::XMLElement const * element, std::string const & videoCodec, VideoFormat & videoFormat );
void readVideoRequireCapabilities( tinyxml2::XMLElement const * element, VideoCodec & videoCodec ); void readVideoRequireCapabilities( tinyxml2::XMLElement const * element, VideoCodec & videoCodec );
void registerDeleter( std::string const & commandName, CommandData const & commandData ); void registerDeleter( std::string const & commandName, CommandData const & commandData );
void rescheduleRAIIHandle( std::string & str, void rescheduleRAIIHandle( std::string & str,