Combine two types of commands into one generation function.

Generation of functions that get a StructureChain or some value are combined into one function.
This commit is contained in:
asuessenbach 2022-03-14 14:54:56 +01:00
parent e02d19207b
commit f58ffe385f
4 changed files with 147 additions and 173 deletions

View File

@ -3147,7 +3147,7 @@ std::string VulkanHppGenerator::generateCommandResult(
return createResultValue( result, VULKAN_HPP_NAMESPACE_STRING "::${className}${classSeparator}${commandName}"${successCodeList} ); return createResultValue( result, VULKAN_HPP_NAMESPACE_STRING "::${className}${classSeparator}${commandName}"${successCodeList} );
})"; })";
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandData.params, vectorParams, {} );
return replaceWithMap( return replaceWithMap(
functionTemplate, functionTemplate,
{ { "argumentList", argumentList }, { { "argumentList", argumentList },
@ -3712,7 +3712,7 @@ std::string VulkanHppGenerator::generateCommandResultGetValue( std::string const
{ {
dataVariable = stripPluralS( dataVariable ); dataVariable = stripPluralS( dataVariable );
} }
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, singularParams ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandData.params, vectorParams, singularParams );
return replaceWithMap( return replaceWithMap(
functionTemplate, functionTemplate,
@ -4880,7 +4880,7 @@ std::string VulkanHppGenerator::generateCommandSingle(
std::string chainTemplate = ""; std::string chainTemplate = "";
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags ); std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags );
std::string nodiscard = generateNoDiscard( 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() ); std::string nodiscard = generateNoDiscard( 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandData.params, vectorParams, {} );
std::string noexceptString = vectorSizeCheck.first ? " VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : " VULKAN_HPP_NOEXCEPT"; std::string noexceptString = vectorSizeCheck.first ? " VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : " VULKAN_HPP_NOEXCEPT";
std::string returnType = ( commandData.returnType == "void" ) ? "void" : stripPrefix( commandData.returnType, "Vk" ); std::string returnType = ( commandData.returnType == "void" ) ? "void" : stripPrefix( commandData.returnType, "Vk" );
std::string returnCall = ( returnType == "void" ) ? "" : "return "; std::string returnCall = ( returnType == "void" ) ? "" : "return ";
@ -5041,7 +5041,7 @@ std::string VulkanHppGenerator::generateCommandVoid1Return(
{ {
return generateCommandSetStandardEnhanced( definition, return generateCommandSetStandardEnhanced( definition,
generateCommandStandard( name, commandData, initialSkipCount, definition ), generateCommandStandard( name, commandData, initialSkipCount, definition ),
generateCommandVoidGetValue( name, commandData, initialSkipCount, definition, {}, returnParam ) ); generateCommandVoidGetValue( name, commandData, initialSkipCount, definition, {}, returnParam, false ) );
} }
} }
} }
@ -5052,7 +5052,7 @@ std::string VulkanHppGenerator::generateCommandVoid1Return(
{ {
return generateCommandSetStandardEnhanced( definition, return generateCommandSetStandardEnhanced( definition,
generateCommandStandard( name, commandData, initialSkipCount, definition ), generateCommandStandard( name, commandData, initialSkipCount, definition ),
generateCommandVoidGetValue( name, commandData, initialSkipCount, definition, {}, returnParam ) ); generateCommandVoidGetValue( name, commandData, initialSkipCount, definition, {}, returnParam, false ) );
} }
} }
else if ( isStructureChainAnchor( commandData.params[returnParam].type.type ) ) else if ( isStructureChainAnchor( commandData.params[returnParam].type.type ) )
@ -5062,8 +5062,8 @@ std::string VulkanHppGenerator::generateCommandVoid1Return(
{ {
return generateCommandSetStandardEnhancedChained( definition, return generateCommandSetStandardEnhancedChained( definition,
generateCommandStandard( name, commandData, initialSkipCount, definition ), generateCommandStandard( name, commandData, initialSkipCount, definition ),
generateCommandVoidGetValue( name, commandData, initialSkipCount, definition, {}, returnParam ), generateCommandVoidGetValue( name, commandData, initialSkipCount, definition, {}, returnParam, false ),
generateCommandVoidGetChain( name, commandData, initialSkipCount, definition, returnParam ) ); generateCommandVoidGetValue( name, commandData, initialSkipCount, definition, {}, returnParam, true ) );
} }
} }
else if ( commandData.params[returnParam].type.type != "void" ) else if ( commandData.params[returnParam].type.type != "void" )
@ -5074,7 +5074,7 @@ std::string VulkanHppGenerator::generateCommandVoid1Return(
case 0: case 0:
return generateCommandSetStandardEnhanced( definition, return generateCommandSetStandardEnhanced( definition,
generateCommandStandard( name, commandData, initialSkipCount, definition ), generateCommandStandard( name, commandData, initialSkipCount, definition ),
generateCommandVoidGetValue( name, commandData, initialSkipCount, definition, {}, returnParam ) ); generateCommandVoidGetValue( name, commandData, initialSkipCount, definition, {}, returnParam, false ) );
break; break;
case 1: case 1:
if ( returnParam != vectorParams.begin()->first ) if ( returnParam != vectorParams.begin()->first )
@ -5088,7 +5088,7 @@ std::string VulkanHppGenerator::generateCommandVoid1Return(
return generateCommandSetStandardEnhanced( return generateCommandSetStandardEnhanced(
definition, definition,
generateCommandStandard( name, commandData, initialSkipCount, definition ), generateCommandStandard( name, commandData, initialSkipCount, definition ),
generateCommandVoidGetValue( name, commandData, initialSkipCount, definition, vectorParams, returnParam ) ); generateCommandVoidGetValue( name, commandData, initialSkipCount, definition, vectorParams, returnParam, false ) );
} }
} }
} }
@ -5298,79 +5298,13 @@ std::string VulkanHppGenerator::generateCommandVoidEnumerateChained( std::string
} }
} }
std::string VulkanHppGenerator::generateCommandVoidGetChain(
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam ) const
{
assert( ( commandData.returnType == "void" ) && commandData.successCodes.empty() && commandData.errorCodes.empty() );
std::set<size_t> skippedParams = determineSkippedParams( commandData.params, initialSkipCount, {}, { returnParam }, false );
std::set<size_t> templatedParams = determineVoidPointerParams( commandData.params );
std::string argumentList = generateArgumentListEnhanced( commandData.params, skippedParams, {}, templatedParams, definition, false, false, true );
std::string argumentTemplates = generateArgumentTemplates( commandData.params, templatedParams, false );
std::string chainTemplates = "typename X, typename Y, typename... Z, ";
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags );
std::string nodiscard = generateNoDiscard( 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
std::string noexceptString = commandData.errorCodes.empty() ? " VULKAN_HPP_NOEXCEPT" : "";
std::string returnType = "StructureChain<X, Y, Z...>";
if ( definition )
{
std::string const functionTemplate =
R"( template <${argumentTemplates}${chainTemplates}typename Dispatch>
${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}${classSeparator}${commandName}( ${argumentList} )${const}${noexcept}
{
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );${vectorSizeCheck}
${returnType} structureChain;
${dataType} & ${dataVariable} = structureChain.template get<${dataType}>();
d.${vkCommand}( ${callArguments} );
return structureChain;
})";
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( {}, {} );
return replaceWithMap(
functionTemplate,
{ { "argumentList", argumentList },
{ "argumentTemplates", argumentTemplates },
{ "callArguments", generateCallArgumentsEnhanced( commandData, initialSkipCount, false, {}, templatedParams, false ) },
{ "chainTemplates", chainTemplates },
{ "className", initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "" },
{ "classSeparator", commandData.handle.empty() ? "" : "::" },
{ "commandName", commandName },
{ "const", commandData.handle.empty() ? "" : " const" },
{ "dataType", stripPostfix( commandData.params[returnParam].type.compose( "VULKAN_HPP_NAMESPACE" ), " *" ) },
{ "dataVariable", startLowerCase( stripPrefix( commandData.params[returnParam].name, "p" ) ) },
{ "nodiscard", "VULKAN_HPP_NODISCARD " },
{ "noexcept", noexceptString },
{ "returnType", returnType },
{ "vectorSizeCheck",
vectorSizeCheck.first ? generateVectorSizeCheck( name, commandData, initialSkipCount, vectorSizeCheck.second, skippedParams ) : "" },
{ "vkCommand", name } } );
}
else
{
std::string const functionTemplate =
R"( template <${argumentTemplates}${chainTemplates}typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
${nodiscard}${returnType} ${commandName}( ${argumentList} )${const}${noexcept};)";
return replaceWithMap( functionTemplate,
{ { "argumentList", argumentList },
{ "argumentTemplates", argumentTemplates },
{ "chainTemplates", chainTemplates },
{ "commandName", commandName },
{ "const", commandData.handle.empty() ? "" : " const" },
{ "nodiscard", "VULKAN_HPP_NODISCARD " },
{ "noexcept", noexceptString },
{ "returnType", returnType } } );
}
}
std::string VulkanHppGenerator::generateCommandVoidGetValue( std::string const & name, std::string VulkanHppGenerator::generateCommandVoidGetValue( std::string const & name,
CommandData const & commandData, CommandData const & commandData,
size_t initialSkipCount, size_t initialSkipCount,
bool definition, bool definition,
std::map<size_t, size_t> const & vectorParams, std::map<size_t, size_t> const & vectorParams,
size_t returnParam ) const size_t returnParam,
bool chained ) const
{ {
assert( ( commandData.returnType == "void" ) && commandData.successCodes.empty() && commandData.errorCodes.empty() ); assert( ( commandData.returnType == "void" ) && commandData.successCodes.empty() && commandData.errorCodes.empty() );
assert( vectorParams.size() <= 1 ); assert( vectorParams.size() <= 1 );
@ -5381,41 +5315,51 @@ std::string VulkanHppGenerator::generateCommandVoidGetValue( std::string const &
std::set<size_t> templatedParams = determineVoidPointerParams( commandData.params ); std::set<size_t> templatedParams = determineVoidPointerParams( commandData.params );
std::string argumentList = generateArgumentListEnhanced( commandData.params, skippedParams, {}, templatedParams, definition, false, false, true ); std::string argumentList = generateArgumentListEnhanced( commandData.params, skippedParams, {}, templatedParams, definition, false, false, true );
std::string argumentTemplates = generateArgumentTemplates( commandData.params, templatedParams, false ); std::string argumentTemplates = generateArgumentTemplates( commandData.params, templatedParams, false );
std::string chainTemplate = "";
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags ); std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags );
std::string returnType = stripPostfix( commandData.params[returnParam].type.compose( "VULKAN_HPP_NAMESPACE" ), "*" ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandData.params, vectorParams, {} );
bool needsVectorSizeCheck = std::string noexceptString = vectorSizeCheck.first ? " VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : " VULKAN_HPP_NOEXCEPT";
!vectorParams.empty() && isLenByStructMember( commandData.params[vectorParams.begin()->first].len, commandData.params[vectorParams.begin()->second] );
std::string noexceptString = needsVectorSizeCheck ? " VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : " VULKAN_HPP_NOEXCEPT"; std::string chainTemplates, returnType;
if ( chained )
{
assert( isStructureChainAnchor( commandData.params[returnParam].type.type ) );
chainTemplates = "typename X, typename Y, typename... Z, ";
returnType = "StructureChain<X, Y, Z...>";
}
else
{
returnType = stripPostfix( commandData.params[returnParam].type.compose( "VULKAN_HPP_NAMESPACE" ), "*" );
}
if ( definition ) if ( definition )
{ {
std::string chainData, returnVariable;
if ( chained )
{
returnVariable = "structureChain";
std::string const chainDataTemplate = R"(
${dataType} & ${dataVariable} = ${returnVariable}.template get<${dataType}>();)";
chainData = replaceWithMap( chainDataTemplate,
{
{ "dataType", stripPostfix( commandData.params[returnParam].type.compose( "VULKAN_HPP_NAMESPACE" ), " *" ) },
{ "dataVariable", startLowerCase( stripPrefix( commandData.params[returnParam].name, "p" ) ) },
{ "returnVariable", returnVariable },
} );
}
else
{
returnVariable = startLowerCase( stripPrefix( commandData.params[returnParam].name, "p" ) );
}
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 vectorSizeCheck; std::string vectorSizeCheckString;
if ( needsVectorSizeCheck ) if ( vectorSizeCheck.first )
{ {
std::string const sizeCheckTemplate = vectorSizeCheckString = generateVectorSizeCheck( name, commandData, initialSkipCount, vectorSizeCheck.second, skippedParams );
R"(
#ifdef VULKAN_HPP_NO_EXCEPTIONS
VULKAN_HPP_ASSERT( ${vectorName}.size() == ${sizeValue} );
#else
if ( ${vectorName}.size() != ${sizeValue} )
{
throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::${className}${classSeparator}${commandName}: ${vectorName}.size() != ${sizeValue}" );
}
#endif /*VULKAN_HPP_NO_EXCEPTIONS*/)";
std::vector<std::string> lenParts = tokenize( commandData.params[vectorParams.begin()->first].len, "->" );
assert( lenParts.size() == 2 );
vectorSizeCheck = replaceWithMap( sizeCheckTemplate,
{ { "className", className },
{ "classSeparator", classSeparator },
{ "commandName", commandName },
{ "sizeValue", startLowerCase( stripPrefix( lenParts[0], "p" ) ) + "." + lenParts[1] },
{ "vectorName", startLowerCase( stripPrefix( commandData.params[vectorParams.begin()->first].name, "p" ) ) } } );
} }
std::string const functionTemplate = std::string const functionTemplate =
@ -5423,7 +5367,7 @@ std::string VulkanHppGenerator::generateCommandVoidGetValue( std::string const &
${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}${classSeparator}${commandName}( ${argumentList} )${const}${noexcept} ${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}${classSeparator}${commandName}( ${argumentList} )${const}${noexcept}
{ {
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );${vectorSizeCheck} VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );${vectorSizeCheck}
${returnType} ${returnVariable}; ${returnType} ${returnVariable};${chainData}
d.${vkCommand}( ${callArguments} ); d.${vkCommand}( ${callArguments} );
return ${returnVariable}; return ${returnVariable};
})"; })";
@ -5432,7 +5376,8 @@ std::string VulkanHppGenerator::generateCommandVoidGetValue( std::string const &
{ { "argumentList", argumentList }, { { "argumentList", argumentList },
{ "argumentTemplates", argumentTemplates }, { "argumentTemplates", argumentTemplates },
{ "callArguments", generateCallArgumentsEnhanced( commandData, initialSkipCount, false, {}, templatedParams, false ) }, { "callArguments", generateCallArgumentsEnhanced( commandData, initialSkipCount, false, {}, templatedParams, false ) },
{ "chainTemplates", chainTemplate }, { "chainData", chainData },
{ "chainTemplates", chainTemplates },
{ "className", className }, { "className", className },
{ "classSeparator", classSeparator }, { "classSeparator", classSeparator },
{ "commandName", commandName }, { "commandName", commandName },
@ -5440,8 +5385,8 @@ std::string VulkanHppGenerator::generateCommandVoidGetValue( std::string const &
{ "nodiscard", "VULKAN_HPP_NODISCARD " }, { "nodiscard", "VULKAN_HPP_NODISCARD " },
{ "noexcept", noexceptString }, { "noexcept", noexceptString },
{ "returnType", returnType }, { "returnType", returnType },
{ "returnVariable", startLowerCase( stripPrefix( commandData.params[returnParam].name, "p" ) ) }, { "returnVariable", returnVariable },
{ "vectorSizeCheck", vectorSizeCheck }, { "vectorSizeCheck", vectorSizeCheckString },
{ "vkCommand", name } } ); { "vkCommand", name } } );
} }
else else
@ -5453,7 +5398,7 @@ std::string VulkanHppGenerator::generateCommandVoidGetValue( std::string const &
return replaceWithMap( functionTemplate, return replaceWithMap( functionTemplate,
{ { "argumentList", argumentList }, { { "argumentList", argumentList },
{ "argumentTemplates", argumentTemplates }, { "argumentTemplates", argumentTemplates },
{ "chainTemplates", chainTemplate }, { "chainTemplates", chainTemplates },
{ "commandName", commandName }, { "commandName", commandName },
{ "const", commandData.handle.empty() ? "" : " const" }, { "const", commandData.handle.empty() ? "" : " const" },
{ "nodiscard", "VULKAN_HPP_NODISCARD " }, { "nodiscard", "VULKAN_HPP_NODISCARD " },
@ -6750,7 +6695,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultMultiSuccessNoErr
)"; )";
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true ); std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandIt->second.params, vectorParams, {} );
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 )
: ""; : "";
@ -6824,7 +6769,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultMultiSuccessWithE
)"; )";
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true ); std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandIt->second.params, vectorParams, {} );
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 )
: ""; : "";
@ -7480,7 +7425,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessNoEr
)"; )";
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true ); std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandIt->second.params, vectorParams, {} );
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 )
: ""; : "";
@ -7553,7 +7498,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWith
)"; )";
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true ); std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandIt->second.params, vectorParams, {} );
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 )
: ""; : "";
@ -8274,7 +8219,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandValue0Return0VectorType
)"; )";
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true ); std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandIt->second.params, vectorParams, {} );
std::string vectorSizeCheckString = std::string vectorSizeCheckString =
vectorSizeCheck.first ? generateVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams ) : ""; vectorSizeCheck.first ? generateVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams ) : "";
@ -8327,7 +8272,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandValue0Return0VectorVkTy
)"; )";
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true ); std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandIt->second.params, vectorParams, {} );
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 )
: ""; : "";
@ -8435,7 +8380,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandVoid0Return( std::map<s
std::set<size_t> templatedParams = determineVoidPointerParams( commandIt->second.params ); std::set<size_t> templatedParams = determineVoidPointerParams( commandIt->second.params );
std::string argumentList = generateArgumentListEnhanced( commandIt->second.params, skippedParams, {}, templatedParams, definition, false, false, false ); std::string argumentList = generateArgumentListEnhanced( commandIt->second.params, skippedParams, {}, templatedParams, definition, false, false, false );
std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags ); std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( 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_WHEN_NO_EXCEPTIONS" : "VULKAN_HPP_NOEXCEPT"; std::string noexceptString = vectorSizeCheck.first ? "VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : "VULKAN_HPP_NOEXCEPT";
std::string argumentTemplates = generateArgumentTemplates( commandIt->second.params, templatedParams, true ); std::string argumentTemplates = generateArgumentTemplates( commandIt->second.params, templatedParams, true );
@ -8541,7 +8486,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandVoid1ReturnValue( std::
std::string argumentList = generateArgumentListEnhanced( commandIt->second.params, skippedParams, {}, {}, definition, false, false, false ); std::string argumentList = generateArgumentListEnhanced( commandIt->second.params, skippedParams, {}, {}, definition, false, false, false );
std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags ); std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags );
std::string returnType = stripPostfix( commandIt->second.params[returnParam].type.compose( "VULKAN_HPP_NAMESPACE" ), "*" ); std::string returnType = stripPostfix( commandIt->second.params[returnParam].type.compose( "VULKAN_HPP_NAMESPACE" ), "*" );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( 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_WHEN_NO_EXCEPTIONS" : "VULKAN_HPP_NOEXCEPT"; std::string noexceptString = vectorSizeCheck.first ? "VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : "VULKAN_HPP_NOEXCEPT";
if ( definition ) if ( definition )
@ -11180,11 +11125,10 @@ std::string VulkanHppGenerator::generateVectorSizeCheck( std::string const &
std::map<size_t, std::vector<size_t>> const & countToVectorMap, std::map<size_t, std::vector<size_t>> const & countToVectorMap,
std::set<size_t> const & skippedParams ) const std::set<size_t> const & skippedParams ) const
{ {
std::string str;
std::string const assertTemplate = " VULKAN_HPP_ASSERT( ${zeroSizeCheck}${firstVectorName}.size() == ${secondVectorName}.size() );"; std::string const assertTemplate = " VULKAN_HPP_ASSERT( ${zeroSizeCheck}${firstVectorName}.size() == ${secondVectorName}.size() );";
std::string const assertTemplateVoid = std::string const assertTemplateVoid =
" VULKAN_HPP_ASSERT( ${zeroSizeCheck}${firstVectorName}.size() * sizeof( ${firstDataType} ) == ${secondVectorName}.size() * sizeof( ${secondDataType} ) );"; " VULKAN_HPP_ASSERT( ${zeroSizeCheck}${firstVectorName}.size() * sizeof( ${firstDataType} ) == ${secondVectorName}.size() * sizeof( ${secondDataType} ) );";
std::string const assertTemplateByLen = " VULKAN_HPP_ASSERT( ${vectorName}.size() == ${sizeValue} );";
std::string const throwTemplate = std::string const throwTemplate =
R"#( if ( ${zeroSizeCheck}${firstVectorName}.size() != ${secondVectorName}.size() ) R"#( if ( ${zeroSizeCheck}${firstVectorName}.size() != ${secondVectorName}.size() )
{ {
@ -11195,17 +11139,33 @@ std::string VulkanHppGenerator::generateVectorSizeCheck( std::string const &
{ {
throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}: ${firstVectorName}.size() * sizeof( ${firstDataType} ) != ${secondVectorName}.size() * sizeof( ${secondDataType} )" ); throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}: ${firstVectorName}.size() * sizeof( ${firstDataType} ) != ${secondVectorName}.size() * sizeof( ${secondDataType} )" );
})#"; })#";
std::string const throwTemplateByLen = R"#( if ( ${vectorName}.size() != ${sizeValue} )
{
throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}: ${vectorName}.size() != ${sizeValue}" );
})#";
std::string className = stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" );
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags ); std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags );
std::string assertions, throws; std::string assertions, throws;
for ( auto const & cvm : countToVectorMap ) for ( auto const & cvm : countToVectorMap )
{ {
assert( !commandData.params[cvm.second[0]].optional );
size_t defaultStartIndex = determineDefaultStartIndex( commandData.params, skippedParams ); size_t defaultStartIndex = determineDefaultStartIndex( commandData.params, skippedParams );
std::string firstVectorName = startLowerCase( stripPrefix( commandData.params[cvm.second[0]].name, "p" ) ); std::string firstVectorName = startLowerCase( stripPrefix( commandData.params[cvm.second[0]].name, "p" ) );
if ( cvm.second.size() == 1 )
{
assert( isLenByStructMember( commandData.params[cvm.second[0]].len, commandData.params[cvm.first] ) );
std::vector<std::string> lenParts = tokenize( commandData.params[cvm.second[0]].len, "->" );
assert( lenParts.size() == 2 );
std::string sizeValue = startLowerCase( stripPrefix( lenParts[0], "p" ) ) + "." + lenParts[1];
assertions += replaceWithMap( assertTemplateByLen, { { "sizeValue", sizeValue }, { "vectorName", firstVectorName } } );
throws += replaceWithMap( throwTemplateByLen,
{ { "className", className }, { "commandName", commandName }, { "sizeValue", sizeValue }, { "vectorName", firstVectorName } } );
}
else
{
for ( size_t i = 1; i < cvm.second.size(); i++ ) for ( size_t i = 1; i < cvm.second.size(); i++ )
{ {
std::string secondVectorName = startLowerCase( stripPrefix( commandData.params[cvm.second[i]].name, "p" ) ); std::string secondVectorName = startLowerCase( stripPrefix( commandData.params[cvm.second[i]].name, "p" ) );
@ -11224,7 +11184,7 @@ std::string VulkanHppGenerator::generateVectorSizeCheck( std::string const &
throws += replaceWithMap( throwTemplateVoid, throws += replaceWithMap( throwTemplateVoid,
{ { "firstDataType", firstDataType }, { { "firstDataType", firstDataType },
{ "firstVectorName", firstVectorName }, { "firstVectorName", firstVectorName },
{ "className", stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) }, { "className", className },
{ "commandName", commandName }, { "commandName", commandName },
{ "secondDataType", secondDataType }, { "secondDataType", secondDataType },
{ "secondVectorName", secondVectorName }, { "secondVectorName", secondVectorName },
@ -11238,7 +11198,7 @@ std::string VulkanHppGenerator::generateVectorSizeCheck( std::string const &
{ "zeroSizeCheck", withZeroSizeCheck ? ( secondVectorName + ".empty() || " ) : "" } } ); { "zeroSizeCheck", withZeroSizeCheck ? ( secondVectorName + ".empty() || " ) : "" } } );
throws += replaceWithMap( throwTemplate, throws += replaceWithMap( throwTemplate,
{ { "firstVectorName", firstVectorName }, { { "firstVectorName", firstVectorName },
{ "className", stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) }, { "className", className },
{ "commandName", commandName }, { "commandName", commandName },
{ "secondVectorName", secondVectorName }, { "secondVectorName", secondVectorName },
{ "zeroSizeCheck", withZeroSizeCheck ? ( "!" + secondVectorName + ".empty() && " ) : "" } } ); { "zeroSizeCheck", withZeroSizeCheck ? ( "!" + secondVectorName + ".empty() && " ) : "" } } );
@ -11250,6 +11210,7 @@ std::string VulkanHppGenerator::generateVectorSizeCheck( std::string const &
} }
} }
} }
}
std::string const sizeCheckTemplate = std::string const sizeCheckTemplate =
R"#( R"#(
@ -11260,9 +11221,7 @@ ${throws}
#endif /*VULKAN_HPP_NO_EXCEPTIONS*/ #endif /*VULKAN_HPP_NO_EXCEPTIONS*/
)#"; )#";
str = replaceWithMap( sizeCheckTemplate, { { "assertions", assertions }, { "throws", throws } } ); return replaceWithMap( sizeCheckTemplate, { { "assertions", assertions }, { "throws", throws } } );
return str;
} }
std::pair<std::string, std::string> VulkanHppGenerator::getParentTypeAndName( std::pair<std::string, HandleData> const & handle ) const std::pair<std::string, std::string> VulkanHppGenerator::getParentTypeAndName( std::pair<std::string, HandleData> const & handle ) const
@ -11466,19 +11425,24 @@ bool VulkanHppGenerator::isStructureChainAnchor( std::string const & type ) cons
return false; return false;
} }
std::pair<bool, std::map<size_t, std::vector<size_t>>> VulkanHppGenerator::needsVectorSizeCheck( std::map<size_t, size_t> const & vectorParams, std::pair<bool, std::map<size_t, std::vector<size_t>>> VulkanHppGenerator::needsVectorSizeCheck( std::vector<ParamData> const & params,
std::map<size_t, size_t> const & vectorParams,
std::set<size_t> const & singularParams ) const std::set<size_t> const & singularParams ) const
{ {
std::map<size_t, std::vector<size_t>> countToVectorMap; std::map<size_t, std::vector<size_t>> countToVectorMap;
for ( auto const & vpi : vectorParams ) for ( auto const & vpi : vectorParams )
{ {
if ( vpi.second != INVALID_INDEX && ( singularParams.find( vpi.second ) == singularParams.end() ) ) if ( vpi.second != INVALID_INDEX &&
( ( singularParams.find( vpi.second ) == singularParams.end() ) || isLenByStructMember( params[vpi.first].len, params[vpi.second] ) ) )
{ {
countToVectorMap[vpi.second].push_back( vpi.first ); countToVectorMap[vpi.second].push_back( vpi.first );
} }
} }
return std::make_pair( std::find_if( countToVectorMap.begin(), countToVectorMap.end(), []( auto const & cvm ) { return 1 < cvm.second.size(); } ) != return std::make_pair( std::find_if( countToVectorMap.begin(),
countToVectorMap.end(), countToVectorMap.end(),
[this, &params]( auto const & cvm ) {
return ( 1 < cvm.second.size() ) || isLenByStructMember( params[cvm.second[0]].len, params[cvm.first] );
} ) != countToVectorMap.end(),
countToVectorMap ); countToVectorMap );
} }

View File

@ -648,14 +648,13 @@ private:
std::pair<size_t, size_t> const & vectorParamIndex, std::pair<size_t, size_t> const & vectorParamIndex,
std::vector<size_t> const & returnParamIndices, std::vector<size_t> const & returnParamIndices,
bool withAllocators ) const; bool withAllocators ) const;
std::string generateCommandVoidGetChain(
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t nonConstPointerIndex ) const;
std::string generateCommandVoidGetValue( std::string const & name, std::string generateCommandVoidGetValue( std::string const & name,
CommandData const & commandData, CommandData const & commandData,
size_t initialSkipCount, size_t initialSkipCount,
bool definition, bool definition,
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
size_t returnParam ) const; size_t returnParam,
bool chained ) const;
std::string generateConstexprString( std::string const & structName ) const; std::string generateConstexprString( std::string const & structName ) const;
std::string generateDestroyCommand( std::string const & name, CommandData const & commandData ) const; std::string generateDestroyCommand( std::string const & name, CommandData const & commandData ) const;
std::string std::string
@ -972,7 +971,8 @@ private:
bool isParam( std::string const & name, std::vector<ParamData> const & params ) const; bool isParam( std::string const & name, std::vector<ParamData> const & params ) const;
bool isStructMember( std::string const & name, std::vector<MemberData> const & memberData ) const; bool isStructMember( std::string const & name, std::vector<MemberData> const & memberData ) const;
bool isStructureChainAnchor( std::string const & type ) const; bool isStructureChainAnchor( std::string const & type ) const;
std::pair<bool, std::map<size_t, std::vector<size_t>>> needsVectorSizeCheck( std::map<size_t, size_t> const & vectorParamIndices, std::pair<bool, std::map<size_t, std::vector<size_t>>> needsVectorSizeCheck( std::vector<ParamData> const & params,
std::map<size_t, size_t> const & vectorParamIndices,
std::set<size_t> const & singularParams ) const; std::set<size_t> const & singularParams ) const;
void readCommands( tinyxml2::XMLElement const * element ); void readCommands( tinyxml2::XMLElement const * element );
void readCommandsCommand( tinyxml2::XMLElement const * element ); void readCommandsCommand( tinyxml2::XMLElement const * element );

View File

@ -13344,6 +13344,7 @@ namespace VULKAN_HPP_NAMESPACE
throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::Device::getAccelerationStructureBuildSizesKHR: maxPrimitiveCounts.size() != buildInfo.geometryCount" ); throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::Device::getAccelerationStructureBuildSizesKHR: maxPrimitiveCounts.size() != buildInfo.geometryCount" );
} }
# endif /*VULKAN_HPP_NO_EXCEPTIONS*/ # endif /*VULKAN_HPP_NO_EXCEPTIONS*/
VULKAN_HPP_NAMESPACE::AccelerationStructureBuildSizesInfoKHR sizeInfo; VULKAN_HPP_NAMESPACE::AccelerationStructureBuildSizesInfoKHR sizeInfo;
d.vkGetAccelerationStructureBuildSizesKHR( m_device, d.vkGetAccelerationStructureBuildSizesKHR( m_device,
static_cast<VkAccelerationStructureBuildTypeKHR>( buildType ), static_cast<VkAccelerationStructureBuildTypeKHR>( buildType ),

View File

@ -3517,7 +3517,7 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NODISCARD VULKAN_HPP_NAMESPACE::AccelerationStructureBuildSizesInfoKHR getAccelerationStructureBuildSizesKHR( VULKAN_HPP_NODISCARD VULKAN_HPP_NAMESPACE::AccelerationStructureBuildSizesInfoKHR getAccelerationStructureBuildSizesKHR(
VULKAN_HPP_NAMESPACE::AccelerationStructureBuildTypeKHR buildType, VULKAN_HPP_NAMESPACE::AccelerationStructureBuildTypeKHR buildType,
const VULKAN_HPP_NAMESPACE::AccelerationStructureBuildGeometryInfoKHR & buildInfo, const VULKAN_HPP_NAMESPACE::AccelerationStructureBuildGeometryInfoKHR & buildInfo,
ArrayProxy<const uint32_t> const & maxPrimitiveCounts VULKAN_HPP_DEFAULT_ARGUMENT_NULLPTR_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT; ArrayProxy<const uint32_t> const & maxPrimitiveCounts VULKAN_HPP_DEFAULT_ARGUMENT_NULLPTR_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS;
//=== VK_KHR_sampler_ycbcr_conversion === //=== VK_KHR_sampler_ycbcr_conversion ===
@ -15014,11 +15014,20 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::AccelerationStructureBuildSizesInfoKHR VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::AccelerationStructureBuildSizesInfoKHR
Device::getAccelerationStructureBuildSizesKHR( VULKAN_HPP_NAMESPACE::AccelerationStructureBuildTypeKHR buildType, Device::getAccelerationStructureBuildSizesKHR( VULKAN_HPP_NAMESPACE::AccelerationStructureBuildTypeKHR buildType,
const VULKAN_HPP_NAMESPACE::AccelerationStructureBuildGeometryInfoKHR & buildInfo, const VULKAN_HPP_NAMESPACE::AccelerationStructureBuildGeometryInfoKHR & buildInfo,
ArrayProxy<const uint32_t> const & maxPrimitiveCounts ) const VULKAN_HPP_NOEXCEPT ArrayProxy<const uint32_t> const & maxPrimitiveCounts ) const VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS
{ {
VULKAN_HPP_ASSERT( getDispatcher()->vkGetAccelerationStructureBuildSizesKHR && VULKAN_HPP_ASSERT( getDispatcher()->vkGetAccelerationStructureBuildSizesKHR &&
"Function <vkGetAccelerationStructureBuildSizesKHR> needs extension <VK_KHR_acceleration_structure> enabled!" ); "Function <vkGetAccelerationStructureBuildSizesKHR> needs extension <VK_KHR_acceleration_structure> enabled!" );
# ifdef VULKAN_HPP_NO_EXCEPTIONS
VULKAN_HPP_ASSERT( maxPrimitiveCounts.size() == buildInfo.geometryCount );
# else
if ( maxPrimitiveCounts.size() != buildInfo.geometryCount )
{
throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::Device::getAccelerationStructureBuildSizesKHR: maxPrimitiveCounts.size() != buildInfo.geometryCount" );
}
# endif /*VULKAN_HPP_NO_EXCEPTIONS*/
VULKAN_HPP_NAMESPACE::AccelerationStructureBuildSizesInfoKHR sizeInfo; VULKAN_HPP_NAMESPACE::AccelerationStructureBuildSizesInfoKHR sizeInfo;
getDispatcher()->vkGetAccelerationStructureBuildSizesKHR( static_cast<VkDevice>( m_device ), getDispatcher()->vkGetAccelerationStructureBuildSizesKHR( static_cast<VkDevice>( m_device ),
static_cast<VkAccelerationStructureBuildTypeKHR>( buildType ), static_cast<VkAccelerationStructureBuildTypeKHR>( buildType ),