mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Generate only the standard version for commands that would require vector-operations inside a struct. (#1970)
Some checks failed
Set Version Tag / set-version-tag (push) Has been cancelled
Some checks failed
Set Version Tag / set-version-tag (push) Has been cancelled
This commit is contained in:
parent
00dac1bd21
commit
56fdc0b070
@ -1863,10 +1863,19 @@ bool VulkanHppGenerator::containsUnion( std::string const & type ) const
|
|||||||
|
|
||||||
bool VulkanHppGenerator::describesVector( StructureData const & structure, std::string const & type ) const
|
bool VulkanHppGenerator::describesVector( StructureData const & structure, std::string const & type ) const
|
||||||
{
|
{
|
||||||
return ( structure.members.size() == 4 ) && ( structure.members[0].name == "sType" ) && ( structure.members[1].name == "pNext" ) &&
|
for ( auto const & member : structure.members )
|
||||||
structure.members[2].type.isValue() && ( ( structure.members[2].type.type == "size_t" ) || ( structure.members[2].type.type == "uint32_t" ) ) &&
|
{
|
||||||
( type.empty() ? true : ( structure.members[3].type.type == type ) ) && structure.members[3].type.isNonConstPointer() &&
|
if ( ( type.empty() ? true : ( member.type.type == type ) ) && member.type.isNonConstPointer() && ( member.lenMembers.size() == 1 ) )
|
||||||
( structure.members[3].lenMembers.size() == 1 ) && ( structure.members[3].lenMembers[0].second == 2 );
|
{
|
||||||
|
assert( member.lenMembers[0].second < structure.members.size() );
|
||||||
|
auto const & lenMember = structure.members[member.lenMembers[0].second];
|
||||||
|
if ( lenMember.type.isValue() && ( ( lenMember.type.type == "size_t" ) || ( lenMember.type.type == "uint32_t" ) ) )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<size_t> VulkanHppGenerator::determineChainedReturnParams( std::vector<ParamData> const & params, std::vector<size_t> const & returnParams ) const
|
std::vector<size_t> VulkanHppGenerator::determineChainedReturnParams( std::vector<ParamData> const & params, std::vector<size_t> const & returnParams ) const
|
||||||
@ -2708,7 +2717,8 @@ std::string VulkanHppGenerator::generateArgumentListEnhanced( std::vector<ParamD
|
|||||||
return generateList( arguments, "", ", " );
|
return generateList( arguments, "", ", " );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string VulkanHppGenerator::generateArgumentListStandard( std::vector<ParamData> const & params, std::set<size_t> const & skippedParams ) const
|
std::string
|
||||||
|
VulkanHppGenerator::generateArgumentListStandard( std::vector<ParamData> const & params, std::set<size_t> const & skippedParams, bool withDispatcher ) const
|
||||||
{
|
{
|
||||||
std::string argumentList;
|
std::string argumentList;
|
||||||
for ( size_t i = 0; i < params.size(); ++i )
|
for ( size_t i = 0; i < params.size(); ++i )
|
||||||
@ -2718,7 +2728,15 @@ std::string VulkanHppGenerator::generateArgumentListStandard( std::vector<ParamD
|
|||||||
argumentList += params[i].type.compose( "VULKAN_HPP_NAMESPACE" ) + " " + params[i].name + generateCArraySizes( params[i].arraySizes ) + ", ";
|
argumentList += params[i].type.compose( "VULKAN_HPP_NAMESPACE" ) + " " + params[i].name + generateCArraySizes( params[i].arraySizes ) + ", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( withDispatcher )
|
||||||
|
{
|
||||||
argumentList += "Dispatch const & d ";
|
argumentList += "Dispatch const & d ";
|
||||||
|
}
|
||||||
|
else if ( !argumentList.empty() )
|
||||||
|
{
|
||||||
|
assert( argumentList.ends_with( ", " ) );
|
||||||
|
argumentList = stripPostfix( argumentList, ", " ) + " ";
|
||||||
|
}
|
||||||
return argumentList;
|
return argumentList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3015,18 +3033,19 @@ std::string VulkanHppGenerator::generateCallArgumentsEnhanced( CommandData const
|
|||||||
return generateList( arguments, "", ", " );
|
return generateList( arguments, "", ", " );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string VulkanHppGenerator::generateCallArgumentsStandard( std::string const & handle, std::vector<ParamData> const & params ) const
|
std::string VulkanHppGenerator::generateCallArgumentsStandard( std::vector<ParamData> const & params, size_t initialSkipCount ) const
|
||||||
{
|
{
|
||||||
std::vector<std::string> arguments;
|
std::vector<std::string> arguments;
|
||||||
for ( auto const & param : params )
|
for ( size_t i = 0; i < initialSkipCount; ++i )
|
||||||
{
|
|
||||||
if ( arguments.empty() && ( param.type.type == handle ) && param.type.isValue() )
|
|
||||||
{
|
{
|
||||||
|
auto const & param = params[i];
|
||||||
|
assert( isHandleType( param.type.type ) && param.type.isValue() );
|
||||||
assert( param.arraySizes.empty() && param.lenExpression.empty() );
|
assert( param.arraySizes.empty() && param.lenExpression.empty() );
|
||||||
arguments.push_back( "m_" + startLowerCase( stripPrefix( param.type.type, "Vk" ) ) );
|
arguments.push_back( "static_cast<" + param.type.type + ">( m_" + startLowerCase( stripPrefix( param.type.type, "Vk" ) ) + " )" );
|
||||||
}
|
}
|
||||||
else
|
for ( size_t i = initialSkipCount; i < params.size(); ++i )
|
||||||
{
|
{
|
||||||
|
auto const & param = params[i];
|
||||||
std::string argument = param.name;
|
std::string argument = param.name;
|
||||||
if ( param.type.type.starts_with( "Vk" ) )
|
if ( param.type.type.starts_with( "Vk" ) )
|
||||||
{
|
{
|
||||||
@ -3049,7 +3068,6 @@ std::string VulkanHppGenerator::generateCallArgumentsStandard( std::string const
|
|||||||
}
|
}
|
||||||
arguments.push_back( argument );
|
arguments.push_back( argument );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return generateList( arguments, "", ", " );
|
return generateList( arguments, "", ", " );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4075,6 +4093,11 @@ std::string VulkanHppGenerator::generateCommandResultMultiSuccessWithErrors1Retu
|
|||||||
{ CommandFlavourFlagBits::enhanced } );
|
{ CommandFlavourFlagBits::enhanced } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( isVectorByStructure( commandData.params[returnParam].type.type ) )
|
||||||
|
{
|
||||||
|
// vector by structure is too complex to be supported! Just generate the standard version
|
||||||
|
return generateCommandSetInclusive( name, commandData, initialSkipCount, definition, { returnParam }, {}, false, {}, raii, false, {} );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::map<size_t, VectorParamData> vectorParams = determineVectorParams( commandData.params );
|
std::map<size_t, VectorParamData> vectorParams = determineVectorParams( commandData.params );
|
||||||
@ -4829,15 +4852,26 @@ std::string VulkanHppGenerator::generateCommandSetInclusive( std::string const &
|
|||||||
if ( raii )
|
if ( raii )
|
||||||
{
|
{
|
||||||
std::string raiiCommands;
|
std::string raiiCommands;
|
||||||
|
if ( raiiFlags.empty() )
|
||||||
|
{
|
||||||
|
// Functions without enhancements need to have a standard implementation
|
||||||
|
raiiCommands = generateRAIIHandleCommandStandard( name, commandData, initialSkipCount, definition );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for ( auto flag : raiiFlags )
|
for ( auto flag : raiiFlags )
|
||||||
{
|
{
|
||||||
const bool noReturn = flag & CommandFlavourFlagBits::noReturn;
|
const bool noReturn = flag & CommandFlavourFlagBits::noReturn;
|
||||||
assert( !noReturn || !raiiFactory ); // noReturn => !raiiFactory
|
assert( !noReturn || !raiiFactory ); // noReturn => !raiiFactory
|
||||||
raiiCommands +=
|
raiiCommands += raiiFactory ? generateRAIIHandleCommandFactory( name, commandData, initialSkipCount, returnParams, vectorParams, definition, flag )
|
||||||
raiiFactory
|
: generateRAIIHandleCommandEnhanced( name,
|
||||||
? generateRAIIHandleCommandFactory( name, commandData, initialSkipCount, returnParams, vectorParams, definition, flag )
|
commandData,
|
||||||
: generateRAIIHandleCommandEnhanced(
|
initialSkipCount,
|
||||||
name, commandData, initialSkipCount, noReturn ? emptyReturnParams : returnParams, noReturn ? emptyVectorParams : vectorParams, definition, flag );
|
noReturn ? emptyReturnParams : returnParams,
|
||||||
|
noReturn ? emptyVectorParams : vectorParams,
|
||||||
|
definition,
|
||||||
|
flag );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return raiiCommands;
|
return raiiCommands;
|
||||||
}
|
}
|
||||||
@ -4865,14 +4899,14 @@ std::string
|
|||||||
{
|
{
|
||||||
std::set<size_t> skippedParams = determineSkippedParams( commandData.params, initialSkipCount, {}, {}, false );
|
std::set<size_t> skippedParams = determineSkippedParams( commandData.params, initialSkipCount, {}, {}, false );
|
||||||
|
|
||||||
std::string argumentList = generateArgumentListStandard( commandData.params, skippedParams );
|
std::string argumentList = generateArgumentListStandard( commandData.params, skippedParams, true );
|
||||||
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount );
|
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount );
|
||||||
std::string nodiscard = ( 1 < commandData.successCodes.size() + commandData.errorCodes.size() ) ? "VULKAN_HPP_NODISCARD " : "";
|
std::string nodiscard = ( 1 < commandData.successCodes.size() + commandData.errorCodes.size() ) ? "VULKAN_HPP_NODISCARD " : "";
|
||||||
std::string returnType = stripPrefix( commandData.returnType, "Vk" );
|
std::string returnType = stripPrefix( commandData.returnType, "Vk" );
|
||||||
|
|
||||||
if ( definition )
|
if ( definition )
|
||||||
{
|
{
|
||||||
std::string functionBody = "d." + name + "( " + generateCallArgumentsStandard( commandData.handle, commandData.params ) + " )";
|
std::string functionBody = "d." + name + "( " + generateCallArgumentsStandard( commandData.params, initialSkipCount ) + " )";
|
||||||
if ( commandData.returnType.starts_with( "Vk" ) )
|
if ( commandData.returnType.starts_with( "Vk" ) )
|
||||||
{
|
{
|
||||||
functionBody = "return static_cast<" + returnType + ">( " + functionBody + " )";
|
functionBody = "return static_cast<" + returnType + ">( " + functionBody + " )";
|
||||||
@ -9313,6 +9347,58 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandFactoryArgumentList( st
|
|||||||
return generateList( arguments, "", ", " );
|
return generateList( arguments, "", ", " );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string VulkanHppGenerator::generateRAIIHandleCommandStandard( std::string const & name,
|
||||||
|
CommandData const & commandData,
|
||||||
|
size_t initialSkipCount,
|
||||||
|
bool definition ) const
|
||||||
|
{
|
||||||
|
std::set<size_t> skippedParams = determineSkippedParams( commandData.params, initialSkipCount, {}, {}, false );
|
||||||
|
std::string argumentList = generateArgumentListStandard( commandData.params, skippedParams, false );
|
||||||
|
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount );
|
||||||
|
std::string nodiscard = ( commandData.returnType != "void" ) ? "VULKAN_HPP_NODISCARD" : "";
|
||||||
|
std::string returnType =
|
||||||
|
commandData.returnType.starts_with( "Vk" ) ? "VULKAN_HPP_NAMESPACE::" + stripPrefix( commandData.returnType, "Vk" ) : commandData.returnType;
|
||||||
|
|
||||||
|
if ( definition )
|
||||||
|
{
|
||||||
|
std::string functionBody = "getDispatcher()->" + name + "( " + generateCallArgumentsStandard( commandData.params, initialSkipCount ) + " )";
|
||||||
|
if ( commandData.returnType.starts_with( "Vk" ) )
|
||||||
|
{
|
||||||
|
functionBody = "return static_cast<" + returnType + ">( " + functionBody + " )";
|
||||||
|
}
|
||||||
|
else if ( commandData.returnType != "void" )
|
||||||
|
{
|
||||||
|
functionBody = "return " + functionBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string const functionTemplate =
|
||||||
|
R"( ${nodiscard} VULKAN_HPP_INLINE ${returnType} ${className}::${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT
|
||||||
|
{
|
||||||
|
${functionPointerCheck}
|
||||||
|
${functionBody};
|
||||||
|
})";
|
||||||
|
|
||||||
|
return replaceWithMap( functionTemplate,
|
||||||
|
{ { "argumentList", argumentList },
|
||||||
|
{ "className", initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "Context" },
|
||||||
|
{ "commandName", commandName },
|
||||||
|
{ "functionBody", functionBody },
|
||||||
|
{ "functionPointerCheck", generateFunctionPointerCheck( name, commandData.requiredBy, true ) },
|
||||||
|
{ "nodiscard", nodiscard },
|
||||||
|
{ "returnType", returnType } } );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string const declarationTemplate =
|
||||||
|
R"(
|
||||||
|
${nodiscard} ${returnType} ${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT;
|
||||||
|
)";
|
||||||
|
|
||||||
|
return replaceWithMap( declarationTemplate,
|
||||||
|
{ { "argumentList", argumentList }, { "commandName", commandName }, { "nodiscard", nodiscard }, { "returnType", returnType } } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<std::string, std::string>
|
std::pair<std::string, std::string>
|
||||||
VulkanHppGenerator::generateRAIIHandleConstructor( std::pair<std::string, HandleData> const & handle,
|
VulkanHppGenerator::generateRAIIHandleConstructor( std::pair<std::string, HandleData> const & handle,
|
||||||
std::map<std::string, VulkanHppGenerator::CommandData>::const_iterator constructorIt,
|
std::map<std::string, VulkanHppGenerator::CommandData>::const_iterator constructorIt,
|
||||||
@ -13261,6 +13347,12 @@ bool VulkanHppGenerator::isUnsupportedFeature( std::string const & name ) const
|
|||||||
return std::any_of( m_unsupportedFeatures.begin(), m_unsupportedFeatures.end(), [&name]( auto const & ed ) { return ed.name == name; } );
|
return std::any_of( m_unsupportedFeatures.begin(), m_unsupportedFeatures.end(), [&name]( auto const & ed ) { return ed.name == name; } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VulkanHppGenerator::isVectorByStructure( std::string const & type ) const
|
||||||
|
{
|
||||||
|
auto structIt = m_structs.find( type );
|
||||||
|
return ( structIt != m_structs.end() ) && describesVector( structIt->second );
|
||||||
|
}
|
||||||
|
|
||||||
void VulkanHppGenerator::markExtendedStructs()
|
void VulkanHppGenerator::markExtendedStructs()
|
||||||
{
|
{
|
||||||
for ( auto const & s : m_structs )
|
for ( auto const & s : m_structs )
|
||||||
|
@ -591,7 +591,7 @@ private:
|
|||||||
bool definition,
|
bool definition,
|
||||||
CommandFlavourFlags flavourFlags,
|
CommandFlavourFlags flavourFlags,
|
||||||
bool withDispatcher ) const;
|
bool withDispatcher ) const;
|
||||||
std::string generateArgumentListStandard( std::vector<ParamData> const & params, std::set<size_t> const & skippedParams ) const;
|
std::string generateArgumentListStandard( std::vector<ParamData> const & params, std::set<size_t> const & skippedParams, bool withDispatcher ) const;
|
||||||
std::string generateArgumentTemplates( std::vector<ParamData> const & params,
|
std::string generateArgumentTemplates( std::vector<ParamData> const & params,
|
||||||
std::vector<size_t> const & returnParams,
|
std::vector<size_t> const & returnParams,
|
||||||
std::map<size_t, VectorParamData> const & vectorParams,
|
std::map<size_t, VectorParamData> const & vectorParams,
|
||||||
@ -611,7 +611,7 @@ private:
|
|||||||
bool raii,
|
bool raii,
|
||||||
bool raiiFactory,
|
bool raiiFactory,
|
||||||
CommandFlavourFlags flavourFlags ) const;
|
CommandFlavourFlags flavourFlags ) const;
|
||||||
std::string generateCallArgumentsStandard( std::string const & handle, std::vector<ParamData> const & params ) const;
|
std::string generateCallArgumentsStandard( std::vector<ParamData> const & params, size_t initialSkipCount ) const;
|
||||||
std::string generateCallArgumentEnhanced( std::vector<ParamData> const & params,
|
std::string generateCallArgumentEnhanced( std::vector<ParamData> const & params,
|
||||||
size_t paramIndex,
|
size_t paramIndex,
|
||||||
bool nonConstPointerAsNullptr,
|
bool nonConstPointerAsNullptr,
|
||||||
@ -896,6 +896,7 @@ private:
|
|||||||
std::set<size_t> const & skippedParams,
|
std::set<size_t> const & skippedParams,
|
||||||
bool definition,
|
bool definition,
|
||||||
bool singular ) const;
|
bool singular ) const;
|
||||||
|
std::string generateRAIIHandleCommandStandard( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition ) const;
|
||||||
std::pair<std::string, std::string> generateRAIIHandleConstructor( std::pair<std::string, HandleData> const & handle,
|
std::pair<std::string, std::string> generateRAIIHandleConstructor( std::pair<std::string, HandleData> const & handle,
|
||||||
std::map<std::string, CommandData>::const_iterator constructorIt,
|
std::map<std::string, CommandData>::const_iterator constructorIt,
|
||||||
std::string const & enter,
|
std::string const & enter,
|
||||||
@ -1059,6 +1060,7 @@ private:
|
|||||||
bool isTypeUsed( std::string const & type ) const;
|
bool isTypeUsed( std::string const & type ) const;
|
||||||
bool isUnsupportedExtension( std::string const & name ) const;
|
bool isUnsupportedExtension( std::string const & name ) const;
|
||||||
bool isUnsupportedFeature( std::string const & name ) const;
|
bool isUnsupportedFeature( std::string const & name ) const;
|
||||||
|
bool isVectorByStructure( std::string const & type ) const;
|
||||||
void markExtendedStructs();
|
void markExtendedStructs();
|
||||||
bool needsStructureChainResize( std::map<size_t, VectorParamData> const & vectorParams, std::vector<size_t> const & chainedReturnParams ) const;
|
bool needsStructureChainResize( std::map<size_t, VectorParamData> const & vectorParams, std::vector<size_t> const & chainedReturnParams ) const;
|
||||||
std::pair<bool, std::map<size_t, std::vector<size_t>>> needsVectorSizeCheck( std::vector<ParamData> const & params,
|
std::pair<bool, std::map<size_t, std::vector<size_t>>> needsVectorSizeCheck( std::vector<ParamData> const & params,
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -21566,8 +21566,9 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
|
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
|
||||||
{
|
{
|
||||||
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
|
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
|
||||||
return static_cast<Result>( d.vkGetDeviceFaultInfoEXT(
|
return static_cast<Result>( d.vkGetDeviceFaultInfoEXT( static_cast<VkDevice>( m_device ),
|
||||||
m_device, reinterpret_cast<VkDeviceFaultCountsEXT *>( pFaultCounts ), reinterpret_cast<VkDeviceFaultInfoEXT *>( pFaultInfo ) ) );
|
reinterpret_cast<VkDeviceFaultCountsEXT *>( pFaultCounts ),
|
||||||
|
reinterpret_cast<VkDeviceFaultInfoEXT *>( pFaultInfo ) ) );
|
||||||
}
|
}
|
||||||
# if defined( VK_USE_PLATFORM_WIN32_KHR )
|
# if defined( VK_USE_PLATFORM_WIN32_KHR )
|
||||||
//=== VK_NV_acquire_winrt_display ===
|
//=== VK_NV_acquire_winrt_display ===
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user