Combine two types of commands into one generation function

This commit is contained in:
asuessenbach 2022-05-18 09:12:00 +02:00
parent 0506a95686
commit 3f240ea665
5 changed files with 186 additions and 254 deletions

View File

@ -2045,24 +2045,16 @@ size_t VulkanHppGenerator::determineDefaultStartIndex( std::vector<ParamData> co
return defaultStartIndex; return defaultStartIndex;
} }
bool VulkanHppGenerator::determineEnumeration( std::map<size_t, size_t> const & vectorParams, bool VulkanHppGenerator::determineEnumeration( std::map<size_t, size_t> const & vectorParams, std::vector<size_t> const & returnParams ) const
std::vector<size_t> const & returnParams
#if !defined( NDEBUG )
,
std::vector<std::string> const & successCodes
#endif
) const
{ {
// a command is considered to be enumerating some data, if for at least one vectorParam both, the data and the counter, are returnParams // a command is considered to be enumerating some data, if for at least one vectorParam both, the data and the counter, are returnParams
bool enumerating = std::find_if( vectorParams.begin(), return std::find_if( vectorParams.begin(),
vectorParams.end(), vectorParams.end(),
[&returnParams]( std::pair<size_t, size_t> const & vp ) [&returnParams]( std::pair<size_t, size_t> const & vp )
{ {
return std::find( returnParams.begin(), returnParams.end(), vp.first ) != returnParams.end() && return std::find( returnParams.begin(), returnParams.end(), vp.first ) != returnParams.end() &&
std::find( returnParams.begin(), returnParams.end(), vp.second ) != returnParams.end(); std::find( returnParams.begin(), returnParams.end(), vp.second ) != returnParams.end();
} ) != vectorParams.end(); } ) != vectorParams.end();
assert( !enumerating || successCodes.empty() || ( ( successCodes.size() == 2 ) && ( successCodes[1] == "VK_INCOMPLETE" ) ) );
return enumerating;
} }
size_t VulkanHppGenerator::determineInitialSkipCount( std::string const & command ) const size_t VulkanHppGenerator::determineInitialSkipCount( std::string const & command ) const
@ -3125,8 +3117,10 @@ std::string VulkanHppGenerator::generateCallSequence( std::string const &
size_t initialSkipCount, size_t initialSkipCount,
std::set<size_t> const & singularParams, std::set<size_t> const & singularParams,
std::set<size_t> const & templatedParams, std::set<size_t> const & templatedParams,
bool chained ) const bool chained,
bool raii ) const
{ {
std::string dispatcher = raii ? "getDispatcher()->" : "d.";
// if at least one returnParam is a size value of a vector param (and no singular params), we need two calls // if at least one returnParam is a size value of a vector param (and no singular params), we need two calls
if ( singularParams.empty() && if ( singularParams.empty() &&
( std::find_if( returnParams.begin(), ( std::find_if( returnParams.begin(),
@ -3155,7 +3149,7 @@ std::string VulkanHppGenerator::generateCallSequence( std::string const &
const std::string callSequenceTemplate = R"(VkResult result; const std::string callSequenceTemplate = R"(VkResult result;
do do
{ {
result = d.${vkCommand}( ${firstCallArguments} ); result = ${dispatcher}${vkCommand}( ${firstCallArguments} );
if ( ( result == VK_SUCCESS ) && ${counterName} ) if ( ( result == VK_SUCCESS ) && ${counterName} )
{ {
structureChains.resize( ${counterName} ); structureChains.resize( ${counterName} );
@ -3164,13 +3158,14 @@ std::string VulkanHppGenerator::generateCallSequence( std::string const &
{ {
${vectorName}[i].pNext = structureChains[i].template get<${vectorElementType}>().pNext; ${vectorName}[i].pNext = structureChains[i].template get<${vectorElementType}>().pNext;
} }
result = d.${vkCommand}( ${secondCallArguments} ); result = ${dispatcher}${vkCommand}( ${secondCallArguments} );
} }
} while ( result == VK_INCOMPLETE );)"; } while ( result == VK_INCOMPLETE );)";
return replaceWithMap( callSequenceTemplate, return replaceWithMap( callSequenceTemplate,
{ { "counterName", startLowerCase( stripPrefix( commandData.params[vectorParamIt->second].name, "p" ) ) }, { { "counterName", startLowerCase( stripPrefix( commandData.params[vectorParamIt->second].name, "p" ) ) },
{ "counterType", commandData.params[vectorParamIt->second].type.type }, { "counterType", commandData.params[vectorParamIt->second].type.type },
{ "dispatcher", dispatcher },
{ "firstCallArguments", firstCallArguments }, { "firstCallArguments", firstCallArguments },
{ "secondCallArguments", secondCallArguments }, { "secondCallArguments", secondCallArguments },
{ "vectorElementType", vectorElementType }, { "vectorElementType", vectorElementType },
@ -3180,18 +3175,19 @@ std::string VulkanHppGenerator::generateCallSequence( std::string const &
else else
{ {
const std::string callSequenceTemplate = const std::string callSequenceTemplate =
R"(d.${vkCommand}( ${firstCallArguments} ); R"(${dispatcher}${vkCommand}( ${firstCallArguments} );
structureChains.resize( ${counterName} ); structureChains.resize( ${counterName} );
${vectorName}.resize( ${counterName} ); ${vectorName}.resize( ${counterName} );
for ( ${counterType} i = 0; i < ${counterName}; i++ ) for ( ${counterType} i = 0; i < ${counterName}; i++ )
{ {
${vectorName}[i].pNext = structureChains[i].template get<${vectorElementType}>().pNext; ${vectorName}[i].pNext = structureChains[i].template get<${vectorElementType}>().pNext;
} }
d.${vkCommand}( ${secondCallArguments} );)"; ${dispatcher}${vkCommand}( ${secondCallArguments} );)";
return replaceWithMap( callSequenceTemplate, return replaceWithMap( callSequenceTemplate,
{ { "counterName", startLowerCase( stripPrefix( commandData.params[vectorParamIt->second].name, "p" ) ) }, { { "counterName", startLowerCase( stripPrefix( commandData.params[vectorParamIt->second].name, "p" ) ) },
{ "counterType", commandData.params[vectorParamIt->second].type.type }, { "counterType", commandData.params[vectorParamIt->second].type.type },
{ "dispatcher", dispatcher },
{ "firstCallArguments", firstCallArguments }, { "firstCallArguments", firstCallArguments },
{ "secondCallArguments", secondCallArguments }, { "secondCallArguments", secondCallArguments },
{ "vectorElementType", vectorElementType }, { "vectorElementType", vectorElementType },
@ -3217,16 +3213,17 @@ std::string VulkanHppGenerator::generateCallSequence( std::string const &
std::string const callSequenceTemplate = R"(VkResult result; std::string const callSequenceTemplate = R"(VkResult result;
do do
{ {
result = d.${vkCommand}( ${firstCallArguments} ); result = ${dispatcher}${vkCommand}( ${firstCallArguments} );
if ( ( result == VK_SUCCESS ) && ${counterName} ) if ( ( result == VK_SUCCESS ) && ${counterName} )
{ {
${resizes} ${resizes}
result = d.${vkCommand}( ${secondCallArguments} ); result = ${dispatcher}${vkCommand}( ${secondCallArguments} );
} }
} while ( result == VK_INCOMPLETE );)"; } while ( result == VK_INCOMPLETE );)";
return replaceWithMap( callSequenceTemplate, return replaceWithMap( callSequenceTemplate,
{ { "counterName", startLowerCase( stripPrefix( commandData.params[vectorParamIt->second].name, "p" ) ) }, { { "counterName", startLowerCase( stripPrefix( commandData.params[vectorParamIt->second].name, "p" ) ) },
{ "dispatcher", dispatcher },
{ "firstCallArguments", firstCallArguments }, { "firstCallArguments", firstCallArguments },
{ "secondCallArguments", secondCallArguments }, { "secondCallArguments", secondCallArguments },
{ "resizes", resizes }, { "resizes", resizes },
@ -3236,12 +3233,13 @@ std::string VulkanHppGenerator::generateCallSequence( std::string const &
{ {
// no need to enumerate here, just two calls // no need to enumerate here, just two calls
assert( commandData.returnType == "void" ); assert( commandData.returnType == "void" );
std::string const callSequenceTemplate = R"(d.${vkCommand}( ${firstCallArguments} ); std::string const callSequenceTemplate = R"(${dispatcher}${vkCommand}( ${firstCallArguments} );
${vectorName}.resize( ${vectorSize} ); ${vectorName}.resize( ${vectorSize} );
d.${vkCommand}( ${secondCallArguments} );)"; ${dispatcher}${vkCommand}( ${secondCallArguments} );)";
return replaceWithMap( callSequenceTemplate, return replaceWithMap( callSequenceTemplate,
{ { "firstCallArguments", firstCallArguments }, { { "dispatcher", dispatcher },
{ "firstCallArguments", firstCallArguments },
{ "secondCallArguments", secondCallArguments }, { "secondCallArguments", secondCallArguments },
{ "vectorName", vectorName }, { "vectorName", vectorName },
{ "vectorSize", vectorSize }, { "vectorSize", vectorSize },
@ -3250,12 +3248,14 @@ std::string VulkanHppGenerator::generateCallSequence( std::string const &
} }
else else
{ {
std::string const callSequenceTemplate = R"(${resultAssignment}d.${vkCommand}( ${callArguments} );)"; std::string const callSequenceTemplate = R"(${resultAssignment}${dispatcher}${vkCommand}( ${callArguments} );)";
std::string callArguments = generateCallArgumentsEnhanced( commandData, initialSkipCount, false, singularParams, templatedParams, false ); std::string callArguments = generateCallArgumentsEnhanced( commandData, initialSkipCount, false, singularParams, templatedParams, raii );
std::string resultAssignment = generateResultAssignment( commandData ); std::string resultAssignment = generateResultAssignment( commandData );
return replaceWithMap( callSequenceTemplate, { { "callArguments", callArguments }, { "resultAssignment", resultAssignment }, { "vkCommand", name } } ); return replaceWithMap(
callSequenceTemplate,
{ { "callArguments", callArguments }, { "dispatcher", dispatcher }, { "resultAssignment", resultAssignment }, { "vkCommand", name } } );
} }
} }
@ -3425,13 +3425,7 @@ std::string VulkanHppGenerator::generateCommandEnhanced( std::string const &
std::set<size_t> singularParams = singular ? determineSingularParams( returnParams[0], vectorParams ) : std::set<size_t>(); std::set<size_t> singularParams = singular ? determineSingularParams( returnParams[0], vectorParams ) : std::set<size_t>();
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck =
needsVectorSizeCheck( commandData.params, vectorParams, returnParams, singularParams ); needsVectorSizeCheck( commandData.params, vectorParams, returnParams, singularParams );
bool enumerating = determineEnumeration( vectorParams, bool enumerating = determineEnumeration( vectorParams, returnParams );
returnParams
#if !defined( NDEBUG )
,
commandData.successCodes
#endif
);
std::vector<std::string> dataTypes = determineDataTypes( commandData.params, vectorParams, returnParams, templatedParams ); std::vector<std::string> dataTypes = determineDataTypes( commandData.params, vectorParams, returnParams, templatedParams );
std::string dataType = combineDataTypes( vectorParams, returnParams, singular, enumerating, dataTypes ); std::string dataType = combineDataTypes( vectorParams, returnParams, singular, enumerating, dataTypes );
@ -3442,15 +3436,7 @@ std::string VulkanHppGenerator::generateCommandEnhanced( std::string const &
generateAllocatorTemplates( returnParams, dataTypes, vectorParams, definition, singular, unique, chained ); generateAllocatorTemplates( returnParams, dataTypes, vectorParams, definition, singular, unique, chained );
std::string typenameCheck = generateTypenameCheck( returnParams, vectorParams, definition, dataTypes, singular, withAllocator, unique, chained ); std::string typenameCheck = generateTypenameCheck( returnParams, vectorParams, definition, dataTypes, singular, withAllocator, unique, chained );
std::string nodiscard = generateNoDiscard( !returnParams.empty(), 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() ); std::string nodiscard = generateNoDiscard( !returnParams.empty(), 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
std::string returnType = generateReturnType( commandData, std::string returnType = generateReturnType( commandData, returnParams, unique, chained, dataType );
returnParams,
#if !defined( NDEBUG )
vectorParams,
singular,
#endif
unique,
chained,
dataType );
std::string className = initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : ""; std::string className = initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "";
std::string classSeparator = commandData.handle.empty() ? "" : "::"; std::string classSeparator = commandData.handle.empty() ? "" : "::";
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags, singular, unique ); std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags, singular, unique );
@ -3478,7 +3464,7 @@ std::string VulkanHppGenerator::generateCommandEnhanced( std::string const &
commandData, initialSkipCount, returnParams, vectorParams, templatedParams, singular, withAllocator, unique, chained, enumerating ); commandData, initialSkipCount, returnParams, vectorParams, templatedParams, singular, withAllocator, unique, chained, enumerating );
std::string dataSizeChecks = generateDataSizeChecks( commandData, returnParams, dataTypes, vectorParams, templatedParams, singular ); std::string dataSizeChecks = generateDataSizeChecks( commandData, returnParams, dataTypes, vectorParams, templatedParams, singular );
std::string callSequence = std::string callSequence =
generateCallSequence( name, commandData, returnParams, vectorParams, initialSkipCount, singularParams, templatedParams, chained ); generateCallSequence( name, commandData, returnParams, vectorParams, initialSkipCount, singularParams, templatedParams, chained, false );
std::string resultCheck = generateResultCheck( commandData, className, classSeparator, commandName, enumerating ); std::string resultCheck = generateResultCheck( commandData, className, classSeparator, commandName, enumerating );
std::string returnStatement = generateReturnStatement( std::string returnStatement = generateReturnStatement(
name, commandData, returnVariable, returnType, dataType, initialSkipCount, returnParams.empty() ? INVALID_INDEX : returnParams[0], unique, enumerating ); name, commandData, returnVariable, returnType, dataType, initialSkipCount, returnParams.empty() ? INVALID_INDEX : returnParams[0], unique, enumerating );
@ -6121,32 +6107,56 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandDeclarations( std::pair
std::string VulkanHppGenerator::generateRAIIHandleCommandEnhanced( std::map<std::string, CommandData>::const_iterator commandIt, std::string VulkanHppGenerator::generateRAIIHandleCommandEnhanced( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount, size_t initialSkipCount,
std::vector<size_t> const & returnParams,
std::map<size_t, size_t> const & vectorParams, std::map<size_t, size_t> const & vectorParams,
bool definition ) const bool definition ) const
{ {
std::set<size_t> skippedParams = determineSkippedParams( commandIt->second.params, initialSkipCount, vectorParams, {}, false ); std::set<size_t> skippedParams = determineSkippedParams( commandIt->second.params, initialSkipCount, vectorParams, {}, false );
std::set<size_t> singularParams = false ? determineSingularParams( returnParams[0], vectorParams ) : std::set<size_t>();
std::set<size_t> templatedParams = determineVoidPointerParams( commandIt->second.params ); std::set<size_t> templatedParams = determineVoidPointerParams( commandIt->second.params );
bool enumerating = determineEnumeration( vectorParams, returnParams );
std::vector<std::string> dataTypes = determineDataTypes( commandIt->second.params, vectorParams, returnParams, templatedParams );
std::string dataType = combineDataTypes( vectorParams, returnParams, false, enumerating, dataTypes );
std::string argumentTemplates = generateArgumentTemplates( commandIt->second.params, {}, vectorParams, templatedParams, true ); std::string argumentTemplates = generateArgumentTemplates( commandIt->second.params, {}, vectorParams, templatedParams, true );
std::string argumentList = std::string argumentList =
generateArgumentListEnhanced( commandIt->second.params, {}, vectorParams, skippedParams, {}, templatedParams, definition, false, false, false ); generateArgumentListEnhanced( commandIt->second.params, {}, vectorParams, skippedParams, {}, templatedParams, definition, false, false, false );
std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags, false, false ); std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags, false, false );
std::string nodiscard =
generateNoDiscard( !returnParams.empty() || ( ( commandIt->second.returnType != "VkResult" ) && ( commandIt->second.returnType != "void" ) ),
1 < commandIt->second.successCodes.size(),
1 < commandIt->second.errorCodes.size() );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandIt->second.params, vectorParams, {}, {} ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandIt->second.params, vectorParams, {}, {} );
std::string noexceptString = vectorSizeCheck.first ? "" : "VULKAN_HPP_NOEXCEPT"; std::string noexceptString = vectorSizeCheck.first ? "" : "VULKAN_HPP_NOEXCEPT";
std::string returnType = generateReturnType( commandIt->second, returnParams, false, false, dataType );
if ( definition ) if ( definition )
{ {
std::string const definitionTemplate = std::string const definitionTemplate =
R"( R"(
${argumentTemplates} ${argumentTemplates}
VULKAN_HPP_INLINE void ${className}::${commandName}( ${argumentList} ) const ${noexcept} ${nodiscard} VULKAN_HPP_INLINE ${returnType} ${className}::${commandName}( ${argumentList} ) const ${noexcept}
{ {
${functionPointerCheck} ${functionPointerCheck}
${vectorSizeCheck} ${vectorSizeCheck}
getDispatcher()->${vkCommand}( ${callArguments} ); ${callSequence}
${returnStatement}
} }
)"; )";
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true ); std::string callSequence =
generateCallSequence( commandIt->first, commandIt->second, returnParams, vectorParams, initialSkipCount, singularParams, templatedParams, false, true );
std::string returnVariable = generateReturnVariable( commandIt->second, returnParams, vectorParams, false, false );
std::string returnStatement = generateReturnStatement( commandIt->first,
commandIt->second,
returnVariable,
returnType,
dataType,
initialSkipCount,
returnParams.empty() ? INVALID_INDEX : returnParams[0],
false,
enumerating );
std::string vectorSizeCheckString = std::string vectorSizeCheckString =
vectorSizeCheck.first ? generateRAIIHandleVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams ) vectorSizeCheck.first ? generateRAIIHandleVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams )
: ""; : "";
@ -6154,31 +6164,37 @@ ${vectorSizeCheck}
return replaceWithMap( definitionTemplate, return replaceWithMap( definitionTemplate,
{ { "argumentList", argumentList }, { { "argumentList", argumentList },
{ "argumentTemplates", argumentTemplates }, { "argumentTemplates", argumentTemplates },
{ "callArguments", callArguments }, { "callSequence", callSequence },
{ "className", stripPrefix( commandIt->second.params[initialSkipCount - 1].type.type, "Vk" ) }, { "className", stripPrefix( commandIt->second.params[initialSkipCount - 1].type.type, "Vk" ) },
{ "commandName", commandName }, { "commandName", commandName },
{ "functionPointerCheck", generateFunctionPointerCheck( commandIt->first, commandIt->second.referencedIn ) }, { "functionPointerCheck", generateFunctionPointerCheck( commandIt->first, commandIt->second.referencedIn ) },
{ "nodiscard", nodiscard },
{ "noexcept", noexceptString }, { "noexcept", noexceptString },
{ "vectorSizeCheck", vectorSizeCheckString }, { "returnStatement", returnStatement },
{ "vkCommand", commandIt->first } } ); { "returnType", returnType },
{ "vectorSizeCheck", vectorSizeCheckString } } );
} }
else else
{ {
std::string const declarationTemplate = std::string const declarationTemplate =
R"( R"(
${argumentTemplates} ${argumentTemplates}
void ${commandName}( ${argumentList} ) const ${noexcept}; ${nodiscard} ${returnType} ${commandName}( ${argumentList} ) const ${noexcept};
)"; )";
return replaceWithMap( return replaceWithMap( declarationTemplate,
declarationTemplate, { { "argumentList", argumentList },
{ { "argumentList", argumentList }, { "argumentTemplates", argumentTemplates }, { "commandName", commandName }, { "noexcept", noexceptString } } ); { "argumentTemplates", argumentTemplates },
{ "commandName", commandName },
{ "nodiscard", nodiscard },
{ "noexcept", noexceptString },
{ "returnType", returnType } } );
} }
} }
std::string VulkanHppGenerator::generateRAIIHandleCommandFactory( std::map<std::string, CommandData>::const_iterator commandIt, std::string VulkanHppGenerator::generateRAIIHandleCommandFactory( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount, size_t initialSkipCount,
std::vector<size_t> returnParams, std::vector<size_t> const & returnParams,
std::map<size_t, size_t> const & vectorParams, std::map<size_t, size_t> const & vectorParams,
bool definition, bool definition,
bool singular ) const bool singular ) const
@ -7214,7 +7230,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessNoEr
std::vector<size_t> returnParams = determineReturnParams( commandIt->second.params ); std::vector<size_t> returnParams = determineReturnParams( commandIt->second.params );
if ( returnParams.empty() ) if ( returnParams.empty() )
{ {
return generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, determineVectorParams( commandIt->second.params ), definition ); return generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, returnParams, determineVectorParams( commandIt->second.params ), definition );
} }
return ""; return "";
} }
@ -7969,73 +7985,13 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandValue( std::map<std::st
} }
else else
{ {
return generateRAIIHandleCommandValue0Return0VectorType( commandIt, initialSkipCount, vectorParams, definition ); return generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, returnParams, vectorParams, definition );
} }
} }
} }
return ""; return "";
} }
std::string VulkanHppGenerator::generateRAIIHandleCommandValue0Return0VectorType( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
std::map<size_t, size_t> const & vectorParams,
bool definition ) const
{
std::set<size_t> skippedParams = determineSkippedParams( commandIt->second.params, initialSkipCount, vectorParams, {}, false );
std::set<size_t> templatedParams = determineVoidPointerParams( commandIt->second.params );
std::string argumentList =
generateArgumentListEnhanced( commandIt->second.params, {}, vectorParams, skippedParams, {}, templatedParams, definition, false, false, false );
std::string argumentTemplates = generateArgumentTemplates( commandIt->second.params, {}, vectorParams, templatedParams, true );
std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags, false, false );
std::string returnType = generateNamespacedType( commandIt->second.returnType );
if ( definition )
{
std::string const definitionTemplate =
R"(
${argumentTemplates}
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE ${returnType} ${className}::${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT
{${functionPointerCheck}
${vectorSizeCheck}
return getDispatcher()->${vkCommand}( ${callArguments} );
}
)";
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandIt->second.params, vectorParams, {}, {} );
std::string vectorSizeCheckString =
vectorSizeCheck.first ? generateVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams, true )
: "";
return replaceWithMap( definitionTemplate,
{ { "argumentList", argumentList },
{ "callArguments", callArguments },
{ "argumentTemplates", argumentTemplates },
{ "className", stripPrefix( commandIt->second.params[initialSkipCount - 1].type.type, "Vk" ) },
{ "commandName", commandName },
{ "functionPointerCheck", generateFunctionPointerCheck( commandIt->first, commandIt->second.referencedIn ) },
{ "returnType", returnType },
{ "vectorSizeCheck", vectorSizeCheckString },
{ "vkCommand", commandIt->first } } );
}
else
{
std::string const declarationTemplate =
R"(
${argumentTemplates}
VULKAN_HPP_NODISCARD ${returnType} ${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT;
)";
return replaceWithMap( declarationTemplate,
{
{ "argumentList", argumentList },
{ "argumentTemplates", argumentTemplates },
{ "commandName", commandName },
{ "returnType", returnType },
} );
}
}
std::string VulkanHppGenerator::generateRAIIHandleCommandValue0Return0VectorVkType( std::map<std::string, CommandData>::const_iterator commandIt, std::string VulkanHppGenerator::generateRAIIHandleCommandValue0Return0VectorVkType( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount, size_t initialSkipCount,
std::map<size_t, size_t> const & vectorParams, std::map<size_t, size_t> const & vectorParams,
@ -8098,7 +8054,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandVoid( std::map<std::str
std::map<size_t, size_t> vectorParams = determineVectorParams( commandIt->second.params ); std::map<size_t, size_t> vectorParams = determineVectorParams( commandIt->second.params );
switch ( returnParams.size() ) switch ( returnParams.size() )
{ {
case 0: str = generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, vectorParams, definition ); break; case 0: str = generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, returnParams, vectorParams, definition ); break;
case 1: case 1:
if ( commandIt->second.params[returnParams[0]].type.postfix == "**" ) if ( commandIt->second.params[returnParams[0]].type.postfix == "**" )
{ {
@ -9938,15 +9894,8 @@ std::string VulkanHppGenerator::generateReturnStatement( std::string const & com
return returnStatement; return returnStatement;
} }
std::string VulkanHppGenerator::generateReturnType( CommandData const & commandData, std::string VulkanHppGenerator::generateReturnType(
std::vector<size_t> const & returnParams, CommandData const & commandData, std::vector<size_t> const & returnParams, bool unique, bool chained, std::string const & dataType ) const
#if !defined( NDEBUG )
std::map<size_t, size_t> const & vectorParams,
bool singular,
#endif
bool unique,
bool chained,
std::string const & dataType ) const
{ {
std::string modifiedDataType = dataType; std::string modifiedDataType = dataType;
if ( chained ) if ( chained )
@ -9977,12 +9926,12 @@ std::string VulkanHppGenerator::generateReturnType( CommandData const &
std::string returnType; std::string returnType;
if ( ( 1 < commandData.successCodes.size() ) && returnParams.empty() ) if ( ( 1 < commandData.successCodes.size() ) && returnParams.empty() )
{ {
assert( ( commandData.returnType == "VkResult" ) && !chained && !singular && !unique ); assert( ( commandData.returnType == "VkResult" ) && !chained && !unique );
returnType = "VULKAN_HPP_NAMESPACE::Result"; returnType = "VULKAN_HPP_NAMESPACE::Result";
} }
else if ( ( commandData.returnType != "VkResult" ) && ( commandData.returnType != "void" ) ) else if ( ( commandData.returnType != "VkResult" ) && ( commandData.returnType != "void" ) )
{ {
assert( returnParams.empty() && vectorParams.empty() && !chained && !singular && !unique ); assert( returnParams.empty() && !chained && !unique );
if ( beginsWith( commandData.returnType, "Vk" ) ) if ( beginsWith( commandData.returnType, "Vk" ) )
{ {
returnType = "VULKAN_HPP_NAMESPACE::" + stripPrefix( commandData.returnType, "Vk" ); returnType = "VULKAN_HPP_NAMESPACE::" + stripPrefix( commandData.returnType, "Vk" );
@ -9995,11 +9944,8 @@ std::string VulkanHppGenerator::generateReturnType( CommandData const &
else if ( ( commandData.returnType == "void" ) || else if ( ( commandData.returnType == "void" ) ||
( ( commandData.returnType == "VkResult" ) && ( commandData.successCodes.size() == 1 ) && commandData.errorCodes.empty() ) ) ( ( commandData.returnType == "VkResult" ) && ( commandData.successCodes.size() == 1 ) && commandData.errorCodes.empty() ) )
{ {
assert( !singular && !unique ); assert( !unique );
assert( ( commandData.returnType != "void" ) || assert( ( commandData.returnType != "void" ) || ( returnParams.size() <= 2 ) );
( returnParams.empty() || ( ( returnParams.size() == 1 ) && ( vectorParams.find( returnParams[0] ) == vectorParams.end() ) ) ||
( ( returnParams.size() == 2 ) && ( vectorParams.size() == 1 ) && ( returnParams[0] == vectorParams.begin()->second ) &&
( returnParams[1] == vectorParams.begin()->first ) ) ) );
assert( ( commandData.returnType != "VkResult" ) || returnParams.empty() ); assert( ( commandData.returnType != "VkResult" ) || returnParams.empty() );
returnType = modifiedDataType; returnType = modifiedDataType;
} }
@ -10009,23 +9955,14 @@ std::string VulkanHppGenerator::generateReturnType( CommandData const &
assert( !commandData.successCodes.empty() && ( commandData.successCodes[0] == "VK_SUCCESS" ) ); assert( !commandData.successCodes.empty() && ( commandData.successCodes[0] == "VK_SUCCESS" ) );
if ( ( 1 < commandData.successCodes.size() ) && ( returnParams.size() == 1 ) ) if ( ( 1 < commandData.successCodes.size() ) && ( returnParams.size() == 1 ) )
{ {
assert( !commandData.errorCodes.empty() && ( vectorParams.empty() || ( vectorParams.find( returnParams[0] ) != vectorParams.end() ) ) && !chained ); assert( !commandData.errorCodes.empty() && !chained );
returnType = "ResultValue<" + modifiedDataType + ">"; returnType = "ResultValue<" + modifiedDataType + ">";
} }
else else
{ {
assert( assert(
( ( commandData.successCodes.size() == 1 ) || ( ( commandData.successCodes.size() == 2 ) && ( commandData.successCodes[1] == "VK_INCOMPLETE" ) ) ) && ( ( commandData.successCodes.size() == 1 ) || ( ( commandData.successCodes.size() == 2 ) && ( commandData.successCodes[1] == "VK_INCOMPLETE" ) ) ) &&
!commandData.errorCodes.empty() && !commandData.errorCodes.empty() && ( returnParams.size() <= 3 ) );
( returnParams.empty() ||
( ( returnParams.size() == 1 ) && ( vectorParams.empty() || ( vectorParams.find( returnParams[0] ) != vectorParams.end() ) ) ) ||
( ( returnParams.size() == 2 ) &&
( ( ( vectorParams.size() == 1 ) && ( returnParams[0] == vectorParams.begin()->second ) && ( returnParams[1] == vectorParams.begin()->first ) ) ||
( ( vectorParams.size() == 2 ) && ( vectorParams.find( returnParams[0] ) != vectorParams.end() ) &&
( vectorParams.find( returnParams[1] ) == vectorParams.end() ) ) ) ) ||
( ( returnParams.size() == 3 ) && ( vectorParams.size() == 2 ) && ( vectorParams.find( returnParams[1] ) != vectorParams.end() ) &&
( vectorParams.find( returnParams[1] )->second == returnParams[0] ) && ( vectorParams.find( returnParams[2] ) != vectorParams.end() ) &&
( vectorParams.find( returnParams[2] )->second == returnParams[0] ) ) ) );
returnType = "typename ResultValueType<" + modifiedDataType + ">::type"; returnType = "typename ResultValueType<" + modifiedDataType + ">::type";
} }
} }

View File

@ -410,13 +410,7 @@ private:
std::vector<size_t> const & returnParams, std::vector<size_t> const & returnParams,
std::set<size_t> const & templatedParams ) const; std::set<size_t> const & templatedParams ) const;
size_t determineDefaultStartIndex( std::vector<ParamData> const & params, std::set<size_t> const & skippedParams ) const; size_t determineDefaultStartIndex( std::vector<ParamData> const & params, std::set<size_t> const & skippedParams ) const;
bool determineEnumeration( std::map<size_t, size_t> const & vectorParams, bool determineEnumeration( std::map<size_t, size_t> const & vectorParams, std::vector<size_t> const & returnParams ) const;
std::vector<size_t> const & returnParams
#if !defined( NDEBUG )
,
std::vector<std::string> const & successCodes
#endif
) const;
size_t determineInitialSkipCount( std::string const & command ) const; size_t determineInitialSkipCount( std::string const & command ) const;
std::vector<size_t> determineReturnParams( std::vector<ParamData> const & params ) const; std::vector<size_t> determineReturnParams( std::vector<ParamData> const & params ) const;
std::vector<std::map<std::string, CommandData>::const_iterator> std::vector<std::map<std::string, CommandData>::const_iterator>
@ -490,7 +484,8 @@ private:
size_t initialSkipCount, size_t initialSkipCount,
std::set<size_t> const & singularParams, std::set<size_t> const & singularParams,
std::set<size_t> const & templatedParams, std::set<size_t> const & templatedParams,
bool chained ) const; bool chained,
bool raii ) const;
std::string generateChainTemplates( std::vector<size_t> const & returnParams, bool chained ) const; std::string generateChainTemplates( std::vector<size_t> const & returnParams, bool chained ) const;
std::string generateCommand( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition ) const; std::string generateCommand( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition ) const;
std::string std::string
@ -681,11 +676,12 @@ private:
std::string generateRAIIHandleCommandDeclarations( std::pair<std::string, HandleData> const & handle, std::set<std::string> const & specialFunctions ) const; std::string generateRAIIHandleCommandDeclarations( std::pair<std::string, HandleData> const & handle, std::set<std::string> const & specialFunctions ) const;
std::string generateRAIIHandleCommandEnhanced( std::map<std::string, CommandData>::const_iterator commandIt, std::string generateRAIIHandleCommandEnhanced( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount, size_t initialSkipCount,
std::vector<size_t> const & returnParams,
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool definition ) const; bool definition ) const;
std::string generateRAIIHandleCommandFactory( std::map<std::string, CommandData>::const_iterator commandIt, std::string generateRAIIHandleCommandFactory( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount, size_t initialSkipCount,
std::vector<size_t> returnParams, std::vector<size_t> const & returnParams,
std::map<size_t, size_t> const & vectorParams, std::map<size_t, size_t> const & vectorParams,
bool definition, bool definition,
bool singular ) const; bool singular ) const;
@ -823,10 +819,6 @@ private:
std::vector<size_t> const & returnParamIndices, std::vector<size_t> const & returnParamIndices,
bool definition ) const; bool definition ) const;
std::string generateRAIIHandleCommandValue( std::map<std::string, CommandData>::const_iterator commandIt, size_t initialSkipCount, bool definition ) const; std::string generateRAIIHandleCommandValue( std::map<std::string, CommandData>::const_iterator commandIt, size_t initialSkipCount, bool definition ) const;
std::string generateRAIIHandleCommandValue0Return0VectorType( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
std::map<size_t, size_t> const & vectorParamIndices,
bool definition ) const;
std::string generateRAIIHandleCommandValue0Return0VectorVkType( std::map<std::string, CommandData>::const_iterator commandIt, std::string generateRAIIHandleCommandValue0Return0VectorVkType( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount, size_t initialSkipCount,
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
@ -946,15 +938,8 @@ private:
size_t returnParam, size_t returnParam,
bool unique, bool unique,
bool enumerating ) const; bool enumerating ) const;
std::string generateReturnType( CommandData const & commandData, std::string generateReturnType(
std::vector<size_t> const & returnParams, CommandData const & commandData, std::vector<size_t> const & returnParams, bool unique, bool chained, std::string const & dataType ) const;
#if !defined( NDEBUG )
std::map<size_t, size_t> const & vectorParams,
bool singular,
#endif
bool unique,
bool chained,
std::string const & dataType ) const;
std::string generateReturnVariable( CommandData const & commandData, std::string generateReturnVariable( CommandData const & commandData,
std::vector<size_t> const & returnParams, std::vector<size_t> const & returnParams,
std::map<size_t, size_t> const & vectorParams, std::map<size_t, size_t> const & vectorParams,

View File

@ -10228,12 +10228,14 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE PFN_vkVoidFunction Instance::getProcAddr( const std::string & name ) const VULKAN_HPP_NOEXCEPT VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE PFN_vkVoidFunction Instance::getProcAddr( const std::string & name ) const VULKAN_HPP_NOEXCEPT
{ {
return getDispatcher()->vkGetInstanceProcAddr( static_cast<VkInstance>( m_instance ), name.c_str() ); PFN_vkVoidFunction result = getDispatcher()->vkGetInstanceProcAddr( static_cast<VkInstance>( m_instance ), name.c_str() );
return result;
} }
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE PFN_vkVoidFunction Device::getProcAddr( const std::string & name ) const VULKAN_HPP_NOEXCEPT VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE PFN_vkVoidFunction Device::getProcAddr( const std::string & name ) const VULKAN_HPP_NOEXCEPT
{ {
return getDispatcher()->vkGetDeviceProcAddr( static_cast<VkDevice>( m_device ), name.c_str() ); PFN_vkVoidFunction result = getDispatcher()->vkGetDeviceProcAddr( static_cast<VkDevice>( m_device ), name.c_str() );
return result;
} }
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_RAII_NAMESPACE::Device VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_RAII_NAMESPACE::Device
@ -11887,15 +11889,17 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE uint64_t VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE uint64_t
Device::getBufferOpaqueCaptureAddress( const VULKAN_HPP_NAMESPACE::BufferDeviceAddressInfo & info ) const VULKAN_HPP_NOEXCEPT Device::getBufferOpaqueCaptureAddress( const VULKAN_HPP_NAMESPACE::BufferDeviceAddressInfo & info ) const VULKAN_HPP_NOEXCEPT
{ {
return getDispatcher()->vkGetBufferOpaqueCaptureAddress( static_cast<VkDevice>( m_device ), uint64_t result =
reinterpret_cast<const VkBufferDeviceAddressInfo *>( &info ) ); getDispatcher()->vkGetBufferOpaqueCaptureAddress( static_cast<VkDevice>( m_device ), reinterpret_cast<const VkBufferDeviceAddressInfo *>( &info ) );
return result;
} }
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE uint64_t VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE uint64_t
Device::getMemoryOpaqueCaptureAddress( const VULKAN_HPP_NAMESPACE::DeviceMemoryOpaqueCaptureAddressInfo & info ) const VULKAN_HPP_NOEXCEPT Device::getMemoryOpaqueCaptureAddress( const VULKAN_HPP_NAMESPACE::DeviceMemoryOpaqueCaptureAddressInfo & info ) const VULKAN_HPP_NOEXCEPT
{ {
return getDispatcher()->vkGetDeviceMemoryOpaqueCaptureAddress( static_cast<VkDevice>( m_device ), uint64_t result = getDispatcher()->vkGetDeviceMemoryOpaqueCaptureAddress( static_cast<VkDevice>( m_device ),
reinterpret_cast<const VkDeviceMemoryOpaqueCaptureAddressInfo *>( &info ) ); reinterpret_cast<const VkDeviceMemoryOpaqueCaptureAddressInfo *>( &info ) );
return result;
} }
//=== VK_VERSION_1_3 === //=== VK_VERSION_1_3 ===
@ -13150,7 +13154,9 @@ namespace VULKAN_HPP_NAMESPACE
{ {
VULKAN_HPP_ASSERT( getDispatcher()->vkGetImageViewHandleNVX && "Function <vkGetImageViewHandleNVX> needs extension <VK_NVX_image_view_handle> enabled!" ); VULKAN_HPP_ASSERT( getDispatcher()->vkGetImageViewHandleNVX && "Function <vkGetImageViewHandleNVX> needs extension <VK_NVX_image_view_handle> enabled!" );
return getDispatcher()->vkGetImageViewHandleNVX( static_cast<VkDevice>( m_device ), reinterpret_cast<const VkImageViewHandleInfoNVX *>( &info ) ); uint32_t result =
getDispatcher()->vkGetImageViewHandleNVX( static_cast<VkDevice>( m_device ), reinterpret_cast<const VkImageViewHandleInfoNVX *>( &info ) );
return result;
} }
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::ImageViewAddressPropertiesNVX ImageView::getAddressNVX() const VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::ImageViewAddressPropertiesNVX ImageView::getAddressNVX() const
@ -16167,8 +16173,9 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_ASSERT( getDispatcher()->vkGetBufferOpaqueCaptureAddressKHR && VULKAN_HPP_ASSERT( getDispatcher()->vkGetBufferOpaqueCaptureAddressKHR &&
"Function <vkGetBufferOpaqueCaptureAddressKHR> needs extension <VK_KHR_buffer_device_address> enabled!" ); "Function <vkGetBufferOpaqueCaptureAddressKHR> needs extension <VK_KHR_buffer_device_address> enabled!" );
return getDispatcher()->vkGetBufferOpaqueCaptureAddressKHR( static_cast<VkDevice>( m_device ), uint64_t result =
reinterpret_cast<const VkBufferDeviceAddressInfo *>( &info ) ); getDispatcher()->vkGetBufferOpaqueCaptureAddressKHR( static_cast<VkDevice>( m_device ), reinterpret_cast<const VkBufferDeviceAddressInfo *>( &info ) );
return result;
} }
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE uint64_t VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE uint64_t
@ -16177,8 +16184,9 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_ASSERT( getDispatcher()->vkGetDeviceMemoryOpaqueCaptureAddressKHR && VULKAN_HPP_ASSERT( getDispatcher()->vkGetDeviceMemoryOpaqueCaptureAddressKHR &&
"Function <vkGetDeviceMemoryOpaqueCaptureAddressKHR> needs extension <VK_KHR_buffer_device_address> enabled!" ); "Function <vkGetDeviceMemoryOpaqueCaptureAddressKHR> needs extension <VK_KHR_buffer_device_address> enabled!" );
return getDispatcher()->vkGetDeviceMemoryOpaqueCaptureAddressKHR( static_cast<VkDevice>( m_device ), uint64_t result = getDispatcher()->vkGetDeviceMemoryOpaqueCaptureAddressKHR( static_cast<VkDevice>( m_device ),
reinterpret_cast<const VkDeviceMemoryOpaqueCaptureAddressInfo *>( &info ) ); reinterpret_cast<const VkDeviceMemoryOpaqueCaptureAddressInfo *>( &info ) );
return result;
} }
//=== VK_EXT_line_rasterization === //=== VK_EXT_line_rasterization ===
@ -16341,7 +16349,9 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_ASSERT( getDispatcher()->vkGetDeferredOperationMaxConcurrencyKHR && VULKAN_HPP_ASSERT( getDispatcher()->vkGetDeferredOperationMaxConcurrencyKHR &&
"Function <vkGetDeferredOperationMaxConcurrencyKHR> needs extension <VK_KHR_deferred_host_operations> enabled!" ); "Function <vkGetDeferredOperationMaxConcurrencyKHR> needs extension <VK_KHR_deferred_host_operations> enabled!" );
return getDispatcher()->vkGetDeferredOperationMaxConcurrencyKHR( static_cast<VkDevice>( m_device ), static_cast<VkDeferredOperationKHR>( m_operation ) ); uint32_t result =
getDispatcher()->vkGetDeferredOperationMaxConcurrencyKHR( static_cast<VkDevice>( m_device ), static_cast<VkDeferredOperationKHR>( m_operation ) );
return result;
} }
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::Result DeferredOperationKHR::getResult() const VULKAN_HPP_NOEXCEPT VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::Result DeferredOperationKHR::getResult() const VULKAN_HPP_NOEXCEPT