diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 84c9fbf..4d3c6c6 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -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 +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 +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 diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index 27a3e9d..0d3868f 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -693,16 +693,16 @@ private: std::string generateEnumToString( std::pair const & enumData ) const; std::pair 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 const & successCodes ) const; - std::string generateFormatTraits() const; - std::string generateFunctionPointerCheck( std::string const & function, std::set const & requiredBy ) const; - std::string generateHandle( std::pair const & handle, std::set & listedHandles ) const; - std::string generateHandleCommandDeclarations( std::set const & commands ) const; + template + std::string generateExtensionReplacedBy( Predicate p, Extraction e ) const; + template + std::string generateExtensionReplacedTest( Predicate p ) const; + std::string generateExtensionTypeTest( std::string const & type ) const; + std::string generateFailureCheck( std::vector const & successCodes ) const; + std::string generateFormatTraits() const; + std::string generateFunctionPointerCheck( std::string const & function, std::set const & requiredBy ) const; + std::string generateHandle( std::pair const & handle, std::set & listedHandles ) const; + std::string generateHandleCommandDeclarations( std::set const & commands ) const; std::string generateHandleDependencies( std::pair const & handle, std::set & listedHandles ) const; std::string generateHandleEmpty( HandleData const & handleData ) const; std::string generateHandleForwardDeclarations() const; diff --git a/vulkan/vulkan_extension_inspection.hpp b/vulkan/vulkan_extension_inspection.hpp index 936c0ae..6bc4964 100644 --- a/vulkan/vulkan_extension_inspection.hpp +++ b/vulkan/vulkan_extension_inspection.hpp @@ -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" ) || diff --git a/vulkan/vulkansc_extension_inspection.hpp b/vulkan/vulkansc_extension_inspection.hpp index d486cd2..c3c0b7a 100644 --- a/vulkan/vulkansc_extension_inspection.hpp +++ b/vulkan/vulkansc_extension_inspection.hpp @@ -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" ) ||