Merge pull request #833 from asuessenbach/163

Update to VK_HEADER_VERSION 163.
This commit is contained in:
Andreas Süßenbach 2020-12-01 11:46:56 +01:00 committed by GitHub
commit 99d9ef9b7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 65 additions and 23 deletions

@ -1 +1 @@
Subproject commit d2308183f2846a1453ce7ae8c77ea7b5a7424ad2 Subproject commit 6a163aa97f8a3d1c186138bedbfb76ce117be8d1

View File

@ -716,7 +716,7 @@ void warn( bool condition, int line, std::string const & message )
VulkanHppGenerator::VulkanHppGenerator( tinyxml2::XMLDocument const & document ) VulkanHppGenerator::VulkanHppGenerator( tinyxml2::XMLDocument const & document )
{ {
m_handles.insert( std::make_pair( m_handles.insert( std::make_pair(
"", HandleData( {}, 0 ) ) ); // insert the default "handle" without class (for createInstance, and such) "", HandleData( {}, "", 0 ) ) ); // insert the default "handle" without class (for createInstance, and such)
int line = document.GetLineNum(); int line = document.GetLineNum();
std::vector<tinyxml2::XMLElement const *> elements = getChildElements( &document ); std::vector<tinyxml2::XMLElement const *> elements = getChildElements( &document );
@ -2691,7 +2691,7 @@ ${enter} class ${className}
public: public:
using CType = Vk${className}; using CType = Vk${className};
static VULKAN_HPP_CONST_OR_CONSTEXPR VULKAN_HPP_NAMESPACE::ObjectType objectType = VULKAN_HPP_NAMESPACE::ObjectType::e${className}; static VULKAN_HPP_CONST_OR_CONSTEXPR VULKAN_HPP_NAMESPACE::ObjectType objectType = VULKAN_HPP_NAMESPACE::ObjectType::${objTypeEnum};
static VULKAN_HPP_CONST_OR_CONSTEXPR VULKAN_HPP_NAMESPACE::DebugReportObjectTypeEXT debugReportObjectType = VULKAN_HPP_NAMESPACE::DebugReportObjectTypeEXT::${debugReportObjectType}; static VULKAN_HPP_CONST_OR_CONSTEXPR VULKAN_HPP_NAMESPACE::DebugReportObjectTypeEXT debugReportObjectType = VULKAN_HPP_NAMESPACE::DebugReportObjectTypeEXT::${debugReportObjectType};
public: public:
@ -2761,13 +2761,13 @@ ${commands}
static_assert( sizeof( VULKAN_HPP_NAMESPACE::${className} ) == sizeof( Vk${className} ), "handle and wrapper have different size!" ); static_assert( sizeof( VULKAN_HPP_NAMESPACE::${className} ) == sizeof( Vk${className} ), "handle and wrapper have different size!" );
template <> template <>
struct VULKAN_HPP_DEPRECATED("vk::cpp_type is deprecated. Use vk::CppType instead.") cpp_type<ObjectType::e${className}> struct VULKAN_HPP_DEPRECATED("vk::cpp_type is deprecated. Use vk::CppType instead.") cpp_type<ObjectType::${objTypeEnum}>
{ {
using type = VULKAN_HPP_NAMESPACE::${className}; using type = VULKAN_HPP_NAMESPACE::${className};
}; };
template <> template <>
struct CppType<VULKAN_HPP_NAMESPACE::ObjectType, VULKAN_HPP_NAMESPACE::ObjectType::e${className}> struct CppType<VULKAN_HPP_NAMESPACE::ObjectType, VULKAN_HPP_NAMESPACE::ObjectType::${objTypeEnum}>
{ {
using Type = VULKAN_HPP_NAMESPACE::${className}; using Type = VULKAN_HPP_NAMESPACE::${className};
}; };
@ -2804,13 +2804,31 @@ ${CppTypeFromDebugReportObjectTypeEXT}
std::string enter, leave; std::string enter, leave;
std::tie( enter, leave ) = generateProtection( handleData.first, !handleData.second.alias.empty() ); std::tie( enter, leave ) = generateProtection( handleData.first, !handleData.second.alias.empty() );
std::string objTypeEnum;
if ( handleData.second.objTypeEnum.empty() )
{
objTypeEnum = "e" + stripPrefix( handleData.first, "Vk" );
}
else
{
enumIt = m_enums.find( "VkObjectType" );
assert( enumIt != m_enums.end() );
valueIt = std::find_if(
enumIt->second.values.begin(), enumIt->second.values.end(), [&handleData]( EnumValueData const & evd ) {
return evd.vulkanValue == handleData.second.objTypeEnum;
} );
assert( valueIt != enumIt->second.values.end() );
objTypeEnum = valueIt->vkValue;
}
str += replaceWithMap( templateString, str += replaceWithMap( templateString,
{ { "className", className }, { { "className", className },
{ "commands", commands }, { "commands", commands },
{ "CppTypeFromDebugReportObjectTypeEXT", cppTypeFromDebugReportObjectTypeEXT }, { "CppTypeFromDebugReportObjectTypeEXT", cppTypeFromDebugReportObjectTypeEXT },
{ "debugReportObjectType", debugReportObjectType }, { "debugReportObjectType", debugReportObjectType },
{ "enter", enter }, { "enter", enter },
{ "memberName", startLowerCase( stripPrefix( handleData.first, "Vk" ) ) } } ); { "memberName", startLowerCase( stripPrefix( handleData.first, "Vk" ) ) },
{ "objTypeEnum", valueIt->vkValue } } );
if ( !handleData.second.alias.empty() ) if ( !handleData.second.alias.empty() )
{ {
@ -6573,23 +6591,39 @@ void VulkanHppGenerator::checkCorrectness()
if ( !handle.first.empty() ) if ( !handle.first.empty() )
{ {
std::string objectType = "e" + stripPrefix( handle.first, "Vk" ); if ( handle.second.objTypeEnum.empty() )
auto valueIt = std::find_if( objectTypeIt->second.values.begin(), {
objectTypeIt->second.values.end(), std::string objectType = "e" + stripPrefix( handle.first, "Vk" );
[&objectType]( EnumValueData const & evd ) { return evd.vkValue == objectType; } ); auto valueIt = std::find_if( objectTypeIt->second.values.begin(),
check( valueIt != objectTypeIt->second.values.end(), objectTypeIt->second.values.end(),
handle.second.xmlLine, [&objectType]( EnumValueData const & evd ) { return evd.vkValue == objectType; } );
"handle <" + handle.first + "> specified without corresponding VkObjectType enum value" ); check( valueIt != objectTypeIt->second.values.end(),
handle.second.xmlLine,
"handle <" + handle.first + "> specified without corresponding VkObjectType enum value" );
}
else
{
check( std::find_if( objectTypeIt->second.values.begin(),
objectTypeIt->second.values.end(),
[&handle]( EnumValueData const & evd ) {
return evd.vulkanValue == handle.second.objTypeEnum;
} ) != objectTypeIt->second.values.end(),
handle.second.xmlLine,
"handle <" + handle.first + "> specifies unknown \"objtypeenum\" <" + handle.second.objTypeEnum + ">" );
}
} }
} }
for ( auto const & objectTypeValue : objectTypeIt->second.values ) for ( auto const & objectTypeValue : objectTypeIt->second.values )
{ {
if ( objectTypeValue.vkValue != "eUnknown" ) if ( objectTypeValue.vkValue != "eUnknown" )
{ {
std::string handleName = "Vk" + stripPrefix( objectTypeValue.vkValue, "e" ); warn( std::find_if( m_handles.begin(),
check( m_handles.find( handleName ) != m_handles.end(), m_handles.end(),
[&objectTypeValue]( std::pair<std::string, HandleData> const & hd ) {
return hd.second.objTypeEnum == objectTypeValue.vulkanValue;
} ) != m_handles.end(),
objectTypeValue.xmlLine, objectTypeValue.xmlLine,
"VkObjectType value <" + objectTypeValue.vulkanValue + "> without corresponding handle" ); "VkObjectType value <" + objectTypeValue.vulkanValue + "> not specified as \"objtypeenum\" for any handle" );
} }
} }
@ -8462,15 +8496,18 @@ void VulkanHppGenerator::readHandle( tinyxml2::XMLElement const *
} }
else else
{ {
checkAttributes( line, attributes, { { "category", { "handle" } } }, { { "parent", {} } } ); checkAttributes( line, attributes, { { "category", { "handle" } } }, { { "objtypeenum", {} }, { "parent", {} } } );
std::string parent; std::string objTypeEnum, parent;
for ( auto const & attribute : attributes ) for ( auto const & attribute : attributes )
{ {
if ( attribute.first == "parent" ) if ( attribute.first == "objtypeenum" )
{
objTypeEnum = attribute.second;
}
else if ( attribute.first == "parent" )
{ {
parent = attribute.second; parent = attribute.second;
check( !parent.empty(), line, "handle with empty parent" );
} }
} }
@ -8488,8 +8525,10 @@ void VulkanHppGenerator::readHandle( tinyxml2::XMLElement const *
"handle with invalid type <" + typeInfo.type + ">" ); "handle with invalid type <" + typeInfo.type + ">" );
check( typeInfo.prefix.empty(), line, "unexpected type prefix <" + typeInfo.prefix + ">" ); check( typeInfo.prefix.empty(), line, "unexpected type prefix <" + typeInfo.prefix + ">" );
check( typeInfo.postfix == "(", line, "unexpected type postfix <" + typeInfo.postfix + ">" ); check( typeInfo.postfix == "(", line, "unexpected type postfix <" + typeInfo.postfix + ">" );
warn( !objTypeEnum.empty(), line, "handle <" + nameData.name + "> does not specify attribute \"objtypeenum\"" );
check( m_handles.insert( std::make_pair( nameData.name, HandleData( tokenize( parent, "," ), line ) ) ).second, check( m_handles.insert( std::make_pair( nameData.name, HandleData( tokenize( parent, "," ), objTypeEnum, line ) ) )
.second,
line, line,
"handle <" + nameData.name + "> already specified" ); "handle <" + nameData.name + "> already specified" );
check( m_types.insert( std::make_pair( nameData.name, TypeCategory::Handle ) ).second, check( m_types.insert( std::make_pair( nameData.name, TypeCategory::Handle ) ).second,

View File

@ -198,13 +198,16 @@ private:
struct HandleData struct HandleData
{ {
HandleData( std::vector<std::string> const & p, int line ) : parents( p ), xmlLine( line ) {} HandleData( std::vector<std::string> const & p, std::string const & objType, int line )
: objTypeEnum( objType ), parents( p ), xmlLine( line )
{}
std::string alias; std::string alias;
std::set<std::string> childrenHandles; std::set<std::string> childrenHandles;
std::set<std::string> commands; std::set<std::string> commands;
std::string deleteCommand; std::string deleteCommand;
std::string deletePool; std::string deletePool;
std::string objTypeEnum;
std::vector<std::string> parents; std::vector<std::string> parents;
int xmlLine; int xmlLine;
}; };

View File

@ -93,7 +93,7 @@ extern "C" __declspec( dllimport ) FARPROC __stdcall GetProcAddress( HINSTANCE h
# include <compare> # include <compare>
#endif #endif
static_assert( VK_HEADER_VERSION == 162, "Wrong VK_HEADER_VERSION!" ); static_assert( VK_HEADER_VERSION == 163, "Wrong VK_HEADER_VERSION!" );
// 32-bit vulkan is not typesafe for handles, so don't allow copy constructors on this platform by default. // 32-bit vulkan is not typesafe for handles, so don't allow copy constructors on this platform by default.
// To enable this feature on 32-bit platforms please define VULKAN_HPP_TYPESAFE_CONVERSION // To enable this feature on 32-bit platforms please define VULKAN_HPP_TYPESAFE_CONVERSION