mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Introduce overload of getExtensionDepends to get availability and dependencies by vulkan version. (#1559)
This commit is contained in:
parent
9de0959474
commit
3427b0039b
@ -141,6 +141,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
std::set<std::string> const & getInstanceExtensions();
|
||||
std::map<std::string, std::string> const & getDeprecatedExtensions();
|
||||
std::map<std::string, std::vector<std::string>> const & getExtensionDepends( std::string const & extension );
|
||||
${getExtensionDependsByVersionDeclaration}
|
||||
std::map<std::string, std::string> const & getObsoletedExtensions();
|
||||
std::map<std::string, std::string> const & getPromotedExtensions();
|
||||
VULKAN_HPP_CONSTEXPR_20 std::string getExtensionDeprecatedBy( std::string const & extension );
|
||||
@ -182,6 +183,8 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
return ( depIt != dependencies.end() ) ? depIt->second : noDependencies;
|
||||
}
|
||||
|
||||
${getExtensionDependsByVersionDefinition}
|
||||
|
||||
VULKAN_HPP_INLINE std::map<std::string, std::string> const & getObsoletedExtensions()
|
||||
{
|
||||
static std::map<std::string, std::string> obsoletedExtensions = { ${obsoletedExtensions} };
|
||||
@ -255,6 +258,8 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
[]( ExtensionData const & extension ) { return extension.deprecatedBy; } ) },
|
||||
{ "deprecatedTest", generateExtensionReplacedTest( []( ExtensionData const & extension ) { return extension.isDeprecated; } ) },
|
||||
{ "extensionDependencies", generateExtensionDependencies() },
|
||||
{ "getExtensionDependsByVersionDeclaration", generateExtensionDependsByVersion( false ) },
|
||||
{ "getExtensionDependsByVersionDefinition", generateExtensionDependsByVersion( true ) },
|
||||
{ "instanceExtensions", generateExtensionsList( "instance" ) },
|
||||
{ "instanceTest", generateExtensionTypeTest( "instance" ) },
|
||||
{ "licenseHeader", m_vulkanLicenseHeader },
|
||||
@ -5676,7 +5681,7 @@ std::string VulkanHppGenerator::generateEnumValueName( std::string const & enumN
|
||||
std::string VulkanHppGenerator::generateExtensionDependencies() const
|
||||
{
|
||||
std::string extensionDependencies, previousEnter, previousLeave;
|
||||
for (auto const& extension : m_extensions)
|
||||
for ( auto const & extension : m_extensions )
|
||||
{
|
||||
if ( !extension.depends.empty() )
|
||||
{
|
||||
@ -5715,6 +5720,60 @@ std::string VulkanHppGenerator::generateExtensionDependencies() const
|
||||
return extensionDependencies;
|
||||
}
|
||||
|
||||
std::string VulkanHppGenerator::generateExtensionDependsByVersion( bool definition ) const
|
||||
{
|
||||
if (m_api != "vulkan")
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
if ( definition )
|
||||
{
|
||||
const std::string generateExtensionDependsTemplate = R"( VULKAN_HPP_INLINE std::pair<bool, std::vector<std::string> const &> getExtensionDepends( std::string const & version, std::string const & extension )
|
||||
{
|
||||
#if !defined( NDEBUG )
|
||||
static std::set<std::string> versions = { ${versions} };
|
||||
assert( versions.find( version ) != versions.end() );
|
||||
#endif
|
||||
static std::vector<std::string> noDependencies;
|
||||
|
||||
std::map<std::string, std::vector<std::string>> const & dependencies = getExtensionDepends( extension );
|
||||
if ( dependencies.empty() )
|
||||
{
|
||||
return { true, noDependencies };
|
||||
}
|
||||
auto depIt = dependencies.lower_bound( version );
|
||||
if ( ( depIt == dependencies.end() ) || ( depIt->first != version ) )
|
||||
{
|
||||
depIt = std::prev( depIt );
|
||||
}
|
||||
if ( depIt == dependencies.end() )
|
||||
{
|
||||
return { false, noDependencies };
|
||||
}
|
||||
else
|
||||
{
|
||||
return { true, depIt->second };
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
std::string versions;
|
||||
for (auto const& feature : m_features)
|
||||
{
|
||||
versions += "\"" + feature.name + "\", ";
|
||||
}
|
||||
assert( versions.ends_with( ", " ) );
|
||||
versions = versions.substr( 0, versions.length() - 2 );
|
||||
|
||||
return replaceWithMap( generateExtensionDependsTemplate, { { "versions", versions } } );
|
||||
}
|
||||
else
|
||||
{
|
||||
return "std::pair<bool, std::vector<std::string> const &> getExtensionDepends( std::string const & version, std::string const & extension );";
|
||||
}
|
||||
}
|
||||
|
||||
template <class Predicate, class Extraction>
|
||||
std::string VulkanHppGenerator::generateExtensionReplacedBy( Predicate p, Extraction e ) const
|
||||
{
|
||||
|
@ -694,6 +694,7 @@ private:
|
||||
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 generateExtensionDependencies() const;
|
||||
std::string generateExtensionDependsByVersion( bool definition ) const;
|
||||
template <class Predicate, class Extraction>
|
||||
std::string generateExtensionReplacedBy( Predicate p, Extraction e ) const;
|
||||
template <class Predicate>
|
||||
|
@ -51,7 +51,22 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
std::map<std::string, std::vector<std::string>> depends = vk::getExtensionDepends( VK_KHR_SWAPCHAIN_EXTENSION_NAME );
|
||||
assert( ( depends.size() == 1 ) && ( depends.begin()->first == "VK_VERSION_1_0" ) && ( depends.begin()->second.size() == 1 ) &&
|
||||
( depends.begin()->second[0] == VK_KHR_DISPLAY_EXTENSION_NAME ) );
|
||||
( depends.begin()->second[0] == VK_KHR_SURFACE_EXTENSION_NAME ) );
|
||||
|
||||
auto [available0, deps0] = vk::getExtensionDepends( "VK_VERSION_1_0", VK_KHR_SURFACE_EXTENSION_NAME );
|
||||
assert( available0 && deps0.empty() );
|
||||
|
||||
auto [available1, deps1] = vk::getExtensionDepends( "VK_VERSION_1_0", VK_KHR_SWAPCHAIN_EXTENSION_NAME );
|
||||
assert( available1 && ( deps1.size() == 1 ) && ( deps1[0] == VK_KHR_SURFACE_EXTENSION_NAME ) );
|
||||
|
||||
auto [available2, deps2] = vk::getExtensionDepends( "VK_VERSION_1_1", VK_KHR_SWAPCHAIN_EXTENSION_NAME );
|
||||
assert( available2 && ( deps2.size() == 1 ) && ( deps2[0] == VK_KHR_SURFACE_EXTENSION_NAME ) );
|
||||
|
||||
auto [available3, deps3] = vk::getExtensionDepends( "VK_VERSION_1_1", VK_EXT_SHADER_TILE_IMAGE_EXTENSION_NAME );
|
||||
assert( !available3 );
|
||||
|
||||
auto [available4, deps4] = vk::getExtensionDepends( "VK_VERSION_1_3", VK_EXT_SHADER_TILE_IMAGE_EXTENSION_NAME );
|
||||
assert( available4 && deps4.empty() );
|
||||
|
||||
std::map<std::string, std::string> const & deprecatedExtensions = vk::getDeprecatedExtensions();
|
||||
auto deprecatedIt = deprecatedExtensions.find( VK_EXT_DEBUG_REPORT_EXTENSION_NAME );
|
||||
|
@ -22,6 +22,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
std::set<std::string> const & getInstanceExtensions();
|
||||
std::map<std::string, std::string> const & getDeprecatedExtensions();
|
||||
std::map<std::string, std::vector<std::string>> const & getExtensionDepends( std::string const & extension );
|
||||
std::pair<bool, std::vector<std::string> const &> getExtensionDepends( std::string const & version, std::string const & extension );
|
||||
std::map<std::string, std::string> const & getObsoletedExtensions();
|
||||
std::map<std::string, std::string> const & getPromotedExtensions();
|
||||
VULKAN_HPP_CONSTEXPR_20 std::string getExtensionDeprecatedBy( std::string const & extension );
|
||||
@ -802,6 +803,34 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
return ( depIt != dependencies.end() ) ? depIt->second : noDependencies;
|
||||
}
|
||||
|
||||
VULKAN_HPP_INLINE std::pair<bool, std::vector<std::string> const &> getExtensionDepends( std::string const & version, std::string const & extension )
|
||||
{
|
||||
#if !defined( NDEBUG )
|
||||
static std::set<std::string> versions = { "VK_VERSION_1_0", "VK_VERSION_1_1", "VK_VERSION_1_2", "VK_VERSION_1_3" };
|
||||
assert( versions.find( version ) != versions.end() );
|
||||
#endif
|
||||
static std::vector<std::string> noDependencies;
|
||||
|
||||
std::map<std::string, std::vector<std::string>> const & dependencies = getExtensionDepends( extension );
|
||||
if ( dependencies.empty() )
|
||||
{
|
||||
return { true, noDependencies };
|
||||
}
|
||||
auto depIt = dependencies.lower_bound( version );
|
||||
if ( ( depIt == dependencies.end() ) || ( depIt->first != version ) )
|
||||
{
|
||||
depIt = std::prev( depIt );
|
||||
}
|
||||
if ( depIt == dependencies.end() )
|
||||
{
|
||||
return { false, noDependencies };
|
||||
}
|
||||
else
|
||||
{
|
||||
return { true, depIt->second };
|
||||
}
|
||||
}
|
||||
|
||||
VULKAN_HPP_INLINE std::map<std::string, std::string> const & getObsoletedExtensions()
|
||||
{
|
||||
static std::map<std::string, std::string> obsoletedExtensions = { { "VK_AMD_negative_viewport_height", "VK_KHR_maintenance1" } };
|
||||
|
@ -22,8 +22,9 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
std::set<std::string> const & getInstanceExtensions();
|
||||
std::map<std::string, std::string> const & getDeprecatedExtensions();
|
||||
std::map<std::string, std::vector<std::string>> const & getExtensionDepends( std::string const & extension );
|
||||
std::map<std::string, std::string> const & getObsoletedExtensions();
|
||||
std::map<std::string, std::string> const & getPromotedExtensions();
|
||||
|
||||
std::map<std::string, std::string> const & getObsoletedExtensions();
|
||||
std::map<std::string, std::string> const & getPromotedExtensions();
|
||||
VULKAN_HPP_CONSTEXPR_20 std::string getExtensionDeprecatedBy( std::string const & extension );
|
||||
VULKAN_HPP_CONSTEXPR_20 std::string getExtensionObsoletedBy( std::string const & extension );
|
||||
VULKAN_HPP_CONSTEXPR_20 std::string getExtensionPromotedTo( std::string const & extension );
|
||||
|
Loading…
Reference in New Issue
Block a user