mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Combine two types of commands into one generation function.
This commit is contained in:
parent
104aee2fd9
commit
4ba01be8d1
@ -3490,71 +3490,6 @@ std::string VulkanHppGenerator::generateCommandResultGetChain(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string VulkanHppGenerator::generateCommandResultGetSingularAndValue( std::string const & name,
|
|
||||||
CommandData const & commandData,
|
|
||||||
size_t initialSkipCount,
|
|
||||||
bool definition,
|
|
||||||
std::vector<size_t> const & returnParams,
|
|
||||||
std::map<size_t, size_t> const & vectorParams ) const
|
|
||||||
{
|
|
||||||
assert( !commandData.handle.empty() && ( commandData.returnType == "VkResult" ) );
|
|
||||||
assert( ( vectorParams.size() == 2 ) && ( returnParams.size() == 2 ) );
|
|
||||||
assert( vectorParams.find( returnParams[0] ) != vectorParams.end() );
|
|
||||||
assert( vectorParams.find( returnParams[1] ) == vectorParams.end() );
|
|
||||||
assert( vectorParams.begin()->second == std::next( vectorParams.begin() )->second );
|
|
||||||
assert( commandData.returnType == "VkResult" );
|
|
||||||
|
|
||||||
std::set<size_t> skippedParams = determineSkippedParams( commandData.params, initialSkipCount, vectorParams, returnParams, false );
|
|
||||||
std::set<size_t> singularParameters = determineSingularParams( returnParams[0], vectorParams );
|
|
||||||
std::string argumentList = generateArgumentListEnhanced( commandData.params, skippedParams, singularParameters, {}, definition, false, false, true );
|
|
||||||
std::string commandName = stripPluralS( generateCommandName( name, commandData.params, initialSkipCount, m_tags, false, false ) );
|
|
||||||
std::string nodiscard = generateNoDiscard( !returnParams.empty(), 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
|
|
||||||
std::string singularElementType = stripPostfix( commandData.params[returnParams[0]].type.compose( "VULKAN_HPP_NAMESPACE" ), " *" );
|
|
||||||
std::string valueType = stripPostfix( commandData.params[returnParams[1]].type.compose( "VULKAN_HPP_NAMESPACE" ), " *" );
|
|
||||||
|
|
||||||
if ( definition )
|
|
||||||
{
|
|
||||||
std::string const functionTemplate =
|
|
||||||
R"( template <typename Dispatch>
|
|
||||||
${nodiscard}VULKAN_HPP_INLINE typename ResultValueType<std::pair<${singularElementType}, ${valueType}>>::type ${className}${classSeparator}${commandName}( ${argumentList} ) const
|
|
||||||
{
|
|
||||||
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
|
|
||||||
std::pair<${singularElementType},${valueType}> data;
|
|
||||||
${singularElementType} & ${singularName} = data.first;
|
|
||||||
${valueType} & ${valueName} = data.second;
|
|
||||||
Result result = static_cast<Result>( d.${vkCommand}( ${callArguments} ) );
|
|
||||||
return createResultValue( result, data, VULKAN_HPP_NAMESPACE_STRING "::${className}${classSeparator}${commandName}"${successCodeList} );
|
|
||||||
})";
|
|
||||||
|
|
||||||
return replaceWithMap( functionTemplate,
|
|
||||||
{ { "argumentList", argumentList },
|
|
||||||
{ "callArguments", generateCallArgumentsEnhanced( commandData, initialSkipCount, false, singularParameters, {}, false ) },
|
|
||||||
{ "className", initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "" },
|
|
||||||
{ "classSeparator", commandData.handle.empty() ? "" : "::" },
|
|
||||||
{ "commandName", commandName },
|
|
||||||
{ "nodiscard", nodiscard },
|
|
||||||
{ "singularElementType", singularElementType },
|
|
||||||
{ "singularName", startLowerCase( stripPluralS( stripPrefix( commandData.params[returnParams[0]].name, "p" ) ) ) },
|
|
||||||
{ "successCodeList", generateSuccessCodeList( commandData.successCodes ) },
|
|
||||||
{ "valueName", startLowerCase( stripPrefix( commandData.params[returnParams[1]].name, "p" ) ) },
|
|
||||||
{ "valueType", valueType },
|
|
||||||
{ "vkCommand", name } } );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string const functionTemplate =
|
|
||||||
R"( template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
|
|
||||||
${nodiscard}typename ResultValueType<std::pair<${singularElementType}, ${valueType}>>::type ${commandName}( ${argumentList} ) const;)";
|
|
||||||
|
|
||||||
return replaceWithMap( functionTemplate,
|
|
||||||
{ { "argumentList", argumentList },
|
|
||||||
{ "commandName", commandName },
|
|
||||||
{ "nodiscard", nodiscard },
|
|
||||||
{ "singularElementType", singularElementType },
|
|
||||||
{ "valueType", valueType } } );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string VulkanHppGenerator::generateCommandResultGetVectorAndValue( std::string const & name,
|
std::string VulkanHppGenerator::generateCommandResultGetVectorAndValue( std::string const & name,
|
||||||
CommandData const & commandData,
|
CommandData const & commandData,
|
||||||
size_t initialSkipCount,
|
size_t initialSkipCount,
|
||||||
@ -4284,7 +4219,7 @@ std::string VulkanHppGenerator::generateCommandResultSingleSuccessWithErrors2Ret
|
|||||||
generateCommandStandard( name, commandData, initialSkipCount, definition ),
|
generateCommandStandard( name, commandData, initialSkipCount, definition ),
|
||||||
generateCommandResultGetVectorAndValue( name, commandData, initialSkipCount, definition, vectorParams, returnParams, false ),
|
generateCommandResultGetVectorAndValue( name, commandData, initialSkipCount, definition, vectorParams, returnParams, false ),
|
||||||
generateCommandResultGetVectorAndValue( name, commandData, initialSkipCount, definition, vectorParams, returnParams, true ),
|
generateCommandResultGetVectorAndValue( name, commandData, initialSkipCount, definition, vectorParams, returnParams, true ),
|
||||||
generateCommandResultGetSingularAndValue( name, commandData, initialSkipCount, definition, returnParams, vectorParams ) );
|
generateCommandSingle( name, commandData, initialSkipCount, definition, vectorParams, returnParams, true, false, false, false ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4560,7 +4495,7 @@ std::string VulkanHppGenerator::generateCommandSingle( std::string const &
|
|||||||
{
|
{
|
||||||
assert( returnParams.size() <= 2 );
|
assert( returnParams.size() <= 2 );
|
||||||
assert( vectorParams.empty() || ( vectorParams.begin()->second != INVALID_INDEX ) );
|
assert( vectorParams.empty() || ( vectorParams.begin()->second != INVALID_INDEX ) );
|
||||||
assert( !singular || ( returnParams.size() == 1 ) ); // if singular is true, then there is one returnParam !
|
assert( !singular || !returnParams.empty() ); // if singular is true, then there is at least one returnParam !
|
||||||
assert( !chained || ( returnParams.size() == 1 ) ); // if chained is true, then there is one returnParam !
|
assert( !chained || ( returnParams.size() == 1 ) ); // if chained is true, then there is one returnParam !
|
||||||
assert( !chained || isStructureChainAnchor( commandData.params[returnParams[0]].type.type ) );
|
assert( !chained || isStructureChainAnchor( commandData.params[returnParams[0]].type.type ) );
|
||||||
|
|
||||||
@ -5129,17 +5064,26 @@ std::string VulkanHppGenerator::generateDataDeclarations( CommandData const &
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
assert( vectorParams.empty() );
|
assert( vectorParams.empty() || singular );
|
||||||
{
|
{
|
||||||
|
std::string dataNames[2];
|
||||||
|
for ( size_t i = 0; i < returnParams.size(); ++i )
|
||||||
|
{
|
||||||
|
dataNames[i] = startLowerCase( stripPrefix( commandData.params[returnParams[i]].name, "p" ) );
|
||||||
|
if ( vectorParams.find( returnParams[i] ) != vectorParams.end() )
|
||||||
|
{
|
||||||
|
assert( singular );
|
||||||
|
dataNames[i] = stripPluralS( dataNames[i] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string const dataDeclarationTemplate = R"(std::pair<${firstDataType},${secondDataType}> data;
|
std::string const dataDeclarationTemplate = R"(std::pair<${firstDataType},${secondDataType}> data;
|
||||||
${firstDataType} & ${firstDataName} = data.first;
|
${firstDataType} & ${firstDataName} = data.first;
|
||||||
${secondDataType} & ${secondDataName} = data.second;)";
|
${secondDataType} & ${secondDataName} = data.second;)";
|
||||||
|
|
||||||
dataDeclarations = replaceWithMap( dataDeclarationTemplate,
|
dataDeclarations = replaceWithMap(
|
||||||
{ { "firstDataName", startLowerCase( stripPrefix( commandData.params[returnParams[0]].name, "p" ) ) },
|
dataDeclarationTemplate,
|
||||||
{ "firstDataType", dataTypes[0] },
|
{ { "firstDataName", dataNames[0] }, { "firstDataType", dataTypes[0] }, { "secondDataName", dataNames[1] }, { "secondDataType", dataTypes[1] } } );
|
||||||
{ "secondDataName", startLowerCase( stripPrefix( commandData.params[returnParams[1]].name, "p" ) ) },
|
|
||||||
{ "secondDataType", dataTypes[1] } } );
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: assert( false ); break;
|
default: assert( false ); break;
|
||||||
@ -10253,8 +10197,10 @@ std::string
|
|||||||
VulkanHppGenerator::generateReturnVariable( CommandData const & commandData, std::vector<size_t> const & returnParams, bool chained, bool singular ) const
|
VulkanHppGenerator::generateReturnVariable( CommandData const & commandData, std::vector<size_t> const & returnParams, bool chained, bool singular ) const
|
||||||
{
|
{
|
||||||
std::string returnVariable;
|
std::string returnVariable;
|
||||||
if ( returnParams.size() == 1 )
|
switch ( returnParams.size() )
|
||||||
{
|
{
|
||||||
|
case 0: break; // no return variable
|
||||||
|
case 1:
|
||||||
if ( chained )
|
if ( chained )
|
||||||
{
|
{
|
||||||
returnVariable = "structureChain";
|
returnVariable = "structureChain";
|
||||||
@ -10267,6 +10213,11 @@ std::string
|
|||||||
returnVariable = stripPluralS( returnVariable );
|
returnVariable = stripPluralS( returnVariable );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case 2: // the return variable is simply named "data", and holds the multi-return value stuff
|
||||||
|
assert( !chained && singular );
|
||||||
|
returnVariable = "data";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return returnVariable;
|
return returnVariable;
|
||||||
}
|
}
|
||||||
|
@ -486,12 +486,6 @@ private:
|
|||||||
bool withAllocators ) const;
|
bool withAllocators ) const;
|
||||||
std::string generateCommandResultGetChain(
|
std::string generateCommandResultGetChain(
|
||||||
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam ) const;
|
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam ) const;
|
||||||
std::string generateCommandResultGetSingularAndValue( std::string const & name,
|
|
||||||
CommandData const & commandData,
|
|
||||||
size_t initialSkipCount,
|
|
||||||
bool definition,
|
|
||||||
std::vector<size_t> const & returnParamIndices,
|
|
||||||
std::map<size_t, size_t> const & vectorParamIndices ) const;
|
|
||||||
std::string generateCommandResultGetVectorAndValue( std::string const & name,
|
std::string generateCommandResultGetVectorAndValue( std::string const & name,
|
||||||
CommandData const & commandData,
|
CommandData const & commandData,
|
||||||
size_t initialSkipCount,
|
size_t initialSkipCount,
|
||||||
|
@ -15228,12 +15228,14 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
Device::getCalibratedTimestampEXT( const VULKAN_HPP_NAMESPACE::CalibratedTimestampInfoEXT & timestampInfo, Dispatch const & d ) const
|
Device::getCalibratedTimestampEXT( const VULKAN_HPP_NAMESPACE::CalibratedTimestampInfoEXT & timestampInfo, Dispatch const & d ) const
|
||||||
{
|
{
|
||||||
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
|
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
|
||||||
|
|
||||||
std::pair<uint64_t, uint64_t> data;
|
std::pair<uint64_t, uint64_t> data;
|
||||||
uint64_t & timestamp = data.first;
|
uint64_t & timestamp = data.first;
|
||||||
uint64_t & maxDeviation = data.second;
|
uint64_t & maxDeviation = data.second;
|
||||||
Result result = static_cast<Result>(
|
VkResult result =
|
||||||
d.vkGetCalibratedTimestampsEXT( m_device, 1, reinterpret_cast<const VkCalibratedTimestampInfoEXT *>( ×tampInfo ), ×tamp, &maxDeviation ) );
|
d.vkGetCalibratedTimestampsEXT( m_device, 1, reinterpret_cast<const VkCalibratedTimestampInfoEXT *>( ×tampInfo ), ×tamp, &maxDeviation );
|
||||||
return createResultValue( result, data, VULKAN_HPP_NAMESPACE_STRING "::Device::getCalibratedTimestampEXT" );
|
resultCheck( static_cast<VULKAN_HPP_NAMESPACE::Result>( result ), VULKAN_HPP_NAMESPACE_STRING "::Device::getCalibratedTimestampEXT" );
|
||||||
|
return createResultValueType( static_cast<VULKAN_HPP_NAMESPACE::Result>( result ), data );
|
||||||
}
|
}
|
||||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user