Add new extension inspection functions getExtensionObsoletedBy() and isExtensionObsoleted() (#1555)

This commit is contained in:
Andreas Süßenbach 2023-04-05 13:37:34 +02:00 committed by GitHub
parent bf8bee64e1
commit a4841bc2f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 97 additions and 83 deletions

View File

@ -136,9 +136,11 @@ namespace VULKAN_HPP_NAMESPACE
//======================================
VULKAN_HPP_CONSTEXPR_20 std::string getExtensionDeprecatedBy( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 std::string getExtensionObsoletedBy( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 std::string getExtensionPromotedTo( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isDeviceExtension( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isExtensionDeprecated( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isExtensionObsoleted( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isExtensionPromoted( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isInstanceExtension( std::string const & name );
@ -152,6 +154,12 @@ namespace VULKAN_HPP_NAMESPACE
${deprecatedBy}
}
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_20 std::string getExtensionObsoletedBy( std::string const & name )
{
${voidName}
${obsoletedBy}
}
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_20 std::string getExtensionPromotedTo( std::string const & name )
{
${promotedTo}
@ -168,6 +176,12 @@ namespace VULKAN_HPP_NAMESPACE
return ${deprecatedTest};
}
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_20 bool isExtensionObsoleted( std::string const & name )
{
${voidName}
return ${obsoletedTest};
}
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_20 bool isExtensionPromoted( std::string const & name )
{
return ${promotedTest};
@ -182,16 +196,25 @@ namespace VULKAN_HPP_NAMESPACE
#endif
)";
std::string str = replaceWithMap( vulkanExtensionInspectionHppTemplate,
{ { "api", m_api },
{ "deviceTest", generateExtensionTypeTest( "device" ) },
{ "deprecatedBy", generateExtensionDeprecatedBy() },
{ "deprecatedTest", generateExtensionDeprecatedTest() },
{ "instanceTest", generateExtensionTypeTest( "instance" ) },
{ "licenseHeader", m_vulkanLicenseHeader },
{ "promotedTest", generateExtensionPromotedTest() },
{ "promotedTo", generateExtensionPromotedTo() },
{ "voidName", ( m_api == "vulkan" ) ? "" : "(void)name;" } } );
std::string str =
replaceWithMap( vulkanExtensionInspectionHppTemplate,
{ { "api", m_api },
{ "deviceTest", generateExtensionTypeTest( "device" ) },
{ "deprecatedBy",
generateExtensionReplacedBy( []( ExtensionData const & extension ) { return extension.isDeprecated; },
[]( ExtensionData const & extension ) { return extension.deprecatedBy; } ) },
{ "deprecatedTest", generateExtensionReplacedTest( []( ExtensionData const & extension ) { return extension.isDeprecated; } ) },
{ "instanceTest", generateExtensionTypeTest( "instance" ) },
{ "licenseHeader", m_vulkanLicenseHeader },
{ "obsoletedBy",
generateExtensionReplacedBy( []( ExtensionData const & extension ) { return !extension.obsoletedBy.empty(); },
[]( ExtensionData const & extension ) { return extension.obsoletedBy; } ) },
{ "obsoletedTest", generateExtensionReplacedTest( []( ExtensionData const & extension ) { return !extension.obsoletedBy.empty(); } ) },
{ "promotedTest", generateExtensionReplacedTest( []( ExtensionData const & extension ) { return !extension.promotedTo.empty(); } ) },
{ "promotedTo",
generateExtensionReplacedBy( []( ExtensionData const & extension ) { return !extension.promotedTo.empty(); },
[]( ExtensionData const & extension ) { return extension.promotedTo; } ) },
{ "voidName", ( m_api == "vulkan" ) ? "" : "(void)name;" } } );
writeToFile( str, vulkan_extension_inspection_hpp );
}
@ -5587,99 +5610,59 @@ std::string VulkanHppGenerator::generateEnumValueName( std::string const & enumN
return result;
}
std::string VulkanHppGenerator::generateExtensionDeprecatedBy() const
template <class Predicate, class Extraction>
std::string VulkanHppGenerator::generateExtensionReplacedBy( Predicate p, Extraction e ) const
{
std::string deprecatedBy, previousEnter, previousLeave;
std::string replacedBy, previousEnter, previousLeave;
for ( auto const & extension : m_extensions )
{
if ( extension.isDeprecated )
if ( p( extension ) )
{
auto [enter, leave] = generateProtection( getProtectFromTitle( extension.name ) );
deprecatedBy += ( ( previousEnter != enter ) ? ( "\n" + previousLeave + enter ) : "\n" ) + " if ( name == \"" + extension.name + "\" ) { return \"" +
extension.deprecatedBy + "\"; }";
replacedBy += ( ( previousEnter != enter ) ? ( "\n" + previousLeave + enter ) : "\n" ) + " if ( name == \"" + extension.name + "\" ) { return \"" +
e( extension ) + "\"; }";
previousEnter = enter;
previousLeave = leave;
}
}
if ( !previousLeave.empty() )
{
deprecatedBy += "\n" + previousLeave;
replacedBy += "\n" + previousLeave;
}
deprecatedBy += "\n return \"\";";
return deprecatedBy;
replacedBy += "\n return \"\";";
return replacedBy;
}
std::string VulkanHppGenerator::generateExtensionDeprecatedTest() const
template <class Predicate>
std::string VulkanHppGenerator::generateExtensionReplacedTest( Predicate p ) const
{
std::string deprecatedTest, previousEnter, previousLeave;
std::string replacedTest, previousEnter, previousLeave;
bool unprotectedEntry = false;
for ( auto const & extension : m_extensions )
{
if ( extension.isDeprecated )
if ( p( extension ) )
{
auto [enter, leave] = generateProtection( getProtectFromTitle( extension.name ) );
deprecatedTest += ( ( previousEnter != enter ) ? ( "\n" + previousLeave + enter ) : "\n" ) + "( name == \"" + extension.name + "\" ) || ";
unprotectedEntry |= enter.empty();
replacedTest += ( ( previousEnter != enter ) ? ( "\n" + previousLeave + enter ) : "\n" ) + "( name == \"" + extension.name + "\" ) || ";
previousEnter = enter;
previousLeave = leave;
}
}
if ( m_api == "vulkan" )
if ( unprotectedEntry )
{
assert( deprecatedTest.ends_with( " || " ) );
deprecatedTest = deprecatedTest.substr( 0, deprecatedTest.length() - 4 );
assert( replacedTest.ends_with( " || " ) );
replacedTest = replacedTest.substr( 0, replacedTest.length() - 4 );
}
if ( !previousLeave.empty() )
{
deprecatedTest += "\n" + previousLeave;
replacedTest += "\n" + previousLeave;
}
if ( m_api != "vulkan" )
if ( !unprotectedEntry )
{
deprecatedTest += "false"; // there might be no deprecations at all, so add a "false" at the end...
replacedTest += "false"; // there might be no replacements at all, so add a "false" at the end...
}
return deprecatedTest;
}
std::string VulkanHppGenerator::generateExtensionPromotedTest() const
{
std::string promotedTest, previousEnter, previousLeave;
for ( auto const & extension : m_extensions )
{
if ( !extension.promotedTo.empty() )
{
auto [enter, leave] = generateProtection( getProtectFromTitle( extension.name ) );
promotedTest += ( ( previousEnter != enter ) ? ( "\n" + previousLeave + enter ) : "\n" ) + "( name == \"" + extension.name + "\" ) || ";
previousEnter = enter;
previousLeave = leave;
}
}
assert( promotedTest.ends_with( " || " ) );
promotedTest = promotedTest.substr( 0, promotedTest.length() - 4 );
if ( !previousLeave.empty() )
{
promotedTest += "\n" + previousLeave;
}
return promotedTest;
}
std::string VulkanHppGenerator::generateExtensionPromotedTo() const
{
std::string promotedTo, previousEnter, previousLeave;
for ( auto const & extension : m_extensions )
{
if ( !extension.promotedTo.empty() )
{
auto [enter, leave] = generateProtection( getProtectFromTitle( extension.name ) );
promotedTo += ( ( previousEnter != enter ) ? ( "\n" + previousLeave + enter ) : "\n" ) + " if ( name == \"" + extension.name + "\" ) { return \"" +
extension.promotedTo + "\"; }";
previousEnter = enter;
previousLeave = leave;
}
}
if ( !previousLeave.empty() )
{
promotedTo += "\n" + previousLeave;
}
promotedTo += "\n return \"\";";
return promotedTo;
return replacedTest;
}
std::string VulkanHppGenerator::generateExtensionTypeTest( std::string const & type ) const

View File

@ -693,16 +693,16 @@ private:
std::string generateEnumToString( std::pair<std::string, EnumData> const & enumData ) const;
std::pair<std::string, std::string> generateEnumSuffixes( std::string const & name, bool bitmask ) const;
std::string generateEnumValueName( std::string const & enumName, std::string const & valueName, bool bitmask ) const;
std::string generateExtensionDeprecatedBy() const;
std::string generateExtensionDeprecatedTest() const;
std::string generateExtensionPromotedTest() const;
std::string generateExtensionPromotedTo() const;
std::string generateExtensionTypeTest( std::string const & type ) const;
std::string generateFailureCheck( std::vector<std::string> const & successCodes ) const;
std::string generateFormatTraits() const;
std::string generateFunctionPointerCheck( std::string const & function, std::set<std::string> const & requiredBy ) 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;
template <class Predicate, class Extraction>
std::string generateExtensionReplacedBy( Predicate p, Extraction e ) const;
template <class Predicate>
std::string generateExtensionReplacedTest( Predicate p ) const;
std::string generateExtensionTypeTest( std::string const & type ) const;
std::string generateFailureCheck( std::vector<std::string> const & successCodes ) const;
std::string generateFormatTraits() const;
std::string generateFunctionPointerCheck( std::string const & function, std::set<std::string> const & requiredBy ) 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 generateHandleDependencies( std::pair<std::string, HandleData> const & handle, std::set<std::string> & listedHandles ) const;
std::string generateHandleEmpty( HandleData const & handleData ) const;
std::string generateHandleForwardDeclarations() const;

View File

@ -17,9 +17,11 @@ namespace VULKAN_HPP_NAMESPACE
//======================================
VULKAN_HPP_CONSTEXPR_20 std::string getExtensionDeprecatedBy( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 std::string getExtensionObsoletedBy( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 std::string getExtensionPromotedTo( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isDeviceExtension( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isExtensionDeprecated( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isExtensionObsoleted( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isExtensionPromoted( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isInstanceExtension( std::string const & name );
@ -98,6 +100,15 @@ namespace VULKAN_HPP_NAMESPACE
return "";
}
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_20 std::string getExtensionObsoletedBy( std::string const & name )
{
if ( name == "VK_AMD_negative_viewport_height" )
{
return "VK_KHR_maintenance1";
}
return "";
}
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_20 std::string getExtensionPromotedTo( std::string const & name )
{
if ( name == "VK_KHR_sampler_mirror_clamp_to_edge" )
@ -581,6 +592,11 @@ namespace VULKAN_HPP_NAMESPACE
( name == "VK_AMD_gpu_shader_int16" ) || ( name == "VK_EXT_buffer_device_address" );
}
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_20 bool isExtensionObsoleted( std::string const & name )
{
return ( name == "VK_AMD_negative_viewport_height" );
}
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_20 bool isExtensionPromoted( std::string const & name )
{
return ( name == "VK_KHR_sampler_mirror_clamp_to_edge" ) || ( name == "VK_EXT_debug_marker" ) || ( name == "VK_AMD_draw_indirect_count" ) ||

View File

@ -17,9 +17,11 @@ namespace VULKAN_HPP_NAMESPACE
//======================================
VULKAN_HPP_CONSTEXPR_20 std::string getExtensionDeprecatedBy( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 std::string getExtensionObsoletedBy( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 std::string getExtensionPromotedTo( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isDeviceExtension( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isExtensionDeprecated( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isExtensionObsoleted( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isExtensionPromoted( std::string const & name );
VULKAN_HPP_CONSTEXPR_20 bool isInstanceExtension( std::string const & name );
@ -41,6 +43,13 @@ namespace VULKAN_HPP_NAMESPACE
return "";
}
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_20 std::string getExtensionObsoletedBy( std::string const & name )
{
(void)name;
return "";
}
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_20 std::string getExtensionPromotedTo( std::string const & name )
{
if ( name == "VK_EXT_texture_compression_astc_hdr" )
@ -139,6 +148,12 @@ namespace VULKAN_HPP_NAMESPACE
false;
}
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_20 bool isExtensionObsoleted( std::string const & name )
{
(void)name;
return false;
}
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_20 bool isExtensionPromoted( std::string const & name )
{
return ( name == "VK_EXT_texture_compression_astc_hdr" ) || ( name == "VK_EXT_global_priority" ) || ( name == "VK_KHR_shader_terminate_invocation" ) ||