diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index beeab2c..6c97951 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -760,6 +760,15 @@ void VulkanHppGenerator::generateToStringHppFile() const #include +// ignore warnings on using deprecated enum values in this header +#if defined( __clang__ ) || defined( __GNUC__ ) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif defined( _MSC_VER ) +# pragma warning( push ) +# pragma warning( disable : 4996 ) +#endif + #if __cpp_lib_format # include // std::format #else @@ -771,6 +780,13 @@ namespace VULKAN_HPP_NAMESPACE ${bitmasksToString} ${enumsToString} } // namespace VULKAN_HPP_NAMESPACE + +#if defined( __clang__ ) || defined( __GNUC__ ) +# pragma GCC diagnostic pop +#elif defined( _MSC_VER ) +# pragma warning( pop ) +#endif + #endif )"; @@ -6763,7 +6779,12 @@ std::string VulkanHppGenerator::generateEnum( std::pair c { enumValues += previousLeave + enter; } - enumValues += " " + valueName + " = " + value.name + ",\n"; + enumValues += " " + valueName; + if ( value.deprecated ) + { + enumValues += " VULKAN_HPP_DEPRECATED_17( \"" + valueName + " is deprecated, but no reason was given in the API XML\" )"; + } + enumValues += " = " + value.name + ",\n"; for ( auto const & valueAlias : value.aliases ) { @@ -13464,6 +13485,7 @@ void VulkanHppGenerator::readEnumsConstants( tinyxml2::XMLElement const * elemen void VulkanHppGenerator::readEnumsEnum( tinyxml2::XMLElement const * element, std::map::iterator enumIt ) { const int line = element->GetLineNum(); + bool deprecated = false; std::map attributes = getAttributes( element ); if ( attributes.contains( "alias" ) ) { @@ -13484,7 +13506,7 @@ void VulkanHppGenerator::readEnumsEnum( tinyxml2::XMLElement const * element, st } else if ( attribute.first == "deprecated" ) { - // the enum value is marked as deprecated/aliased but still exisits -> no modifications needed here + deprecated = true; } else if ( attribute.first == "name" ) { @@ -13524,7 +13546,7 @@ void VulkanHppGenerator::readEnumsEnum( tinyxml2::XMLElement const * element, st checkForError( name.starts_with( prefix ), line, "encountered enum value <" + name + "> that does not begin with expected prefix <" + prefix + ">" ); checkForError( bitpos.empty() ^ value.empty(), line, "both or none of \"bitpos\" and \"value\" are set for enum <" + name + "> which is invalid" ); - enumIt->second.addEnumValue( line, name, "", bitpos, value, true ); + enumIt->second.addEnumValue( line, name, "", bitpos, value, true, deprecated ); } } @@ -14365,6 +14387,7 @@ void VulkanHppGenerator::readRequireEnum( { { "api", { "vulkan", "vulkansc" } }, { "bitpos", {} }, { "comment", {} }, + { "deprecated", { "true" } }, { "dir", { "-" } }, { "extends", {} }, { "extnumber", {} }, @@ -14374,6 +14397,7 @@ void VulkanHppGenerator::readRequireEnum( { "value", {} } } ); std::string api, bitpos, extends, name, offset, protect, type, value; + bool deprecated = false; for ( auto const & attribute : attributes ) { if ( attribute.first == "api" ) @@ -14384,6 +14408,10 @@ void VulkanHppGenerator::readRequireEnum( { bitpos = attribute.second; } + else if ( attribute.first == "deprecated" ) + { + deprecated = true; + } else if ( attribute.first == "extends" ) { extends = attribute.second; @@ -14451,8 +14479,13 @@ void VulkanHppGenerator::readRequireEnum( auto enumIt = findByNameOrAlias( m_enums, extends ); assert( enumIt != m_enums.end() ); - enumIt->second.addEnumValue( - line, name, protect.empty() ? getProtectFromPlatform( platform ) : protect, bitpos + offset, value, ( api.empty() || ( api == m_api ) ) && supported ); + enumIt->second.addEnumValue( line, + name, + protect.empty() ? getProtectFromPlatform( platform ) : protect, + bitpos + offset, + value, + ( api.empty() || ( api == m_api ) ) && supported, + deprecated ); } } } @@ -16244,12 +16277,12 @@ void VulkanHppGenerator::EnumData::addEnumAlias( int line, std::string const & n } void VulkanHppGenerator::EnumData::addEnumValue( - int line, std::string const & name, std::string const & protect, std::string const & bitpos, std::string const & value, bool supported ) + int line, std::string const & name, std::string const & protect, std::string const & bitpos, std::string const & value, bool supported, bool deprecated ) { auto valueIt = findByName( values, name ); if ( valueIt == values.end() ) { - values.push_back( { {}, bitpos, name, protect, supported, value, line } ); + values.push_back( { {}, bitpos, deprecated, name, protect, supported, value, line } ); } else if ( supported ) // only for supported enum values, we need to check for consistency! { diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index c8de96e..fa6c6f6 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -147,6 +147,7 @@ private: { std::map aliases = {}; std::string bitpos = {}; + bool deprecated = {}; std::string name = {}; std::string protect = {}; bool supported = {}; @@ -157,8 +158,13 @@ private: struct EnumData { void addEnumAlias( int line, std::string const & name, std::string const & alias, std::string const & protect, bool supported ); - void addEnumValue( - int line, std::string const & valueName, std::string const & protect, std::string const & bitpos, std::string const & value, bool supported ); + void addEnumValue( int line, + std::string const & valueName, + std::string const & protect, + std::string const & bitpos, + std::string const & value, + bool supported, + bool deprecated ); std::map aliases = {}; std::string bitwidth = {}; diff --git a/snippets/macros.hpp b/snippets/macros.hpp index ee10903..c4a0268 100644 --- a/snippets/macros.hpp +++ b/snippets/macros.hpp @@ -176,6 +176,12 @@ # define VULKAN_HPP_DEPRECATED( msg ) #endif +#if 17 <= VULKAN_HPP_CPP_VERSION +# define VULKAN_HPP_DEPRECATED_17( msg ) [[deprecated( msg )]] +#else +# define VULKAN_HPP_DEPRECATED_17( msg ) +#endif + #if ( 17 <= VULKAN_HPP_CPP_VERSION ) && !defined( VULKAN_HPP_NO_NODISCARD_WARNINGS ) # define VULKAN_HPP_NODISCARD [[nodiscard]] # if defined( VULKAN_HPP_NO_EXCEPTIONS ) diff --git a/vulkan/vulkan_enums.hpp b/vulkan/vulkan_enums.hpp index fe4f89d..42c1449 100644 --- a/vulkan/vulkan_enums.hpp +++ b/vulkan/vulkan_enums.hpp @@ -4501,13 +4501,13 @@ namespace VULKAN_HPP_NAMESPACE eBt709NonlinearEXT = VK_COLOR_SPACE_BT709_NONLINEAR_EXT, eBt2020LinearEXT = VK_COLOR_SPACE_BT2020_LINEAR_EXT, eHdr10St2084EXT = VK_COLOR_SPACE_HDR10_ST2084_EXT, - eDolbyvisionEXT = VK_COLOR_SPACE_DOLBYVISION_EXT, - eHdr10HlgEXT = VK_COLOR_SPACE_HDR10_HLG_EXT, - eAdobergbLinearEXT = VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT, - eAdobergbNonlinearEXT = VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT, - ePassThroughEXT = VK_COLOR_SPACE_PASS_THROUGH_EXT, - eExtendedSrgbNonlinearEXT = VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT, - eDisplayNativeAMD = VK_COLOR_SPACE_DISPLAY_NATIVE_AMD + eDolbyvisionEXT VULKAN_HPP_DEPRECATED_17( "eDolbyvisionEXT is deprecated, but no reason was given in the API XML" ) = VK_COLOR_SPACE_DOLBYVISION_EXT, + eHdr10HlgEXT = VK_COLOR_SPACE_HDR10_HLG_EXT, + eAdobergbLinearEXT = VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT, + eAdobergbNonlinearEXT = VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT, + ePassThroughEXT = VK_COLOR_SPACE_PASS_THROUGH_EXT, + eExtendedSrgbNonlinearEXT = VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT, + eDisplayNativeAMD = VK_COLOR_SPACE_DISPLAY_NATIVE_AMD }; enum class CompositeAlphaFlagBitsKHR : VkCompositeAlphaFlagsKHR diff --git a/vulkan/vulkan_hpp_macros.hpp b/vulkan/vulkan_hpp_macros.hpp index b754679..dd017c6 100644 --- a/vulkan/vulkan_hpp_macros.hpp +++ b/vulkan/vulkan_hpp_macros.hpp @@ -185,6 +185,12 @@ # define VULKAN_HPP_DEPRECATED( msg ) #endif +#if 17 <= VULKAN_HPP_CPP_VERSION +# define VULKAN_HPP_DEPRECATED_17( msg ) [[deprecated( msg )]] +#else +# define VULKAN_HPP_DEPRECATED_17( msg ) +#endif + #if ( 17 <= VULKAN_HPP_CPP_VERSION ) && !defined( VULKAN_HPP_NO_NODISCARD_WARNINGS ) # define VULKAN_HPP_NODISCARD [[nodiscard]] # if defined( VULKAN_HPP_NO_EXCEPTIONS ) diff --git a/vulkan/vulkan_to_string.hpp b/vulkan/vulkan_to_string.hpp index 8417c14..b7c0177 100644 --- a/vulkan/vulkan_to_string.hpp +++ b/vulkan/vulkan_to_string.hpp @@ -10,6 +10,15 @@ #include +// ignore warnings on using deprecated enum values in this header +#if defined( __clang__ ) || defined( __GNUC__ ) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif defined( _MSC_VER ) +# pragma warning( push ) +# pragma warning( disable : 4996 ) +#endif + #if __cpp_lib_format # include // std::format #else @@ -9146,4 +9155,11 @@ namespace VULKAN_HPP_NAMESPACE } } // namespace VULKAN_HPP_NAMESPACE + +#if defined( __clang__ ) || defined( __GNUC__ ) +# pragma GCC diagnostic pop +#elif defined( _MSC_VER ) +# pragma warning( pop ) +#endif + #endif diff --git a/vulkan/vulkansc_enums.hpp b/vulkan/vulkansc_enums.hpp index 469e05e..e11543a 100644 --- a/vulkan/vulkansc_enums.hpp +++ b/vulkan/vulkansc_enums.hpp @@ -3166,20 +3166,20 @@ namespace VULKAN_HPP_NAMESPACE enum class ColorSpaceKHR { - eSrgbNonlinear = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, - eDisplayP3NonlinearEXT = VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT, - eExtendedSrgbLinearEXT = VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT, - eDisplayP3LinearEXT = VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT, - eDciP3NonlinearEXT = VK_COLOR_SPACE_DCI_P3_NONLINEAR_EXT, - eBt709LinearEXT = VK_COLOR_SPACE_BT709_LINEAR_EXT, - eBt709NonlinearEXT = VK_COLOR_SPACE_BT709_NONLINEAR_EXT, - eBt2020LinearEXT = VK_COLOR_SPACE_BT2020_LINEAR_EXT, - eHdr10St2084EXT = VK_COLOR_SPACE_HDR10_ST2084_EXT, - eDolbyvisionEXT = VK_COLOR_SPACE_DOLBYVISION_EXT, - eHdr10HlgEXT = VK_COLOR_SPACE_HDR10_HLG_EXT, - eAdobergbLinearEXT = VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT, - eAdobergbNonlinearEXT = VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT, - ePassThroughEXT = VK_COLOR_SPACE_PASS_THROUGH_EXT, + eSrgbNonlinear = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, + eDisplayP3NonlinearEXT = VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT, + eExtendedSrgbLinearEXT = VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT, + eDisplayP3LinearEXT = VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT, + eDciP3NonlinearEXT = VK_COLOR_SPACE_DCI_P3_NONLINEAR_EXT, + eBt709LinearEXT = VK_COLOR_SPACE_BT709_LINEAR_EXT, + eBt709NonlinearEXT = VK_COLOR_SPACE_BT709_NONLINEAR_EXT, + eBt2020LinearEXT = VK_COLOR_SPACE_BT2020_LINEAR_EXT, + eHdr10St2084EXT = VK_COLOR_SPACE_HDR10_ST2084_EXT, + eDolbyvisionEXT VULKAN_HPP_DEPRECATED_17( "eDolbyvisionEXT is deprecated, but no reason was given in the API XML" ) = VK_COLOR_SPACE_DOLBYVISION_EXT, + eHdr10HlgEXT = VK_COLOR_SPACE_HDR10_HLG_EXT, + eAdobergbLinearEXT = VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT, + eAdobergbNonlinearEXT = VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT, + ePassThroughEXT = VK_COLOR_SPACE_PASS_THROUGH_EXT, eExtendedSrgbNonlinearEXT = VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT }; diff --git a/vulkan/vulkansc_hpp_macros.hpp b/vulkan/vulkansc_hpp_macros.hpp index 9d0e403..b808f5e 100644 --- a/vulkan/vulkansc_hpp_macros.hpp +++ b/vulkan/vulkansc_hpp_macros.hpp @@ -185,6 +185,12 @@ # define VULKAN_HPP_DEPRECATED( msg ) #endif +#if 17 <= VULKAN_HPP_CPP_VERSION +# define VULKAN_HPP_DEPRECATED_17( msg ) [[deprecated( msg )]] +#else +# define VULKAN_HPP_DEPRECATED_17( msg ) +#endif + #if ( 17 <= VULKAN_HPP_CPP_VERSION ) && !defined( VULKAN_HPP_NO_NODISCARD_WARNINGS ) # define VULKAN_HPP_NODISCARD [[nodiscard]] # if defined( VULKAN_HPP_NO_EXCEPTIONS ) diff --git a/vulkan/vulkansc_to_string.hpp b/vulkan/vulkansc_to_string.hpp index 261b40f..7820a9b 100644 --- a/vulkan/vulkansc_to_string.hpp +++ b/vulkan/vulkansc_to_string.hpp @@ -10,6 +10,15 @@ #include +// ignore warnings on using deprecated enum values in this header +#if defined( __clang__ ) || defined( __GNUC__ ) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif defined( _MSC_VER ) +# pragma warning( push ) +# pragma warning( disable : 4996 ) +#endif + #if __cpp_lib_format # include // std::format #else @@ -4411,4 +4420,11 @@ namespace VULKAN_HPP_NAMESPACE } } // namespace VULKAN_HPP_NAMESPACE + +#if defined( __clang__ ) || defined( __GNUC__ ) +# pragma GCC diagnostic pop +#elif defined( _MSC_VER ) +# pragma warning( pop ) +#endif + #endif