Correct version of two-step function returning two vectors of data

+ mark wrong version as deprecated (C++14)
This commit is contained in:
asuessenbach 2020-09-15 10:23:19 +02:00
parent f4b4e0eba9
commit d6dfdb547e
3 changed files with 589 additions and 22 deletions

View File

@ -602,15 +602,23 @@ std::string replaceWithMap( std::string const & input, std::map<std::string, std
// No match, just return the original string // No match, just return the original string
if ( it == end ) if ( it == end )
{ {
assert( replacements.empty() );
return input; return input;
} }
#if !defined( NDEBUG )
std::set<std::string> matchedReplacements;
#endif
std::string result = ""; std::string result = "";
while ( it != end ) while ( it != end )
{ {
std::smatch match = *it; std::smatch match = *it;
auto itReplacement = replacements.find( match[1].str() ); auto itReplacement = replacements.find( match[1].str() );
assert( itReplacement != replacements.end() ); assert( itReplacement != replacements.end() );
#if !defined( NDEBUG )
matchedReplacements.insert( match[1].str() );
#endif
result += result +=
match.prefix().str() + ( ( itReplacement != replacements.end() ) ? itReplacement->second : match[0].str() ); match.prefix().str() + ( ( itReplacement != replacements.end() ) ? itReplacement->second : match[0].str() );
@ -622,6 +630,17 @@ std::string replaceWithMap( std::string const & input, std::map<std::string, std
result += match.suffix().str(); result += match.suffix().str();
} }
} }
#if !defined( NDEBUG )
std::set<std::string> missedReplacements;
for ( auto r : replacements )
{
if ( matchedReplacements.find( r.first ) == matchedReplacements.end() )
{
missedReplacements.insert( r.first );
}
}
assert( missedReplacements.empty() );
#endif
return result; return result;
} }
@ -1216,6 +1235,20 @@ void VulkanHppGenerator::appendCommand( std::string & str,
return; return;
} }
} }
else if ( vectorParamIndices.size() == 2 )
{
auto firstVectorParam = vectorParamIndices.begin();
auto secondVectorParam = firstVectorParam++;
std::vector<ParamData> const & params = commandData.params;
if ( ( firstVectorParam->second == secondVectorParam->second ) &&
params[firstVectorParam->first].type.isNonConstPointer() &&
params[secondVectorParam->first].type.isNonConstPointer() &&
params[firstVectorParam->second].type.isNonConstPointer() )
{
appendCommandTwoStepTwoVectors( str, name, commandData, vectorParamIndices, definition );
return;
}
}
bool twoStep = isTwoStepAlgorithm( commandData.params ); bool twoStep = isTwoStepAlgorithm( commandData.params );
@ -1477,9 +1510,9 @@ void VulkanHppGenerator::appendCommandFixedSizeVector( std::string &
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 );
std::string commandName = startLowerCase( stripPrefix( name, "vk" ) ); std::string commandName = determineCommandName( name, commandData.params[0].type.type );
std::string commandNameSingular = stripPluralS( commandName ); std::string commandNameSingular = stripPluralS( commandName );
std::string nodiscard = std::string nodiscardEnhanced =
( 1 < commandData.successCodes.size() ) ( 1 < commandData.successCodes.size() )
? "VULKAN_HPP_NODISCARD " ? "VULKAN_HPP_NODISCARD "
: ( ( 1 < commandData.errorCodes.size() ) ? "VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS " : "" ); : ( ( 1 < commandData.errorCodes.size() ) ? "VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS " : "" );
@ -1494,22 +1527,18 @@ void VulkanHppGenerator::appendCommandFixedSizeVector( std::string &
if ( definition ) if ( definition )
{ {
std::string const functionTemplate = R"( std::string const functionTemplate = R"(
${enter} template <typename Dispatch> ${enter}${commandStandard}
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE Result ${className}::${commandName}( ${argumentListStandard} ) const VULKAN_HPP_NOEXCEPT
{
${functionBodyStandard}
}
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename T, typename Dispatch> template <typename T, typename Dispatch>
VULKAN_HPP_DEPRECATED( "This function is deprecated. Use one of the other flavours of it.") VULKAN_HPP_DEPRECATED( "This function is deprecated. Use one of the other flavours of it.")
${nodiscard}VULKAN_HPP_INLINE ${returnTypeDeprecated} ${className}::${commandName}( ${argumentListEnhancedDeprecated} ) const ${nodiscardEnhanced}VULKAN_HPP_INLINE ${returnTypeDeprecated} ${className}::${commandName}( ${argumentListEnhancedDeprecated} ) const
{ {
${functionBodyEnhancedDeprecated} ${functionBodyEnhancedDeprecated}
} }
template <typename T, typename Allocator, typename Dispatch> template <typename T, typename Allocator, typename Dispatch>
${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}::${commandName}( ${argumentListEnhanced} ) const ${nodiscardEnhanced}VULKAN_HPP_INLINE ${returnType} ${className}::${commandName}( ${argumentListEnhanced} ) const
{ {
VULKAN_HPP_ASSERT( ${dataSize} % sizeof( T ) == 0 ); VULKAN_HPP_ASSERT( ${dataSize} % sizeof( T ) == 0 );
std::vector<T,Allocator> ${dataName}( ${dataSize} / sizeof( T ) ); std::vector<T,Allocator> ${dataName}( ${dataSize} / sizeof( T ) );
@ -1518,7 +1547,7 @@ ${enter} template <typename Dispatch>
} }
template <typename T, typename Dispatch> template <typename T, typename Dispatch>
${nodiscard}VULKAN_HPP_INLINE ${returnTypeSingular} ${className}::${commandNameSingular}( ${argumentListEnhancedSingular} ) const ${nodiscardEnhanced}VULKAN_HPP_INLINE ${returnTypeSingular} ${className}::${commandNameSingular}( ${argumentListEnhancedSingular} ) const
{ {
T ${dataName}; T ${dataName};
${functionCallSingular} ${functionCallSingular}
@ -1560,10 +1589,10 @@ ${leave}
true, true,
false, false,
false ) }, false ) },
{ "argumentListStandard", constructFunctionHeaderArgumentsStandard( commandData, false ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) }, { "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName }, { "commandName", commandName },
{ "commandNameSingular", commandNameSingular }, { "commandNameSingular", commandNameSingular },
{ "commandStandard", constructCommandStandard( name, commandData, definition ) },
{ "dataName", startLowerCase( stripPrefix( commandData.params[vectorParamIndexIt->first].name, "p" ) ) }, { "dataName", startLowerCase( stripPrefix( commandData.params[vectorParamIndexIt->first].name, "p" ) ) },
{ "dataSize", commandData.params[vectorParamIndexIt->first].len }, { "dataSize", commandData.params[vectorParamIndexIt->first].len },
{ "enter", enter }, { "enter", enter },
@ -1580,29 +1609,26 @@ ${leave}
false, false,
false, false,
false ) }, false ) },
{ "functionBodyStandard", constructFunctionBodyStandard( " ", name, commandData ) },
{ "functionCall", functionCall }, { "functionCall", functionCall },
{ "functionCallSingular", functionCallSingular }, { "functionCallSingular", functionCallSingular },
{ "leave", leave }, { "leave", leave },
{ "nodiscard", nodiscard }, { "nodiscardEnhanced", nodiscardEnhanced },
{ "successCodeList", successCodeList }, { "successCodeList", successCodeList },
{ "returnType", returnType }, { "returnType", returnType },
{ "returnTypeDeprecated", returnTypeDeprecated }, { "returnTypeDeprecated", returnTypeDeprecated },
{ "returnTypeSingular", returnTypeSingular }, { "returnTypeSingular", returnTypeSingular } } ) );
{ "vkCommandName", name } } ) );
} }
else else
{ {
std::string const functionTemplate = R"( std::string const functionTemplate = R"(
${enter} template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> ${enter}${commandStandard}
VULKAN_HPP_NODISCARD Result ${commandName}( ${argumentListStandard} ) const VULKAN_HPP_NOEXCEPT;
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename T, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> template <typename T, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
${nodiscard}${returnTypeDeprecated} ${commandName}( ${argumentListEnhancedDeprecated} ) const; ${nodiscardEnhanced}${returnTypeDeprecated} ${commandName}( ${argumentListEnhancedDeprecated} ) const;
template <typename T, typename Allocator = std::allocator<T>, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> template <typename T, typename Allocator = std::allocator<T>, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
${nodiscard}${returnType} ${commandName}( ${argumentListEnhanced} ) const; ${nodiscardEnhanced}${returnType} ${commandName}( ${argumentListEnhanced} ) const;
template <typename T, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> template <typename T, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
${nodiscard}${returnTypeSingular} ${commandNameSingular}( ${argumentListEnhancedSingular} ) const; ${nodiscardEnhanced}${returnTypeSingular} ${commandNameSingular}( ${argumentListEnhancedSingular} ) const;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
${leave} ${leave}
)"; )";
@ -1624,12 +1650,12 @@ ${leave}
true, true,
true, true,
false ) }, false ) },
{ "argumentListStandard", constructFunctionHeaderArgumentsStandard( commandData, true ) },
{ "commandName", commandName }, { "commandName", commandName },
{ "commandNameSingular", commandNameSingular }, { "commandNameSingular", commandNameSingular },
{ "commandStandard", constructCommandStandard( name, commandData, definition ) },
{ "enter", enter }, { "enter", enter },
{ "leave", leave }, { "leave", leave },
{ "nodiscard", nodiscard }, { "nodiscardEnhanced", nodiscardEnhanced },
{ "returnType", returnType }, { "returnType", returnType },
{ "returnTypeDeprecated", returnTypeDeprecated }, { "returnTypeDeprecated", returnTypeDeprecated },
{ "returnTypeSingular", returnTypeSingular } } ) ); { "returnTypeSingular", returnTypeSingular } } ) );
@ -1649,6 +1675,164 @@ ${leave}
} }
} }
void VulkanHppGenerator::appendCommandTwoStepTwoVectors( std::string & str,
std::string const & name,
CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices,
bool definition ) const
{
assert( commandData.returnType == "VkResult" );
assert( vectorParamIndices.size() == 2 );
std::string enter, leave;
std::tie( enter, leave ) = generateProtection( commandData.feature, commandData.extensions );
assert( enter.empty() );
std::string commandName = determineCommandName( name, commandData.params[0].type.type );
std::string nodiscardEnhanced =
( 1 < commandData.successCodes.size() )
? "VULKAN_HPP_NODISCARD "
: ( ( 1 < commandData.errorCodes.size() ) ? "VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS " : "" );
size_t returnParamIndexDeprecated = determineReturnParamIndex( commandData, vectorParamIndices, true );
std::string returnTypeDeprecated =
determineEnhancedReturnType( commandData,
returnParamIndexDeprecated,
vectorParamIndices,
false ); // get the enhanced return type without structureChain
std::string templateTypeDeprecated = stripPrefix( commandData.params[returnParamIndexDeprecated].type.type, "Vk" );
if ( definition )
{
const std::string functionTemplate = R"(
${commandStandard}
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Allocator, typename Dispatch>
VULKAN_HPP_DEPRECATED( "This function is deprecated. Use one of the other flavours of it.")
${nodiscardEnhanced}VULKAN_HPP_INLINE typename ResultValueType<${returnTypeDeprecated}>::type ${className}::${commandName}( ${argumentListEnhancedDeprecated} ) const
{
${functionBodyEnhancedDeprecated}
}
template <typename Allocator, typename Dispatch, typename B, typename std::enable_if<std::is_same<typename B::value_type, ${templateTypeDeprecated}>::value, int>::type>
VULKAN_HPP_DEPRECATED( "This function is deprecated. Use one of the other flavours of it.")
${nodiscardEnhanced}VULKAN_HPP_INLINE typename ResultValueType<${returnTypeDeprecated}>::type ${className}::${commandName}( ${argumentListEnhancedWithAllocatorDeprecated} ) const
{
${functionBodyEnhancedWithAllocatorDeprecated}
}
${commandEnhanced}
${commandEnhancedWithAllocators}
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
)";
str += replaceWithMap(
functionTemplate,
std::map<std::string, std::string>(
{ { "argumentListEnhancedDeprecated",
constructFunctionHeaderArgumentsEnhanced( commandData,
returnParamIndexDeprecated,
returnParamIndexDeprecated,
vectorParamIndices,
false,
false,
false ) },
{ "argumentListEnhancedWithAllocatorDeprecated",
constructFunctionHeaderArgumentsEnhanced( commandData,
returnParamIndexDeprecated,
returnParamIndexDeprecated,
vectorParamIndices,
false,
false,
true ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandEnhanced",
constructCommandTwoStepTwoVectors( name, commandData, vectorParamIndices, definition, false ) },
{ "commandEnhancedWithAllocators",
constructCommandTwoStepTwoVectors( name, commandData, vectorParamIndices, definition, true ) },
{ "commandName", commandName },
{ "commandStandard", constructCommandStandard( name, commandData, definition ) },
{ "functionBodyEnhancedDeprecated",
constructFunctionBodyEnhanced( " ",
name,
commandData,
returnParamIndexDeprecated,
returnParamIndexDeprecated,
vectorParamIndices,
true,
returnTypeDeprecated,
false,
false,
false,
false ) },
{ "functionBodyEnhancedWithAllocatorDeprecated",
constructFunctionBodyEnhanced( " ",
name,
commandData,
returnParamIndexDeprecated,
returnParamIndexDeprecated,
vectorParamIndices,
true,
returnTypeDeprecated,
false,
false,
false,
true ) },
{ "nodiscardEnhanced", nodiscardEnhanced },
{ "returnTypeDeprecated", returnTypeDeprecated },
{ "templateTypeDeprecated", templateTypeDeprecated } } ) );
}
else
{
const std::string functionTemplate = R"(
${commandStandard}
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Allocator = std::allocator<${templateTypeDeprecated}>,
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
${nodiscardEnhanced}typename ResultValueType<${returnTypeDeprecated}>::type ${commandName}( ${argumentListEnhancedDeprecated} ) const;
template <typename Allocator = std::allocator<${templateTypeDeprecated}>,
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE,
typename B = Allocator,
typename std::enable_if<std::is_same<typename B::value_type, ${templateTypeDeprecated}>::value, int>::type = 0>
${nodiscardEnhanced}typename ResultValueType<${returnTypeDeprecated}>::type ${commandName}( ${argumentListEnhancedWithAllocatorDeprecated} ) const;
${commandEnhanced}
${commandEnhancedWithAllocators}
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
)";
str += replaceWithMap(
functionTemplate,
std::map<std::string, std::string>(
{ { "argumentListEnhancedDeprecated",
constructFunctionHeaderArgumentsEnhanced( commandData,
returnParamIndexDeprecated,
returnParamIndexDeprecated,
vectorParamIndices,
false,
true,
false ) },
{ "argumentListEnhancedWithAllocatorDeprecated",
constructFunctionHeaderArgumentsEnhanced( commandData,
returnParamIndexDeprecated,
returnParamIndexDeprecated,
vectorParamIndices,
false,
true,
true ) },
{ "commandEnhanced",
constructCommandTwoStepTwoVectors( name, commandData, vectorParamIndices, definition, false ) },
{ "commandEnhancedWithAllocators",
constructCommandTwoStepTwoVectors( name, commandData, vectorParamIndices, definition, true ) },
{ "commandName", commandName },
{ "commandStandard", constructCommandStandard( name, commandData, definition ) },
{ "nodiscardEnhanced", nodiscardEnhanced },
{ "returnTypeDeprecated", returnTypeDeprecated },
{ "templateTypeDeprecated", templateTypeDeprecated } } ) );
}
}
void VulkanHppGenerator::appendDispatchLoaderDynamic( std::string & str ) void VulkanHppGenerator::appendDispatchLoaderDynamic( std::string & str )
{ {
str += R"( str += R"(
@ -3610,6 +3794,244 @@ void VulkanHppGenerator::appendStructCompareOperators( std::string &
{ { "name", stripPrefix( structData.first, "Vk" ) }, { "compareMembers", compareMembers } } ); { { "name", stripPrefix( structData.first, "Vk" ) }, { "compareMembers", compareMembers } } );
} }
std::string VulkanHppGenerator::constructArgumentList( std::vector<ParamData> const & params,
std::set<size_t> const & skippedParams,
bool withAllocators ) const
{
assert( *skippedParams.begin() == 0 );
std::string argumentList;
for ( size_t i = 1; i < params.size(); ++i )
{
if ( skippedParams.find( i ) == skippedParams.end() )
{
assert( params[i].arraySizes.empty() );
assert( params[i].len.empty() );
assert( !params[i].optional );
argumentList += params[i].type.compose() + " " + params[i].name + ", ";
}
}
if ( withAllocators )
{
for ( auto sp : skippedParams )
{
if ( !params[sp].len.empty() )
{
argumentList += stripPrefix( params[sp].type.type, "Vk" ) + "Allocator & " +
startLowerCase( stripPrefix( params[sp].name, "p" ) ) + "Allocator, ";
}
}
}
argumentList += "Dispatch const & d";
return argumentList;
}
std::string VulkanHppGenerator::constructCallArguments( std::vector<ParamData> const & params,
std::map<size_t, size_t> const & vectorParamIndices,
bool firstCall ) const
{
size_t countIndex = vectorParamIndices.empty() ? ~0 : vectorParamIndices.begin()->second;
assert( ( vectorParamIndices.size() != 2 ) || ( std::next( vectorParamIndices.begin() )->second == countIndex ) );
std::string arguments = "m_" + startLowerCase( stripPrefix( params[0].type.type, "Vk" ) );
for ( size_t i = 1; i < params.size(); i++ )
{
if ( i == countIndex )
{
arguments += ", &" + startLowerCase( stripPrefix( params[i].name, "p" ) );
}
else if ( vectorParamIndices.find( i ) != vectorParamIndices.end() )
{
if ( firstCall )
{
arguments += ", nullptr";
}
else
{
arguments += ", reinterpret_cast<" + params[i].type.type + " *>( enumeratedData." +
( ( vectorParamIndices.find( i ) == vectorParamIndices.begin() ) ? "first" : "second" ) +
".data() )";
}
}
else
{
std::string arg = params[i].name;
if ( beginsWith( params[i].type.type, "Vk" ) )
{
if ( params[i].len.empty() )
{
arg = "static_cast<" + params[i].type.type + ">( " + arg + " )";
}
else
{
arg = "reinterpret_cast<" + params[i].type.type + "*>( " + arg + " )";
}
}
arguments += ", " + arg;
}
}
return arguments;
}
std::string VulkanHppGenerator::constructCommandStandard( std::string const & name,
CommandData const & commandData,
bool definition ) const
{
std::string str;
std::string commandName = determineCommandName( name, commandData.params[0].type.type );
std::string nodiscard =
( 1 < commandData.successCodes.size() + commandData.errorCodes.size() ) ? "VULKAN_HPP_NODISCARD " : "";
if ( definition )
{
std::string const functionTemplate =
R"( template <typename Dispatch>
${nodiscard}VULKAN_HPP_INLINE Result ${className}::${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT
{
return static_cast<Result>( d.${vkCommand}( ${callArguments} ) );
})";
str = replaceWithMap( functionTemplate,
std::map<std::string, std::string>( {
{ "argumentList", constructFunctionHeaderArgumentsStandard( commandData, false ) },
{ "callArguments", constructCallArguments( commandData.params, {}, true ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName },
{ "nodiscard", nodiscard },
{ "vkCommand", name },
} ) );
}
else
{
std::string const functionTemplate =
R"( template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
${nodiscard}Result ${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT;)";
str = replaceWithMap( functionTemplate,
std::map<std::string, std::string>(
{ { "argumentList", constructFunctionHeaderArgumentsStandard( commandData, true ) },
{ "commandName", commandName },
{ "nodiscard", nodiscard } } ) );
}
return str;
}
std::string VulkanHppGenerator::constructCommandTwoStepTwoVectors( std::string const & name,
CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices,
bool definition,
bool withAllocators ) const
{
std::string str;
std::string commandName = determineCommandName( name, commandData.params[0].type.type );
std::string nodiscard =
( 1 < commandData.successCodes.size() )
? "VULKAN_HPP_NODISCARD "
: ( ( 1 < commandData.errorCodes.size() ) ? "VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS " : "" );
auto firstVectorParamIt = vectorParamIndices.begin();
auto secondVectorParamIt = std::next( firstVectorParamIt );
std::string firstTemplateType = stripPrefix( commandData.params[firstVectorParamIt->first].type.type, "Vk" );
std::string secondTemplateType = stripPrefix( commandData.params[secondVectorParamIt->first].type.type, "Vk" );
assert( commandData.params[0].type.type == commandData.handle );
assert( firstVectorParamIt->second == secondVectorParamIt->second );
std::set<size_t> skippedParams = {
0, firstVectorParamIt->second, firstVectorParamIt->first, secondVectorParamIt->first
};
if ( definition )
{
const std::string functionTemplate =
R"( template <typename ${firstTemplateType}Allocator, typename ${secondTemplateType}Allocator, typename Dispatch${withAllocatorTypenameCheck}>
${nodiscard}VULKAN_HPP_INLINE typename ResultValueType<std::pair<std::vector<${firstTemplateType}, ${firstTemplateType}Allocator>, std::vector<${secondTemplateType}, ${secondTemplateType}Allocator>>>::type ${className}::${commandName}( ${argumentList} ) const
{
std::pair<std::vector<${firstTemplateType}, ${firstTemplateType}Allocator>, std::vector<${secondTemplateType}, ${secondTemplateType}Allocator>> enumeratedData${pairConstructor};
${counterType} ${counterName};
Result result;
do
{
result = static_cast<Result>( d.${vkCommand}( ${firstCallArguments} ) );
if ( ( result == Result::eSuccess ) && counterCount )
{
enumeratedData.first.resize( ${counterName} );
enumeratedData.second.resize( ${counterName} );
result = static_cast<Result>( d.${vkCommand}( ${secondCallArguments} ) );
VULKAN_HPP_ASSERT( ${counterName} <= enumeratedData.first.size() );
}
} while ( result == Result::eIncomplete );
if ( ( result == Result::eSuccess ) && ( ${counterName} < enumeratedData.first.size() ) )
{
enumeratedData.first.resize( ${counterName} );
enumeratedData.second.resize( ${counterName} );
}
return createResultValue( result, enumeratedData, VULKAN_HPP_NAMESPACE_STRING"::${className}::${commandName}" );
})";
assert( beginsWith( commandData.params[firstVectorParamIt->first].name, "p" ) );
assert( beginsWith( commandData.params[firstVectorParamIt->second].name, "p" ) );
assert( beginsWith( commandData.params[secondVectorParamIt->first].name, "p" ) );
std::string firstVectorName =
startLowerCase( stripPrefix( commandData.params[firstVectorParamIt->first].name, "p" ) );
std::string secondVectorName =
startLowerCase( stripPrefix( commandData.params[secondVectorParamIt->first].name, "p" ) );
std::string counterType = commandData.params[firstVectorParamIt->second].type.type;
std::string counterName =
startLowerCase( stripPrefix( stripPluralS( commandData.params[firstVectorParamIt->second].name ), "p" ) );
std::string firstCallArguments = constructCallArguments( commandData.params, vectorParamIndices, true );
std::string secondCallArguments = constructCallArguments( commandData.params, vectorParamIndices, false );
std::string withAllocatorsTypenameCheck =
", typename B1, typename B2, typename std::enable_if < std::is_same<typename B1::value_type, " +
firstTemplateType + ">::value && std::is_same<typename B2::value_type, " + secondTemplateType +
">::value, int>::type ";
str = replaceWithMap(
functionTemplate,
std::map<std::string, std::string>(
{ { "argumentList", constructArgumentList( commandData.params, skippedParams, withAllocators ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName },
{ "counterName", counterName },
{ "counterType", counterType },
{ "firstCallArguments", firstCallArguments },
{ "firstTemplateType", firstTemplateType },
{ "nodiscard", nodiscard },
{ "pairConstructor",
withAllocators ? ( "( std::piecewise_construct, std::forward_as_tuple( " + firstVectorName +
"Allocator ), std::forward_as_tuple( " + secondVectorName + "Allocator ) )" )
: "" },
{ "secondCallArguments", secondCallArguments },
{ "secondTemplateType", secondTemplateType },
{ "vkCommand", name },
{ "withAllocatorTypenameCheck", withAllocators ? withAllocatorsTypenameCheck : "" } } ) );
}
else
{
const std::string functionTemplate =
R"( template <typename ${firstTemplateType}Allocator = std::allocator<${firstTemplateType}>, typename ${secondTemplateType}Allocator = std::allocator<${secondTemplateType}>, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE${withAllocatorTypenameCheck}>
${nodiscard}typename ResultValueType<std::pair<std::vector<${firstTemplateType}, ${firstTemplateType}Allocator>, std::vector<${secondTemplateType}, ${secondTemplateType}Allocator>>>::type ${commandName}( ${argumentList} VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;)";
std::string withAllocatorsTypenameCheck =
", typename B1 = " + firstTemplateType + "Allocator, typename B2 = " + secondTemplateType +
"Allocator, typename std::enable_if < std::is_same<typename B1::value_type, " + firstTemplateType +
">::value && std::is_same<typename B2::value_type, " + secondTemplateType + ">::value, int>::type = 0";
str = replaceWithMap(
functionTemplate,
std::map<std::string, std::string>(
{ { "argumentList", constructArgumentList( commandData.params, skippedParams, withAllocators ) },
{ "commandName", commandName },
{ "firstTemplateType", firstTemplateType },
{ "nodiscard", nodiscard },
{ "secondTemplateType", secondTemplateType },
{ "withAllocatorTypenameCheck", withAllocators ? withAllocatorsTypenameCheck : "" } } ) );
}
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

@ -81,6 +81,11 @@ private:
return ( prefix == rhs.prefix ) && ( type == rhs.type ) && ( postfix == rhs.postfix ); return ( prefix == rhs.prefix ) && ( type == rhs.type ) && ( postfix == rhs.postfix );
} }
bool isConstPointer() const
{
return ( prefix.find( "const" ) != std::string::npos ) && ( postfix.find( '*' ) != std::string::npos );
}
bool isNonConstPointer() const bool isNonConstPointer() const
{ {
return ( prefix.find( "const" ) == std::string::npos ) && ( postfix.find( '*' ) != std::string::npos ); return ( prefix.find( "const" ) == std::string::npos ) && ( postfix.find( '*' ) != std::string::npos );
@ -316,6 +321,11 @@ private:
CommandData const & commandData, CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool definition ) const; bool definition ) const;
void appendCommandTwoStepTwoVectors( 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,
@ -495,6 +505,19 @@ private:
void appendUniqueTypes( std::string & str, void appendUniqueTypes( std::string & str,
std::string const & parentType, std::string const & parentType,
std::set<std::string> const & childrenTypes ) const; std::set<std::string> const & childrenTypes ) const;
std::string constructArgumentList( std::vector<ParamData> const & params,
std::set<size_t> const & skippedParams,
bool withAllocators ) const;
std::string constructCallArguments( std::vector<ParamData> const & params,
std::map<size_t, size_t> const & vectorParamIndices,
bool firstCall ) const;
std::string
constructCommandStandard( std::string const & name, CommandData const & commandData, bool definition ) const;
std::string constructCommandTwoStepTwoVectors( 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

@ -59231,6 +59231,30 @@ namespace VULKAN_HPP_NAMESPACE
ArrayProxy<VULKAN_HPP_NAMESPACE::PerformanceCounterKHR> const & counters, ArrayProxy<VULKAN_HPP_NAMESPACE::PerformanceCounterKHR> const & counters,
Allocator const & vectorAllocator, Allocator const & vectorAllocator,
Dispatch const & d ) const; Dispatch const & d ) const;
template <typename PerformanceCounterKHRAllocator = std::allocator<PerformanceCounterKHR>,
typename PerformanceCounterDescriptionKHRAllocator = std::allocator<PerformanceCounterDescriptionKHR>,
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD typename ResultValueType<
std::pair<std::vector<PerformanceCounterKHR, PerformanceCounterKHRAllocator>,
std::vector<PerformanceCounterDescriptionKHR, PerformanceCounterDescriptionKHRAllocator>>>::type
enumerateQueueFamilyPerformanceQueryCountersKHR(
uint32_t queueFamilyIndex, Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
template <typename PerformanceCounterKHRAllocator = std::allocator<PerformanceCounterKHR>,
typename PerformanceCounterDescriptionKHRAllocator = std::allocator<PerformanceCounterDescriptionKHR>,
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE,
typename B1 = PerformanceCounterKHRAllocator,
typename B2 = PerformanceCounterDescriptionKHRAllocator,
typename std::enable_if<std::is_same<typename B1::value_type, PerformanceCounterKHR>::value &&
std::is_same<typename B2::value_type, PerformanceCounterDescriptionKHR>::value,
int>::type = 0>
VULKAN_HPP_NODISCARD typename ResultValueType<
std::pair<std::vector<PerformanceCounterKHR, PerformanceCounterKHRAllocator>,
std::vector<PerformanceCounterDescriptionKHR, PerformanceCounterDescriptionKHRAllocator>>>::type
enumerateQueueFamilyPerformanceQueryCountersKHR(
uint32_t queueFamilyIndex,
PerformanceCounterKHRAllocator & countersAllocator,
PerformanceCounterDescriptionKHRAllocator & counterDescriptionsAllocator,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
@ -100775,8 +100799,10 @@ namespace VULKAN_HPP_NAMESPACE
reinterpret_cast<VkPerformanceCounterKHR *>( pCounters ), reinterpret_cast<VkPerformanceCounterKHR *>( pCounters ),
reinterpret_cast<VkPerformanceCounterDescriptionKHR *>( pCounterDescriptions ) ) ); reinterpret_cast<VkPerformanceCounterDescriptionKHR *>( pCounterDescriptions ) ) );
} }
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Allocator, typename Dispatch> template <typename Allocator, typename Dispatch>
VULKAN_HPP_DEPRECATED( "This function is deprecated. Use one of the other flavours of it." )
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE
typename ResultValueType<std::vector<PerformanceCounterDescriptionKHR, Allocator>>::type typename ResultValueType<std::vector<PerformanceCounterDescriptionKHR, Allocator>>::type
PhysicalDevice::enumerateQueueFamilyPerformanceQueryCountersKHR( PhysicalDevice::enumerateQueueFamilyPerformanceQueryCountersKHR(
@ -100816,11 +100842,13 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NAMESPACE_STRING VULKAN_HPP_NAMESPACE_STRING
"::PhysicalDevice::enumerateQueueFamilyPerformanceQueryCountersKHR" ); "::PhysicalDevice::enumerateQueueFamilyPerformanceQueryCountersKHR" );
} }
template < template <
typename Allocator, typename Allocator,
typename Dispatch, typename Dispatch,
typename B, typename B,
typename std::enable_if<std::is_same<typename B::value_type, PerformanceCounterDescriptionKHR>::value, int>::type> typename std::enable_if<std::is_same<typename B::value_type, PerformanceCounterDescriptionKHR>::value, int>::type>
VULKAN_HPP_DEPRECATED( "This function is deprecated. Use one of the other flavours of it." )
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE
typename ResultValueType<std::vector<PerformanceCounterDescriptionKHR, Allocator>>::type typename ResultValueType<std::vector<PerformanceCounterDescriptionKHR, Allocator>>::type
PhysicalDevice::enumerateQueueFamilyPerformanceQueryCountersKHR( PhysicalDevice::enumerateQueueFamilyPerformanceQueryCountersKHR(
@ -100861,6 +100889,100 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NAMESPACE_STRING VULKAN_HPP_NAMESPACE_STRING
"::PhysicalDevice::enumerateQueueFamilyPerformanceQueryCountersKHR" ); "::PhysicalDevice::enumerateQueueFamilyPerformanceQueryCountersKHR" );
} }
template <typename PerformanceCounterKHRAllocator,
typename PerformanceCounterDescriptionKHRAllocator,
typename Dispatch>
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE typename ResultValueType<
std::pair<std::vector<PerformanceCounterKHR, PerformanceCounterKHRAllocator>,
std::vector<PerformanceCounterDescriptionKHR, PerformanceCounterDescriptionKHRAllocator>>>::type
PhysicalDevice::enumerateQueueFamilyPerformanceQueryCountersKHR( uint32_t queueFamilyIndex,
Dispatch const & d ) const
{
std::pair<std::vector<PerformanceCounterKHR, PerformanceCounterKHRAllocator>,
std::vector<PerformanceCounterDescriptionKHR, PerformanceCounterDescriptionKHRAllocator>>
enumeratedData;
uint32_t counterCount;
Result result;
do
{
result = static_cast<Result>( d.vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(
m_physicalDevice, queueFamilyIndex, &counterCount, nullptr, nullptr ) );
if ( ( result == Result::eSuccess ) && counterCount )
{
enumeratedData.first.resize( counterCount );
enumeratedData.second.resize( counterCount );
result = static_cast<Result>( d.vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(
m_physicalDevice,
queueFamilyIndex,
&counterCount,
reinterpret_cast<VkPerformanceCounterKHR *>( enumeratedData.first.data() ),
reinterpret_cast<VkPerformanceCounterDescriptionKHR *>( enumeratedData.second.data() ) ) );
VULKAN_HPP_ASSERT( counterCount <= enumeratedData.first.size() );
}
} while ( result == Result::eIncomplete );
if ( ( result == Result::eSuccess ) && ( counterCount < enumeratedData.first.size() ) )
{
enumeratedData.first.resize( counterCount );
enumeratedData.second.resize( counterCount );
}
return createResultValue( result,
enumeratedData,
VULKAN_HPP_NAMESPACE_STRING
"::PhysicalDevice::enumerateQueueFamilyPerformanceQueryCountersKHR" );
}
template <typename PerformanceCounterKHRAllocator,
typename PerformanceCounterDescriptionKHRAllocator,
typename Dispatch,
typename B1,
typename B2,
typename std::enable_if<std::is_same<typename B1::value_type, PerformanceCounterKHR>::value &&
std::is_same<typename B2::value_type, PerformanceCounterDescriptionKHR>::value,
int>::type>
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE typename ResultValueType<
std::pair<std::vector<PerformanceCounterKHR, PerformanceCounterKHRAllocator>,
std::vector<PerformanceCounterDescriptionKHR, PerformanceCounterDescriptionKHRAllocator>>>::type
PhysicalDevice::enumerateQueueFamilyPerformanceQueryCountersKHR(
uint32_t queueFamilyIndex,
PerformanceCounterKHRAllocator & countersAllocator,
PerformanceCounterDescriptionKHRAllocator & counterDescriptionsAllocator,
Dispatch const & d ) const
{
std::pair<std::vector<PerformanceCounterKHR, PerformanceCounterKHRAllocator>,
std::vector<PerformanceCounterDescriptionKHR, PerformanceCounterDescriptionKHRAllocator>>
enumeratedData( std::piecewise_construct,
std::forward_as_tuple( countersAllocator ),
std::forward_as_tuple( counterDescriptionsAllocator ) );
uint32_t counterCount;
Result result;
do
{
result = static_cast<Result>( d.vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(
m_physicalDevice, queueFamilyIndex, &counterCount, nullptr, nullptr ) );
if ( ( result == Result::eSuccess ) && counterCount )
{
enumeratedData.first.resize( counterCount );
enumeratedData.second.resize( counterCount );
result = static_cast<Result>( d.vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(
m_physicalDevice,
queueFamilyIndex,
&counterCount,
reinterpret_cast<VkPerformanceCounterKHR *>( enumeratedData.first.data() ),
reinterpret_cast<VkPerformanceCounterDescriptionKHR *>( enumeratedData.second.data() ) ) );
VULKAN_HPP_ASSERT( counterCount <= enumeratedData.first.size() );
}
} while ( result == Result::eIncomplete );
if ( ( result == Result::eSuccess ) && ( counterCount < enumeratedData.first.size() ) )
{
enumeratedData.first.resize( counterCount );
enumeratedData.second.resize( counterCount );
}
return createResultValue( result,
enumeratedData,
VULKAN_HPP_NAMESPACE_STRING
"::PhysicalDevice::enumerateQueueFamilyPerformanceQueryCountersKHR" );
}
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
template <typename Dispatch> template <typename Dispatch>