refactor command generation of two-vector getting functions returning void

This commit is contained in:
asuessenbach 2020-09-22 18:20:08 +02:00
parent 2fe1356b5a
commit 4d21e2b210
3 changed files with 308 additions and 112 deletions

View File

@ -1293,17 +1293,27 @@ void VulkanHppGenerator::appendCommand( std::string & str,
{ {
// two vector parameters // two vector parameters
auto firstVectorParam = vectorParamIndices.begin(); auto firstVectorParam = vectorParamIndices.begin();
auto secondVectorParam = firstVectorParam++; auto secondVectorParam = std::next( firstVectorParam );
std::vector<ParamData> const & params = commandData.params; std::vector<ParamData> const & params = commandData.params;
if ( ( firstVectorParam->second == secondVectorParam->second ) && if ( ( firstVectorParam->second != INVALID_INDEX ) && ( firstVectorParam->second == secondVectorParam->second ) )
params[firstVectorParam->first].type.isNonConstPointer() &&
params[secondVectorParam->first].type.isNonConstPointer() &&
params[firstVectorParam->second].type.isNonConstPointer() )
{ {
// both vectors are non-const pointer (that is, return parameters), and share the same size parameter, which in // the two vectors use the very same size parameter
// turn is a non-const pointer if ( params[firstVectorParam->first].type.isNonConstPointer() &&
appendCommandEnumerateTwoVectors( str, name, commandData, vectorParamIndices, definition ); params[secondVectorParam->first].type.isNonConstPointer() &&
appendedFunction = true; params[firstVectorParam->second].type.isNonConstPointer() )
{
// both vectors, as well as the size parameter are non-const pointer that is output parameters
appendCommandEnumerateTwoVectors( str, name, commandData, vectorParamIndices, definition );
appendedFunction = true;
}
else if ( params[firstVectorParam->first].type.isConstPointer() &&
params[secondVectorParam->first].type.isConstPointer() &&
params[firstVectorParam->second].type.isValue() && ( commandData.returnType == "void" ) )
{
// size is given by value and the vectors are const pointers, that is input parameters; function returns void
appendCommandTwoVectorsVoid( str, name, commandData, vectorParamIndices, definition );
appendedFunction = true;
}
} }
} }
break; break;
@ -1628,8 +1638,7 @@ ${enter}${commandStandard}${newlineOnDefinition}
${commandEnhanced}${newlineOnDefinition} ${commandEnhanced}${newlineOnDefinition}
${commandEnhancedSingular} ${commandEnhancedSingular}
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
${leave} ${leave})";
)";
std::string enter, leave; std::string enter, leave;
std::tie( enter, leave ) = generateProtection( commandData.feature, commandData.extensions ); std::tie( enter, leave ) = generateProtection( commandData.feature, commandData.extensions );
@ -1658,8 +1667,7 @@ ${enter}${commandStandard}${newlineOnDefinition}
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
${commandEnhanced} ${commandEnhanced}
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
${leave} ${leave})";
)";
std::string enter, leave; std::string enter, leave;
std::tie( enter, leave ) = generateProtection( commandData.feature, commandData.extensions ); std::tie( enter, leave ) = generateProtection( commandData.feature, commandData.extensions );
@ -1683,8 +1691,7 @@ ${enter}${commandStandard}${newlineOnDefinition}
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
${commandEnhanced} ${commandEnhanced}
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
${leave} ${leave})";
)";
std::string enter, leave; std::string enter, leave;
std::tie( enter, leave ) = generateProtection( commandData.feature, commandData.extensions ); std::tie( enter, leave ) = generateProtection( commandData.feature, commandData.extensions );
@ -1717,6 +1724,36 @@ ${commandStandard}
} ) ); } ) );
} }
void VulkanHppGenerator::appendCommandTwoVectorsVoid( std::string & str,
std::string const & name,
CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices,
bool definition ) const
{
assert( commandData.returnType == "void" );
assert( vectorParamIndices.size() == 2 );
std::string enter, leave;
std::tie( enter, leave ) = generateProtection( commandData.feature, commandData.extensions );
const std::string functionTemplate = R"(
${enter}${commandStandard}${newlineOnDefinition}
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
${commandEnhanced}
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
${leave})";
str +=
replaceWithMap( functionTemplate,
std::map<std::string, std::string>(
{ { "commandEnhanced",
constructCommandTwoVectorsVoid( name, commandData, vectorParamIndices, definition, false ) },
{ "commandStandard", constructCommandStandard( name, commandData, definition ) },
{ "enter", enter },
{ "leave", leave },
{ "newlineOnDefinition", definition ? "\n" : "" } } ) );
}
void VulkanHppGenerator::appendDispatchLoaderDynamic( std::string & str ) void VulkanHppGenerator::appendDispatchLoaderDynamic( std::string & str )
{ {
str += R"( str += R"(
@ -3693,7 +3730,15 @@ std::string VulkanHppGenerator::constructArgumentListEnhanced( std::vector<Param
{ {
if ( params[i].type.isConstPointer() ) if ( params[i].type.isConstPointer() )
{ {
if ( params[i].optional ) if ( !params[i].len.empty() )
{
std::string type = params[i].type.compose();
assert( endsWith( type, "*" ) );
type.pop_back();
argumentList += "ArrayProxy<" + type + "> const & " + startLowerCase( stripPrefix( params[i].name, "p" ) );
}
else if ( params[i].optional )
{ {
assert( params[i].type.isConstPointer() ); assert( params[i].type.isConstPointer() );
argumentList += "Optional<const " + stripPrefix( params[i].type.type, "Vk" ) + "> " + argumentList += "Optional<const " + stripPrefix( params[i].type.type, "Vk" ) + "> " +
@ -3748,13 +3793,47 @@ std::string VulkanHppGenerator::constructArgumentListStandard( std::vector<Param
return argumentList; return argumentList;
} }
std::string VulkanHppGenerator::constructCallArguments( std::vector<ParamData> const & params, std::string VulkanHppGenerator::constructCallArgument( ParamData const & param, bool enhanced ) const
std::map<size_t, size_t> const & vectorParamIndices,
bool vectorAsNullptr,
bool enhanced,
bool singular ) const
{ {
size_t countIndex = vectorParamIndices.empty() ? ~0 : vectorParamIndices.begin()->second; std::string argument = param.name;
if ( beginsWith( param.type.type, "Vk" ) )
{
if ( param.type.isValue() )
{
argument = "static_cast<" + param.type.type + ">( " + argument + " )";
}
else
{
assert( !param.type.postfix.empty() );
if ( enhanced )
{
argument = "&" + startLowerCase( stripPrefix( argument, "p" ) );
}
argument = "reinterpret_cast<" + ( param.type.prefix.empty() ? "" : param.type.prefix ) + " " + param.type.type +
" " + param.type.postfix + ">( " + argument + " )";
}
}
return argument;
}
std::string VulkanHppGenerator::constructCallArguments( std::vector<ParamData> const & params, bool enhanced ) const
{
std::string arguments = "m_" + startLowerCase( stripPrefix( params[0].type.type, "Vk" ) );
for ( size_t i = 1; i < params.size(); i++ )
{
arguments += ", " + constructCallArgument( params[i], enhanced );
}
return arguments;
}
std::string
VulkanHppGenerator::constructCallArgumentsEnumerateVectors( std::vector<ParamData> const & params,
std::map<size_t, size_t> const & vectorParamIndices,
bool vectorAsNullptr ) const
{
assert( vectorParamIndices.size() == 2 );
size_t countIndex = vectorParamIndices.begin()->second;
assert( ( vectorParamIndices.size() != 2 ) || ( std::next( vectorParamIndices.begin() )->second == countIndex ) ); assert( ( vectorParamIndices.size() != 2 ) || ( std::next( vectorParamIndices.begin() )->second == countIndex ) );
std::string arguments = "m_" + startLowerCase( stripPrefix( params[0].type.type, "Vk" ) ); std::string arguments = "m_" + startLowerCase( stripPrefix( params[0].type.type, "Vk" ) );
@ -3763,67 +3842,87 @@ std::string VulkanHppGenerator::constructCallArguments( std::vector<ParamData> c
arguments += ", "; arguments += ", ";
if ( i == countIndex ) if ( i == countIndex )
{ {
if ( singular ) assert( !params[i].type.isValue() );
arguments += "&" + startLowerCase( stripPrefix( params[i].name, "p" ) );
}
else if ( vectorParamIndices.find( i ) != vectorParamIndices.end() )
{
if ( vectorAsNullptr )
{ {
arguments += "sizeof( T )"; arguments += "nullptr";
}
else if ( params[i].type.isValue() )
{
arguments += params[i].name;
} }
else else
{ {
arguments += "&" + startLowerCase( stripPrefix( params[i].name, "p" ) ); arguments += "reinterpret_cast<" + params[i].type.type + " *>( enumeratedData." +
( ( vectorParamIndices.find( i ) == vectorParamIndices.begin() ) ? "first" : "second" ) +
".data() )";
} }
} }
else if ( vectorParamIndices.find( i ) != vectorParamIndices.end() ) else
{
arguments += constructCallArgument( params[i], true );
}
}
return arguments;
}
std::string VulkanHppGenerator::constructCallArgumentsGetVector( std::vector<ParamData> const & params,
std::pair<size_t, size_t> const & vectorParamIndices,
bool singular ) const
{
std::string arguments = "m_" + startLowerCase( stripPrefix( params[0].type.type, "Vk" ) );
for ( size_t i = 1; i < params.size(); i++ )
{
arguments += ", ";
if ( i == vectorParamIndices.first )
{ {
if ( singular ) if ( singular )
{ {
arguments += "reinterpret_cast<" + params[i].type.type + " *>( &" + arguments += "reinterpret_cast<" + params[i].type.type + " *>( &" +
startLowerCase( stripPrefix( params[i].name, "p" ) ) + " )"; startLowerCase( stripPrefix( params[i].name, "p" ) ) + " )";
} }
else if ( vectorAsNullptr )
{
arguments += "nullptr";
}
else else
{ {
switch ( vectorParamIndices.size() ) arguments += "reinterpret_cast<" + params[i].type.type + " *>( " +
{ startLowerCase( stripPrefix( params[i].name, "p" ) ) + ".data() )";
case 1:
arguments += "reinterpret_cast<" + params[i].type.type + " *>( " +
startLowerCase( stripPrefix( params[i].name, "p" ) ) + ".data() )";
break;
case 2:
arguments += "reinterpret_cast<" + params[i].type.type + " *>( enumeratedData." +
( ( vectorParamIndices.find( i ) == vectorParamIndices.begin() ) ? "first" : "second" ) +
".data() )";
break;
default: assert( false );
}
} }
} }
else if ( ( i == vectorParamIndices.second ) && singular )
{
arguments += "sizeof( T )";
}
else else
{ {
std::string arg = params[i].name; arguments += constructCallArgument( params[i], true );
if ( beginsWith( params[i].type.type, "Vk" ) ) }
{ }
if ( params[i].type.isValue() ) return arguments;
{ }
arg = "static_cast<" + params[i].type.type + ">( " + arg + " )";
} std::string
else VulkanHppGenerator::constructCallArgumentsVectors( std::vector<ParamData> const & params,
{ std::map<size_t, size_t> const & vectorParamIndices ) const
if ( enhanced ) {
{ assert( !vectorParamIndices.empty() );
arg = "&" + startLowerCase( stripPrefix( arg, "p" ) ); size_t countIndex = vectorParamIndices.begin()->second;
}
arg = "reinterpret_cast<" + params[i].type.prefix + " " + params[i].type.type + " " + params[i].type.postfix + std::string arguments = "m_" + startLowerCase( stripPrefix( params[0].type.type, "Vk" ) );
">( " + arg + " )"; for ( size_t i = 1; i < params.size(); i++ )
} {
} arguments += ", ";
arguments += "" + arg; if ( i == countIndex )
{
arguments += startLowerCase( stripPrefix( params[vectorParamIndices.begin()->first].name, "p" ) ) + ".size()";
}
else if ( vectorParamIndices.find( i ) != vectorParamIndices.end() )
{
assert( !params[i].type.prefix.empty() && !params[i].type.postfix.empty() );
arguments += "reinterpret_cast<" + params[i].type.prefix + " " + params[i].type.type + " " +
params[i].type.postfix + ">( " + startLowerCase( stripPrefix( params[i].name, "p" ) ) + ".data() )";
}
else
{
arguments += constructCallArgument( params[i], true );
} }
} }
return arguments; return arguments;
@ -3904,14 +4003,15 @@ std::string
{ "counterName", { "counterName",
startLowerCase( stripPrefix( stripPluralS( commandData.params[firstVectorParamIt->second].name ), "p" ) ) }, startLowerCase( stripPrefix( stripPluralS( commandData.params[firstVectorParamIt->second].name ), "p" ) ) },
{ "counterType", commandData.params[firstVectorParamIt->second].type.type }, { "counterType", commandData.params[firstVectorParamIt->second].type.type },
{ "firstCallArguments", constructCallArguments( commandData.params, vectorParamIndices, true, true, false ) }, { "firstCallArguments",
constructCallArgumentsEnumerateVectors( commandData.params, vectorParamIndices, true ) },
{ "nodiscard", nodiscard }, { "nodiscard", nodiscard },
{ "pairConstructor", { "pairConstructor",
withAllocators ? ( "( std::piecewise_construct, std::forward_as_tuple( " + firstVectorName + withAllocators ? ( "( std::piecewise_construct, std::forward_as_tuple( " + firstVectorName +
"Allocator ), std::forward_as_tuple( " + secondVectorName + "Allocator ) )" ) "Allocator ), std::forward_as_tuple( " + secondVectorName + "Allocator ) )" )
: "" }, : "" },
{ "secondCallArguments", { "secondCallArguments",
constructCallArguments( commandData.params, vectorParamIndices, false, true, false ) }, constructCallArgumentsEnumerateVectors( commandData.params, vectorParamIndices, false ) },
{ "templateTypeFirst", templateTypeFirst }, { "templateTypeFirst", templateTypeFirst },
{ "templateTypeSecond", templateTypeSecond }, { "templateTypeSecond", templateTypeSecond },
{ "vkCommand", name }, { "vkCommand", name },
@ -4050,7 +4150,8 @@ std::string VulkanHppGenerator::constructCommandGetVector( std::string const &
functionTemplate, functionTemplate,
std::map<std::string, std::string>( std::map<std::string, std::string>(
{ { "argumentList", argumentList }, { { "argumentList", argumentList },
{ "callArguments", constructCallArguments( commandData.params, vectorParamIndices, false, true, false ) }, { "callArguments",
constructCallArgumentsGetVector( commandData.params, *vectorParamIndices.begin(), false ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) }, { "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName }, { "commandName", commandName },
{ "dataName", startLowerCase( stripPrefix( commandData.params[vectorParamIndex].name, "p" ) ) }, { "dataName", startLowerCase( stripPrefix( commandData.params[vectorParamIndex].name, "p" ) ) },
@ -4170,7 +4271,7 @@ std::string VulkanHppGenerator::constructCommandGetVectorSingular( std::string c
functionTemplate, functionTemplate,
std::map<std::string, std::string>( std::map<std::string, std::string>(
{ { "argumentList", argumentList }, { { "argumentList", argumentList },
{ "callArguments", constructCallArguments( commandData.params, vectorParamIndices, false, true, true ) }, { "callArguments", constructCallArgumentsGetVector( commandData.params, *vectorParamIndices.begin(), true ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) }, { "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName }, { "commandName", commandName },
{ "dataName", startLowerCase( stripPrefix( commandData.params[vectorParamIndex].name, "p" ) ) }, { "dataName", startLowerCase( stripPrefix( commandData.params[vectorParamIndex].name, "p" ) ) },
@ -4216,15 +4317,15 @@ std::string VulkanHppGenerator::constructCommandSimple( std::string const & name
return createResultValue( result, VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}" ); return createResultValue( result, VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}" );
})"; })";
str = replaceWithMap( functionTemplate, str = replaceWithMap(
std::map<std::string, std::string>( functionTemplate,
{ { "argumentList", argumentList }, std::map<std::string, std::string>( { { "argumentList", argumentList },
{ "callArguments", constructCallArguments( commandData.params, {}, false, true, false ) }, { "callArguments", constructCallArguments( commandData.params, true ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) }, { "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName }, { "commandName", commandName },
{ "nodiscard", nodiscard }, { "nodiscard", nodiscard },
{ "returnType", returnType }, { "returnType", returnType },
{ "vkCommand", name } } ) ); { "vkCommand", name } } ) );
} }
else else
{ {
@ -4260,13 +4361,13 @@ std::string VulkanHppGenerator::constructCommandSimpleVoid( std::string const &
d.${vkCommand}( ${callArguments} ); d.${vkCommand}( ${callArguments} );
})"; })";
str = replaceWithMap( functionTemplate, str = replaceWithMap(
std::map<std::string, std::string>( functionTemplate,
{ { "argumentList", argumentList }, std::map<std::string, std::string>( { { "argumentList", argumentList },
{ "callArguments", constructCallArguments( commandData.params, {}, false, true, false ) }, { "callArguments", constructCallArguments( commandData.params, true ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) }, { "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName }, { "commandName", commandName },
{ "vkCommand", name } } ) ); { "vkCommand", name } } ) );
} }
else else
{ {
@ -4291,36 +4392,45 @@ std::string VulkanHppGenerator::constructCommandStandard( std::string const & na
std::string argumentList = constructArgumentListStandard( commandData.params, { 0 } ); std::string argumentList = constructArgumentListStandard( commandData.params, { 0 } );
std::string commandName = determineCommandName( name, commandData.params[0].type.type ); std::string commandName = determineCommandName( name, commandData.params[0].type.type );
std::string nodiscard = constructNoDiscardStandard( commandData ); std::string nodiscard = constructNoDiscardStandard( commandData );
assert( ( commandData.returnType == "void" ) || ( commandData.returnType == "VkResult" ) );
std::string returnType = ( commandData.returnType == "void" ) ? "void" : "Result";
if ( definition ) if ( definition )
{ {
std::string functionBody = "d." + name + "( " + constructCallArguments( commandData.params, false ) + " )";
if ( returnType != "void" )
{
assert( returnType == "Result" );
functionBody = "return static_cast<Result>( " + functionBody + " )";
}
std::string const functionTemplate = std::string const functionTemplate =
R"( template <typename Dispatch> R"( template <typename Dispatch>
${nodiscard}VULKAN_HPP_INLINE Result ${className}::${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT ${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}::${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT
{ {
return static_cast<Result>( d.${vkCommand}( ${callArguments} ) ); ${functionBody};
})"; })";
str = replaceWithMap( functionTemplate, str =
std::map<std::string, std::string>( { replaceWithMap( functionTemplate,
{ "argumentList", argumentList }, std::map<std::string, std::string>( { { "argumentList", argumentList },
{ "callArguments", constructCallArguments( commandData.params, {}, true, false, false ) }, { "className", stripPrefix( commandData.handle, "Vk" ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) }, { "commandName", commandName },
{ "commandName", commandName }, { "functionBody", functionBody },
{ "nodiscard", nodiscard }, { "nodiscard", nodiscard },
{ "vkCommand", name }, { "returnType", returnType } } ) );
} ) );
} }
else else
{ {
std::string const functionTemplate = std::string const functionTemplate =
R"( template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> R"( template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
${nodiscard}Result ${commandName}( ${argumentList} VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;)"; ${nodiscard}${returnType} ${commandName}( ${argumentList} VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;)";
str = replaceWithMap( str = replaceWithMap( functionTemplate,
functionTemplate, std::map<std::string, std::string>( { { "argumentList", argumentList },
std::map<std::string, std::string>( { "commandName", commandName },
{ { "argumentList", argumentList }, { "commandName", commandName }, { "nodiscard", nodiscard } } ) ); { "nodiscard", nodiscard },
{ "returnType", returnType } } ) );
} }
return str; return str;
} }
@ -4346,7 +4456,7 @@ std::string VulkanHppGenerator::constructCommandStandardVoid( std::string const
str = replaceWithMap( functionTemplate, str = replaceWithMap( functionTemplate,
std::map<std::string, std::string>( { std::map<std::string, std::string>( {
{ "argumentList", argumentList }, { "argumentList", argumentList },
{ "callArguments", constructCallArguments( commandData.params, {}, false, false, false ) }, { "callArguments", constructCallArguments( commandData.params, false ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) }, { "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName }, { "commandName", commandName },
{ "vkCommand", name }, { "vkCommand", name },
@ -4365,6 +4475,72 @@ std::string VulkanHppGenerator::constructCommandStandardVoid( std::string const
return str; return str;
} }
std::string VulkanHppGenerator::constructCommandTwoVectorsVoid( std::string const & name,
CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices,
bool definition,
bool withAllocators ) const
{
std::string str;
auto firstVectorParamIt = vectorParamIndices.begin();
auto secondVectorParamIt = std::next( firstVectorParamIt );
assert( commandData.params[0].type.type == commandData.handle );
assert( firstVectorParamIt->second == secondVectorParamIt->second );
std::string argumentList =
constructArgumentListEnhanced( commandData.params, { 0, firstVectorParamIt->second }, definition, withAllocators );
std::string commandName = determineCommandName( name, commandData.params[0].type.type );
if ( definition )
{
const std::string functionTemplate =
R"x( template <typename Dispatch>
VULKAN_HPP_INLINE void ${className}::${commandName}( ${argumentList} ) const
{
# ifdef VULKAN_HPP_NO_EXCEPTIONS
VULKAN_HPP_ASSERT( ${firstVectorName}.size() == ${secondVectorName}.size() );
# else
if ( ${firstVectorName}.size() != ${secondVectorName}.size() )
{
throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}: ${firstVectorName}.size() != ${secondVectorName}.size()" );
}
#endif /*VULKAN_HPP_NO_EXCEPTIONS*/
d.${vkCommand}( ${callArguments} );
})x";
assert( beginsWith( commandData.params[firstVectorParamIt->first].name, "p" ) );
std::string firstVectorName =
startLowerCase( stripPrefix( commandData.params[firstVectorParamIt->first].name, "p" ) );
assert( beginsWith( commandData.params[secondVectorParamIt->first].name, "p" ) );
std::string secondVectorName =
startLowerCase( stripPrefix( commandData.params[secondVectorParamIt->first].name, "p" ) );
str =
replaceWithMap( functionTemplate,
std::map<std::string, std::string>(
{ { "argumentList", argumentList },
{ "callArguments", constructCallArgumentsVectors( commandData.params, vectorParamIndices ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName },
{ "firstVectorName", firstVectorName },
{ "secondVectorName", secondVectorName },
{ "vkCommand", name } } ) );
}
else
{
const std::string functionTemplate =
R"( template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
void ${commandName}( ${argumentList} ) const;)";
str = replaceWithMap(
functionTemplate,
std::map<std::string, std::string>( { { "argumentList", argumentList }, { "commandName", commandName } } ) );
}
return str;
}
std::string std::string
VulkanHppGenerator::constructConstexprString( std::pair<std::string, StructureData> const & structData ) const VulkanHppGenerator::constructConstexprString( std::pair<std::string, StructureData> const & structData ) const
{ {

View File

@ -338,6 +338,11 @@ private:
std::string const & name, std::string const & name,
CommandData const & commandData, CommandData const & commandData,
bool definition ) const; bool definition ) const;
void appendCommandTwoVectorsVoid( std::string & str,
std::string const & name,
CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices,
bool definition ) const;
void appendDispatchLoaderDynamicCommand( std::string & str, void appendDispatchLoaderDynamicCommand( std::string & str,
std::string & emptyFunctions, std::string & emptyFunctions,
std::string & deviceFunctions, std::string & deviceFunctions,
@ -523,11 +528,16 @@ private:
bool withAllocators ) const; bool withAllocators ) const;
std::string constructArgumentListStandard( std::vector<ParamData> const & params, std::string constructArgumentListStandard( std::vector<ParamData> const & params,
std::set<size_t> const & skippedParams ) const; std::set<size_t> const & skippedParams ) const;
std::string constructCallArguments( std::vector<ParamData> const & params, std::string constructCallArgument( ParamData const & param, bool enhanced ) const;
std::map<size_t, size_t> const & vectorParamIndices, std::string constructCallArguments( std::vector<ParamData> const & params, bool enhanced ) const;
bool vectorAsNullptr, std::string constructCallArgumentsEnumerateVectors( std::vector<ParamData> const & params,
bool enhanced, std::map<size_t, size_t> const & vectorParamIndices,
bool singular ) const; bool vectorAsNullptr ) const;
std::string constructCallArgumentsGetVector( std::vector<ParamData> const & params,
std::pair<size_t, size_t> const & vectorParamIndices,
bool singular ) const;
std::string constructCallArgumentsVectors( std::vector<ParamData> const & params,
std::map<size_t, size_t> const & vectorParamIndices ) const;
std::string constructCommandEnumerateTwoVectors( std::string const & name, std::string constructCommandEnumerateTwoVectors( std::string const & name,
CommandData const & commandData, CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
@ -558,6 +568,11 @@ private:
constructCommandStandard( std::string const & name, CommandData const & commandData, bool definition ) const; constructCommandStandard( std::string const & name, CommandData const & commandData, bool definition ) const;
std::string std::string
constructCommandStandardVoid( std::string const & name, CommandData const & commandData, bool definition ) const; constructCommandStandardVoid( std::string const & name, CommandData const & commandData, bool definition ) const;
std::string constructCommandTwoVectorsVoid( std::string const & name,
CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices,
bool definition,
bool withAllocators ) const;
std::string constructConstexprString( std::pair<std::string, StructureData> const & structData ) const; std::string constructConstexprString( std::pair<std::string, StructureData> const & structData ) const;
std::string constructFunctionBodyEnhanced( std::string const & indentation, std::string constructFunctionBodyEnhanced( std::string const & indentation,
std::string const & name, std::string const & name,

View File

@ -87368,6 +87368,7 @@ namespace VULKAN_HPP_NAMESPACE
reinterpret_cast<const VkBuffer *>( pCounterBuffers ), reinterpret_cast<const VkBuffer *>( pCounterBuffers ),
reinterpret_cast<const VkDeviceSize *>( pCounterBufferOffsets ) ); reinterpret_cast<const VkDeviceSize *>( pCounterBufferOffsets ) );
} }
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch> template <typename Dispatch>
VULKAN_HPP_INLINE void CommandBuffer::beginTransformFeedbackEXT( VULKAN_HPP_INLINE void CommandBuffer::beginTransformFeedbackEXT(
@ -87383,7 +87384,7 @@ namespace VULKAN_HPP_NAMESPACE
{ {
throw LogicError( throw LogicError(
VULKAN_HPP_NAMESPACE_STRING VULKAN_HPP_NAMESPACE_STRING
"::VkCommandBuffer::beginTransformFeedbackEXT: counterBuffers.size() != counterBufferOffsets.size()" ); "::CommandBuffer::beginTransformFeedbackEXT: counterBuffers.size() != counterBufferOffsets.size()" );
} }
# endif /*VULKAN_HPP_NO_EXCEPTIONS*/ # endif /*VULKAN_HPP_NO_EXCEPTIONS*/
d.vkCmdBeginTransformFeedbackEXT( m_commandBuffer, d.vkCmdBeginTransformFeedbackEXT( m_commandBuffer,
@ -87551,6 +87552,7 @@ namespace VULKAN_HPP_NAMESPACE
reinterpret_cast<const VkBuffer *>( pBuffers ), reinterpret_cast<const VkBuffer *>( pBuffers ),
reinterpret_cast<const VkDeviceSize *>( pOffsets ) ); reinterpret_cast<const VkDeviceSize *>( pOffsets ) );
} }
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch> template <typename Dispatch>
VULKAN_HPP_INLINE void VULKAN_HPP_INLINE void
@ -87565,7 +87567,7 @@ namespace VULKAN_HPP_NAMESPACE
if ( buffers.size() != offsets.size() ) if ( buffers.size() != offsets.size() )
{ {
throw LogicError( VULKAN_HPP_NAMESPACE_STRING throw LogicError( VULKAN_HPP_NAMESPACE_STRING
"::VkCommandBuffer::bindVertexBuffers: buffers.size() != offsets.size()" ); "::CommandBuffer::bindVertexBuffers: buffers.size() != offsets.size()" );
} }
# endif /*VULKAN_HPP_NO_EXCEPTIONS*/ # endif /*VULKAN_HPP_NO_EXCEPTIONS*/
d.vkCmdBindVertexBuffers( m_commandBuffer, d.vkCmdBindVertexBuffers( m_commandBuffer,
@ -87757,6 +87759,7 @@ namespace VULKAN_HPP_NAMESPACE
reinterpret_cast<const VkAccelerationStructureBuildGeometryInfoKHR *>( pInfos ), reinterpret_cast<const VkAccelerationStructureBuildGeometryInfoKHR *>( pInfos ),
reinterpret_cast<const VkAccelerationStructureBuildOffsetInfoKHR * const *>( ppOffsetInfos ) ); reinterpret_cast<const VkAccelerationStructureBuildOffsetInfoKHR * const *>( ppOffsetInfos ) );
} }
# ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE # ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch> template <typename Dispatch>
VULKAN_HPP_INLINE void CommandBuffer::buildAccelerationStructureKHR( VULKAN_HPP_INLINE void CommandBuffer::buildAccelerationStructureKHR(
@ -87770,7 +87773,7 @@ namespace VULKAN_HPP_NAMESPACE
if ( infos.size() != pOffsetInfos.size() ) if ( infos.size() != pOffsetInfos.size() )
{ {
throw LogicError( VULKAN_HPP_NAMESPACE_STRING throw LogicError( VULKAN_HPP_NAMESPACE_STRING
"::VkCommandBuffer::buildAccelerationStructureKHR: infos.size() != pOffsetInfos.size()" ); "::CommandBuffer::buildAccelerationStructureKHR: infos.size() != pOffsetInfos.size()" );
} }
# endif /*VULKAN_HPP_NO_EXCEPTIONS*/ # endif /*VULKAN_HPP_NO_EXCEPTIONS*/
d.vkCmdBuildAccelerationStructureKHR( d.vkCmdBuildAccelerationStructureKHR(
@ -88523,6 +88526,7 @@ namespace VULKAN_HPP_NAMESPACE
reinterpret_cast<const VkBuffer *>( pCounterBuffers ), reinterpret_cast<const VkBuffer *>( pCounterBuffers ),
reinterpret_cast<const VkDeviceSize *>( pCounterBufferOffsets ) ); reinterpret_cast<const VkDeviceSize *>( pCounterBufferOffsets ) );
} }
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch> template <typename Dispatch>
VULKAN_HPP_INLINE void CommandBuffer::endTransformFeedbackEXT( VULKAN_HPP_INLINE void CommandBuffer::endTransformFeedbackEXT(
@ -88538,7 +88542,7 @@ namespace VULKAN_HPP_NAMESPACE
{ {
throw LogicError( throw LogicError(
VULKAN_HPP_NAMESPACE_STRING VULKAN_HPP_NAMESPACE_STRING
"::VkCommandBuffer::endTransformFeedbackEXT: counterBuffers.size() != counterBufferOffsets.size()" ); "::CommandBuffer::endTransformFeedbackEXT: counterBuffers.size() != counterBufferOffsets.size()" );
} }
# endif /*VULKAN_HPP_NO_EXCEPTIONS*/ # endif /*VULKAN_HPP_NO_EXCEPTIONS*/
d.vkCmdEndTransformFeedbackEXT( m_commandBuffer, d.vkCmdEndTransformFeedbackEXT( m_commandBuffer,
@ -97556,6 +97560,7 @@ namespace VULKAN_HPP_NAMESPACE
reinterpret_cast<const VkSwapchainKHR *>( pSwapchains ), reinterpret_cast<const VkSwapchainKHR *>( pSwapchains ),
reinterpret_cast<const VkHdrMetadataEXT *>( pMetadata ) ); reinterpret_cast<const VkHdrMetadataEXT *>( pMetadata ) );
} }
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch> template <typename Dispatch>
VULKAN_HPP_INLINE void VULKAN_HPP_INLINE void
@ -97569,7 +97574,7 @@ namespace VULKAN_HPP_NAMESPACE
if ( swapchains.size() != metadata.size() ) if ( swapchains.size() != metadata.size() )
{ {
throw LogicError( VULKAN_HPP_NAMESPACE_STRING throw LogicError( VULKAN_HPP_NAMESPACE_STRING
"::VkDevice::setHdrMetadataEXT: swapchains.size() != metadata.size()" ); "::Device::setHdrMetadataEXT: swapchains.size() != metadata.size()" );
} }
# endif /*VULKAN_HPP_NO_EXCEPTIONS*/ # endif /*VULKAN_HPP_NO_EXCEPTIONS*/
d.vkSetHdrMetadataEXT( m_device, d.vkSetHdrMetadataEXT( m_device,