Merge pull request #766 from asuessenbach/refactor

Refactor functions returning a vector of handles.
This commit is contained in:
Andreas Süßenbach 2020-10-08 12:56:32 +02:00 committed by GitHub
commit 7fc9c190e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 503 additions and 186 deletions

View File

@ -1311,14 +1311,21 @@ void VulkanHppGenerator::appendCommand( std::string & str,
{ {
// the return parameter is the only vector parameter // the return parameter is the only vector parameter
auto vectorParamIndexIt = vectorParamIndices.begin(); auto vectorParamIndexIt = vectorParamIndices.begin();
assert( vectorParamIndexIt->first == *nonConstPointerParamIndices.begin() ); assert( vectorParamIndexIt->first == nonConstPointerParamIndices[0] );
assert( commandData.params[vectorParamIndexIt->second].type.isValue() ); if ( isHandleType( commandData.params[nonConstPointerParamIndices[0]].type.type ) )
if ( commandData.params[vectorParamIndexIt->first].type.type == "void" ) {
assert( isParamIndirect( commandData.params[vectorParamIndexIt->first].len,
commandData.params[vectorParamIndexIt->second] ) );
appendCommandGetVectorOfHandles( str, name, commandData, *vectorParamIndexIt, definition );
}
else
{ {
// the size of the vector parameter is given by a value -> just get that stuff // the size of the vector parameter is given by a value -> just get that stuff
appendCommandGetVector( str, name, commandData, vectorParamIndices, definition ); assert( commandData.params[vectorParamIndexIt->first].type.type == "void" );
appendedFunction = true; assert( commandData.params[vectorParamIndexIt->second].type.isValue() );
appendCommandGetVector( str, name, commandData, *vectorParamIndexIt, definition );
} }
appendedFunction = true;
} }
break; break;
default: break; default: break;
@ -1767,14 +1774,13 @@ ${leave})";
{ "newlineOnDefinition", definition ? "\n" : "" } } ) ); { "newlineOnDefinition", definition ? "\n" : "" } } ) );
} }
void VulkanHppGenerator::appendCommandGetVector( std::string & str, void VulkanHppGenerator::appendCommandGetVector( std::string & str,
std::string const & name, std::string const & name,
CommandData const & commandData, CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices, std::pair<size_t, size_t> const & vectorParamIndices,
bool definition ) const bool definition ) const
{ {
assert( commandData.returnType == "VkResult" ); assert( commandData.returnType == "VkResult" );
assert( vectorParamIndices.size() == 1 );
std::string const functionTemplate = R"( std::string const functionTemplate = R"(
${enter}${commandStandard}${newlineOnDefinition} ${enter}${commandStandard}${newlineOnDefinition}
@ -1802,6 +1808,46 @@ ${leave})";
{ "newlineOnDefinition", definition ? "\n" : "" } } ) ); { "newlineOnDefinition", definition ? "\n" : "" } } ) );
} }
void VulkanHppGenerator::appendCommandGetVectorOfHandles( std::string & str,
std::string const & name,
CommandData const & commandData,
std::pair<size_t, size_t> const & vectorParamIndices,
bool definition ) const
{
assert( commandData.returnType == "VkResult" );
std::string const functionTemplate = R"(
${enter}${commandStandard}${newlineOnDefinition}
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
${commandEnhanced}${newlineOnDefinition}
${commandEnhancedWithAllocators}${newlineOnDefinition}
# ifndef VULKAN_HPP_NO_SMART_HANDLE
${commandEnhancedUnique}${newlineOnDefinition}
${commandEnhancedUniqueWithAllocators}
# endif /*VULKAN_HPP_NO_SMART_HANDLE*/
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
${leave})";
std::string enter, leave;
std::tie( enter, leave ) = generateProtection( commandData.feature, commandData.extensions );
str += replaceWithMap(
functionTemplate,
std::map<std::string, std::string>(
{ { "commandEnhanced",
constructCommandGetVectorOfHandles( name, commandData, vectorParamIndices, definition, false ) },
{ "commandEnhancedUnique",
constructCommandGetVectorOfUniqueHandles( name, commandData, vectorParamIndices, definition, false ) },
{ "commandEnhancedUniqueWithAllocators",
constructCommandGetVectorOfUniqueHandles( name, commandData, vectorParamIndices, definition, true ) },
{ "commandEnhancedWithAllocators",
constructCommandGetVectorOfHandles( name, commandData, vectorParamIndices, definition, true ) },
{ "commandStandard", constructCommandStandard( name, commandData, definition ) },
{ "enter", enter },
{ "leave", leave },
{ "newlineOnDefinition", definition ? "\n" : "" } } ) );
}
void VulkanHppGenerator::appendCommandSimple( std::string & str, void VulkanHppGenerator::appendCommandSimple( std::string & str,
std::string const & name, std::string const & name,
CommandData const & commandData, CommandData const & commandData,
@ -2633,7 +2679,7 @@ std::string VulkanHppGenerator::appendFunctionBodyEnhancedLocalReturnVariable(
if ( vpiIt != vectorParamIndices.end() && !twoStep ) if ( vpiIt != vectorParamIndices.end() && !twoStep )
{ {
appendFunctionBodyEnhancedLocalReturnVariableVectorSize( appendFunctionBodyEnhancedLocalReturnVariableVectorSize(
str, commandData.params, *vpiIt, returnParamIndex, vectorParamIndices, withAllocator ); str, commandData.params, *vpiIt, vectorParamIndices, withAllocator );
} }
else if ( withAllocator ) else if ( withAllocator )
{ {
@ -2649,40 +2695,21 @@ void VulkanHppGenerator::appendFunctionBodyEnhancedLocalReturnVariableVectorSize
std::string & str, std::string & str,
std::vector<ParamData> const & params, std::vector<ParamData> const & params,
std::pair<size_t, size_t> const & vectorParamIndex, std::pair<size_t, size_t> const & vectorParamIndex,
size_t returnParamIndex,
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool withAllocator ) const bool withAllocator ) const
{ {
// if the return parameter is a vector parameter, and not part of a two-step algorithm, initialize its size // if the return parameter is a vector parameter, and not part of a two-step algorithm, initialize its size
std::string size; std::string size;
if ( vectorParamIndex.second == INVALID_INDEX ) assert( vectorParamIndex.second != INVALID_INDEX );
// the size of the vector is given by an other parameter
// first check, if that size has become the size of some other vector parameter
// -> look for it and get it's actual size
for ( auto const & vpi : vectorParamIndices )
{ {
assert( !params[returnParamIndex].len.empty() ); if ( ( vpi.first != vectorParamIndex.first ) && ( vpi.second == vectorParamIndex.second ) )
// the size of the vector is not given by an other parameter, but by some member of a parameter, described as
// 'parameter->member'
// -> replace the '->' by '.' and filter out the leading 'p' to access that value
size = startLowerCase( stripPrefix( params[returnParamIndex].len, "p" ) );
size_t pos = size.find( "->" );
if ( pos == std::string::npos )
{ {
// other notation possibility: :: size = startLowerCase( stripPrefix( params[vpi.first].name, "p" ) ) + ".size()";
pos = size.find( "::" ); break;
}
assert( pos != std::string::npos );
size.replace( pos, 2, "." );
}
else
{
// the size of the vector is given by an other parameter
// first check, if that size has become the size of some other vector parameter
// -> look for it and get it's actual size
for ( auto const & vpi : vectorParamIndices )
{
if ( ( vpi.first != vectorParamIndex.first ) && ( vpi.second == vectorParamIndex.second ) )
{
size = startLowerCase( stripPrefix( params[vpi.first].name, "p" ) ) + ".size()";
break;
}
} }
} }
assert( !size.empty() ); assert( !size.empty() );
@ -4429,7 +4456,7 @@ std::string VulkanHppGenerator::constructCommandEnumerateVoid( std::string const
if ( definition ) if ( definition )
{ {
const std::string functionTemplate = const std::string functionTemplate =
R"( template <typename ${vectorElementType}Allocator, typename Dispatch${withAllocatorTypenameCheck}> R"( template <typename ${vectorElementType}Allocator, typename Dispatch${typenameCheck}>
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector<${vectorElementType}, ${vectorElementType}Allocator> ${className}::${commandName}( ${argumentList} ) const VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector<${vectorElementType}, ${vectorElementType}Allocator> ${className}::${commandName}( ${argumentList} ) const
{ {
std::vector<${vectorElementType}, ${vectorElementType}Allocator> ${vectorName}${vectorAllocator}; std::vector<${vectorElementType}, ${vectorElementType}Allocator> ${vectorName}${vectorAllocator};
@ -4441,10 +4468,9 @@ std::string VulkanHppGenerator::constructCommandEnumerateVoid( std::string const
return ${vectorName}; return ${vectorName};
})"; })";
std::string vectorName = startLowerCase( stripPrefix( commandData.params[vectorParamIndex.first].name, "p" ) ); std::string vectorName = startLowerCase( stripPrefix( commandData.params[vectorParamIndex.first].name, "p" ) );
std::string withAllocatorsTypenameCheck = std::string typenameCheck = ", typename B, typename std::enable_if<std::is_same<typename B::value_type, " +
", typename B, typename std::enable_if<std::is_same<typename B::value_type, " + vectorElementType + vectorElementType + ">::value, int>::type ";
">::value, int>::type ";
str = replaceWithMap( str = replaceWithMap(
functionTemplate, functionTemplate,
@ -4458,11 +4484,11 @@ std::string VulkanHppGenerator::constructCommandEnumerateVoid( std::string const
constructCallArgumentsEnumerateVectors( commandData.params, { vectorParamIndex }, true ) }, constructCallArgumentsEnumerateVectors( commandData.params, { vectorParamIndex }, true ) },
{ "secondCallArguments", { "secondCallArguments",
constructCallArgumentsEnumerateVectors( commandData.params, { vectorParamIndex }, false ) }, constructCallArgumentsEnumerateVectors( commandData.params, { vectorParamIndex }, false ) },
{ "typenameCheck", withAllocators ? typenameCheck : "" },
{ "vectorAllocator", withAllocators ? ( "( " + vectorName + "Allocator )" ) : "" }, { "vectorAllocator", withAllocators ? ( "( " + vectorName + "Allocator )" ) : "" },
{ "vectorElementType", vectorElementType }, { "vectorElementType", vectorElementType },
{ "vectorName", vectorName }, { "vectorName", vectorName },
{ "vkCommand", name }, { "vkCommand", name } } ) );
{ "withAllocatorTypenameCheck", withAllocators ? withAllocatorsTypenameCheck : "" } } ) );
} }
else else
{ {
@ -4470,17 +4496,16 @@ std::string VulkanHppGenerator::constructCommandEnumerateVoid( std::string const
R"( template <typename ${vectorElementType}Allocator = std::allocator<${vectorElementType}>, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE${withAllocatorTypenameCheck}> R"( template <typename ${vectorElementType}Allocator = std::allocator<${vectorElementType}>, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE${withAllocatorTypenameCheck}>
VULKAN_HPP_NODISCARD std::vector<${vectorElementType}, ${vectorElementType}Allocator> ${commandName}( ${argumentList} ) const;)"; VULKAN_HPP_NODISCARD std::vector<${vectorElementType}, ${vectorElementType}Allocator> ${commandName}( ${argumentList} ) const;)";
std::string withAllocatorsTypenameCheck = std::string typenameCheck = ", typename B = " + vectorElementType +
", typename B = " + vectorElementType + "Allocator, typename std::enable_if<std::is_same<typename B::value_type, " +
"Allocator, typename std::enable_if<std::is_same<typename B::value_type, " + vectorElementType + vectorElementType + ">::value, int>::type = 0";
">::value, int>::type = 0";
str = replaceWithMap( functionTemplate, str = replaceWithMap(
std::map<std::string, std::string>( functionTemplate,
{ { "argumentList", argumentList }, std::map<std::string, std::string>( { { "argumentList", argumentList },
{ "commandName", commandName }, { "commandName", commandName },
{ "vectorElementType", vectorElementType }, { "vectorElementType", vectorElementType },
{ "withAllocatorTypenameCheck", withAllocators ? withAllocatorsTypenameCheck : "" } } ) ); { "withAllocatorTypenameCheck", withAllocators ? typenameCheck : "" } } ) );
} }
return str; return str;
} }
@ -4656,18 +4681,15 @@ std::string VulkanHppGenerator::constructCommandGetValue( std::string const & na
return str; return str;
} }
std::string VulkanHppGenerator::constructCommandGetVector( std::string const & name, std::string VulkanHppGenerator::constructCommandGetVector( std::string const & name,
CommandData const & commandData, CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices, std::pair<size_t, size_t> const & vectorParamIndices,
bool definition ) const bool definition ) const
{ {
assert( vectorParamIndices.size() == 1 );
std::string str; std::string str;
size_t vectorParamIndex = vectorParamIndices.begin()->first;
std::string argumentList = std::string argumentList =
constructArgumentListEnhanced( commandData.params, { 0, vectorParamIndex }, definition, false ); constructArgumentListEnhanced( commandData.params, { 0, vectorParamIndices.first }, definition, false );
std::string commandName = determineCommandName( name, commandData.params[0].type.type ); std::string commandName = determineCommandName( name, commandData.params[0].type.type );
std::string nodiscard = constructNoDiscardEnhanced( commandData ); std::string nodiscard = constructNoDiscardEnhanced( commandData );
std::string returnType = constructReturnType( commandData, "std::vector<T,Allocator>" ); std::string returnType = constructReturnType( commandData, "std::vector<T,Allocator>" );
@ -4688,12 +4710,11 @@ std::string VulkanHppGenerator::constructCommandGetVector( std::string const &
functionTemplate, functionTemplate,
std::map<std::string, std::string>( std::map<std::string, std::string>(
{ { "argumentList", argumentList }, { { "argumentList", argumentList },
{ "callArguments", { "callArguments", constructCallArgumentsGetVector( commandData.params, vectorParamIndices, false ) },
constructCallArgumentsGetVector( commandData.params, *vectorParamIndices.begin(), false ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) }, { "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName }, { "commandName", commandName },
{ "dataName", startLowerCase( stripPrefix( commandData.params[vectorParamIndex].name, "p" ) ) }, { "dataName", startLowerCase( stripPrefix( commandData.params[vectorParamIndices.first].name, "p" ) ) },
{ "dataSize", commandData.params[vectorParamIndex].len }, { "dataSize", commandData.params[vectorParamIndices.first].len },
{ "nodiscard", nodiscard }, { "nodiscard", nodiscard },
{ "returnType", returnType }, { "returnType", returnType },
{ "successCodeList", constructSuccessCodeList( commandData.successCodes ) }, { "successCodeList", constructSuccessCodeList( commandData.successCodes ) },
@ -4716,16 +4737,15 @@ std::string VulkanHppGenerator::constructCommandGetVector( std::string const &
} }
std::string std::string
VulkanHppGenerator::constructCommandGetVectorDeprecated( std::string const & name, VulkanHppGenerator::constructCommandGetVectorDeprecated( std::string const & name,
CommandData const & commandData, CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices, std::pair<size_t, size_t> const & vectorParamIndices,
bool definition ) const bool definition ) const
{ {
std::string str; std::string str;
std::map<size_t, size_t>::const_iterator vectorParamIndexIt = vectorParamIndices.begin(); std::string argumentList = constructFunctionHeaderArgumentsEnhanced(
std::string argumentList = constructFunctionHeaderArgumentsEnhanced( commandData, INVALID_INDEX, vectorParamIndices.first, { vectorParamIndices }, false, !definition, false );
commandData, INVALID_INDEX, vectorParamIndexIt->first, vectorParamIndices, false, !definition, false );
std::string commandName = determineCommandName( name, commandData.params[0].type.type ); std::string commandName = determineCommandName( name, commandData.params[0].type.type );
std::string nodiscard = constructNoDiscardEnhanced( commandData ); std::string nodiscard = constructNoDiscardEnhanced( commandData );
std::string returnType = constructReturnType( commandData, "void" ); std::string returnType = constructReturnType( commandData, "void" );
@ -4750,8 +4770,8 @@ std::string
name, name,
commandData, commandData,
INVALID_INDEX, INVALID_INDEX,
vectorParamIndexIt->first, vectorParamIndices.first,
vectorParamIndices, { vectorParamIndices },
false, false,
"void", "void",
false, false,
@ -4777,19 +4797,249 @@ std::string
return str; return str;
} }
std::string VulkanHppGenerator::constructCommandGetVectorSingular( std::string const & name, std::string
CommandData const & commandData, VulkanHppGenerator::constructCommandGetVectorOfHandles( std::string const & name,
std::map<size_t, size_t> const & vectorParamIndices, CommandData const & commandData,
bool definition ) const std::pair<size_t, size_t> const & vectorParamIndices,
bool definition,
bool withAllocator ) const
{ {
assert( vectorParamIndices.size() == 1 ); assert( !commandData.handle.empty() );
assert( commandData.successCodes.size() == 1 );
std::string str; std::string str;
size_t vectorParamIndex = vectorParamIndices.begin()->first;
size_t sizeParamIndex = vectorParamIndices.begin()->second;
std::string argumentList = std::string argumentList =
constructArgumentListEnhanced( commandData.params, { 0, sizeParamIndex, vectorParamIndex }, definition, false ); constructArgumentListEnhanced( commandData.params, { 0, vectorParamIndices.first }, definition, withAllocator );
std::string commandName = determineCommandName( name, commandData.params[0].type.type );
std::string nodiscard = constructNoDiscardEnhanced( commandData );
std::string handleType = stripPrefix( commandData.params[vectorParamIndices.first].type.type, "Vk" );
if ( definition )
{
std::string const functionTemplate =
R"( template <typename ${handleType}Allocator, typename Dispatch${typenameCheck}>
${nodiscard}VULKAN_HPP_INLINE typename ResultValueType<std::vector<${handleType}, ${handleType}Allocator>>::type ${className}::${commandName}( ${argumentList} ) const
{
std::vector<${handleType}, ${handleType}Allocator> ${vectorName}( ${vectorSize}${vectorAllocator} );
Result result = static_cast<Result>( d.${vkCommand}( ${callArguments} ) );
return createResultValue( result, ${vectorName}, VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}" );
})";
std::vector<std::string> lenParts = tokenize( commandData.params[vectorParamIndices.first].len, "->" );
assert( lenParts.size() == 2 );
std::string typenameCheck = ", typename B, typename std::enable_if<std::is_same<typename B::value_type, " +
handleType + ">::value, int>::type ";
std::string vectorName = startLowerCase( stripPrefix( commandData.params[vectorParamIndices.first].name, "p" ) );
str = replaceWithMap(
functionTemplate,
std::map<std::string, std::string>(
{ { "argumentList", argumentList },
{ "callArguments", constructCallArgumentsGetVector( commandData.params, vectorParamIndices, false ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName },
{ "nodiscard", nodiscard },
{ "handleType", handleType },
{ "typenameCheck", withAllocator ? typenameCheck : "" },
{ "vectorAllocator", withAllocator ? ( ", " + vectorName + "Allocator" ) : "" },
{ "vectorName", vectorName },
{ "vectorSize", startLowerCase( stripPrefix( lenParts[0], "p" ) ) + "." + lenParts[1] },
{ "vkCommand", name } } ) );
}
else
{
std::string const functionTemplate =
R"( template <typename ${handleType}Allocator = std::allocator<${handleType}>, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE${typenameCheck}>
${nodiscard}typename ResultValueType<std::vector<${handleType}, ${handleType}Allocator>>::type ${commandName}( ${argumentList} ) const;)";
std::string typenameCheck = ", typename B = " + handleType + "Allocator, typename std::enable_if<std::is_same<typename B::value_type, " +
handleType + ">::value, int>::type = 0";
str = replaceWithMap(
functionTemplate,
std::map<std::string, std::string>( { { "argumentList", argumentList },
{ "commandName", commandName },
{ "handleType", handleType },
{ "nodiscard", nodiscard },
{ "typenameCheck", withAllocator ? typenameCheck : "" } } ) );
}
return str;
}
std::string
VulkanHppGenerator::constructCommandGetVectorOfUniqueHandles( std::string const & name,
CommandData const & commandData,
std::pair<size_t, size_t> const & vectorParamIndices,
bool definition,
bool withAllocator ) const
{
assert( !commandData.handle.empty() );
assert( commandData.successCodes.size() == 1 );
std::string str;
std::string argumentList =
constructArgumentListEnhanced( commandData.params, { 0, vectorParamIndices.first }, definition, withAllocator );
std::string commandName = determineCommandName( name, commandData.params[0].type.type );
std::string nodiscard = constructNoDiscardEnhanced( commandData );
std::string handleType = stripPrefix( commandData.params[vectorParamIndices.first].type.type, "Vk" );
if ( definition )
{
std::string const functionTemplate =
R"( template <typename Dispatch, typename ${handleType}Allocator${typenameCheck}>
${nodiscard}VULKAN_HPP_INLINE typename ResultValueType<std::vector<UniqueHandle<${handleType}, Dispatch>, ${handleType}Allocator>>::type ${className}::${commandName}Unique( ${argumentList} ) const
{
std::vector<UniqueHandle<${handleType}, Dispatch>, ${handleType}Allocator> ${uniqueVectorName}${vectorAllocator};
std::vector<${handleType}> ${vectorName}( ${vectorSize} );
Result result = static_cast<Result>( d.${vkCommand}( ${callArguments} ) );
if ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess )
{
${uniqueVectorName}.reserve( ${vectorSize} );
PoolFree<${className}, ${poolType}, Dispatch> deleter( *this, ${poolName}, d );
for ( size_t i=0; i < ${vectorSize}; i++ )
{
${uniqueVectorName}.push_back( UniqueHandle<${handleType}, Dispatch>( ${vectorName}[i], deleter ) );
}
}
return createResultValue( result, std::move( ${uniqueVectorName} ), VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}Unique" );
})";
std::vector<std::string> lenParts = tokenize( commandData.params[vectorParamIndices.first].len, "->" );
assert( lenParts.size() == 2 );
std::string poolType, poolName;
std::tie( poolType, poolName ) = getPoolTypeAndName( commandData.params[vectorParamIndices.second].type.type );
assert( !poolType.empty() );
std::string typenameCheck = ", typename B, typename std::enable_if<std::is_same<typename B::value_type, UniqueHandle<" +
handleType + ", Dispatch>>::value, int>::type ";
std::string vectorName = startLowerCase( stripPrefix( commandData.params[vectorParamIndices.first].name, "p" ) );
str = replaceWithMap(
functionTemplate,
std::map<std::string, std::string>(
{ { "argumentList", argumentList },
{ "callArguments", constructCallArgumentsGetVector( commandData.params, vectorParamIndices, false ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName },
{ "handleType", handleType },
{ "nodiscard", nodiscard },
{ "poolName", startLowerCase( stripPrefix( lenParts[0], "p" ) ) + "." + poolName },
{ "poolType", stripPrefix( poolType, "Vk" ) },
{ "typenameCheck", withAllocator ? typenameCheck : "" },
{ "uniqueVectorName", "unique" + stripPrefix( commandData.params[vectorParamIndices.first].name, "p" ) },
{ "vectorAllocator", withAllocator ? ( "( " + vectorName + "Allocator )" ) : "" },
{ "vectorName", vectorName },
{ "vectorSize", startLowerCase( stripPrefix( lenParts[0], "p" ) ) + "." + lenParts[1] },
{ "vkCommand", name } } ) );
}
else
{
std::string const functionTemplate =
R"( template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE, typename ${handleType}Allocator = std::allocator<UniqueHandle<${handleType}, Dispatch>>${typenameCheck}>
${nodiscard}typename ResultValueType<std::vector<UniqueHandle<${handleType}, Dispatch>, ${handleType}Allocator>>::type ${commandName}Unique( ${argumentList} ) const;)";
std::string typenameCheck = ", typename B = " + handleType + "Allocator, typename std::enable_if<std::is_same<typename B::value_type, UniqueHandle<" +
handleType + ", Dispatch>>::value, int>::type = 0";
str = replaceWithMap( functionTemplate,
std::map<std::string, std::string>( { { "argumentList", argumentList },
{ "commandName", commandName },
{ "handleType", handleType },
{ "nodiscard", nodiscard },
{ "typenameCheck", withAllocator ? typenameCheck : "" } } ) );
}
return str;
}
std::string VulkanHppGenerator::constructCommandGetVectorOfUniqueHandlesWithAllocator(
std::string const & name,
CommandData const & commandData,
std::pair<size_t, size_t> const & vectorParamIndices,
bool definition ) const
{
assert( !commandData.handle.empty() );
assert( commandData.successCodes.size() == 1 );
std::string str;
std::string argumentList =
constructArgumentListEnhanced( commandData.params, { 0, vectorParamIndices.first }, definition, true );
std::string commandName = determineCommandName( name, commandData.params[0].type.type );
std::string nodiscard = constructNoDiscardEnhanced( commandData );
std::string handleType = stripPrefix( commandData.params[vectorParamIndices.first].type.type, "Vk" );
if ( definition )
{
std::string const functionTemplate =
R"( template <typename Dispatch, typename Allocator, typename B, typename std::enable_if<std::is_same<typename B::value_type, UniqueHandle<${handleType}, Dispatch>>::value, int>::type>
${nodiscard}VULKAN_HPP_INLINE typename ResultValueType<std::vector<UniqueHandle<${handleType}, Dispatch>, Allocator>>::type ${className}::${commandName}Unique( ${argumentList} ) const
{
std::vector<UniqueHandle<${handleType}, Dispatch>, Allocator> ${uniqueVectorName}( ${vectorName}Allocator );
std::vector<${handleType}> ${vectorName}( ${vectorSize} );
Result result = static_cast<Result>( d.${vkCommand}( ${callArguments} ) );
if ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess )
{
${uniqueVectorName}.reserve( ${vectorSize} );
PoolFree<${className}, ${poolType}, Dispatch> deleter( *this, ${poolName}, d );
for ( size_t i=0; i < ${vectorSize}; i++ )
{
${uniqueVectorName}.push_back( UniqueHandle<${handleType}, Dispatch>( ${vectorName}[i], deleter ) );
}
}
return createResultValue( result, std::move( ${uniqueVectorName} ), VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}Unique" );
})";
std::vector<std::string> lenParts = tokenize( commandData.params[vectorParamIndices.first].len, "->" );
assert( lenParts.size() == 2 );
std::string poolType, poolName;
std::tie( poolType, poolName ) = getPoolTypeAndName( commandData.params[vectorParamIndices.second].type.type );
assert( !poolType.empty() );
str = replaceWithMap(
functionTemplate,
std::map<std::string, std::string>(
{ { "argumentList", argumentList },
{ "callArguments", constructCallArgumentsGetVector( commandData.params, vectorParamIndices, false ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName },
{ "handleType", handleType },
{ "nodiscard", nodiscard },
{ "poolName", startLowerCase( stripPrefix( lenParts[0], "p" ) ) + "." + poolName },
{ "poolType", stripPrefix( poolType, "Vk" ) },
{ "uniqueVectorName", "unique" + stripPrefix( commandData.params[vectorParamIndices.first].name, "p" ) },
{ "vectorName", startLowerCase( stripPrefix( commandData.params[vectorParamIndices.first].name, "p" ) ) },
{ "vectorSize", startLowerCase( stripPrefix( lenParts[0], "p" ) ) + "." + lenParts[1] },
{ "vkCommand", name } } ) );
}
else
{
std::string const functionTemplate =
R"( template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE, typename Allocator = std::allocator<UniqueHandle<${handleType}, Dispatch>>, typename B = Allocator, typename std::enable_if<std::is_same<typename B::value_type, UniqueHandle<${handleType}, Dispatch>>::value, int>::type = 0>
${nodiscard}typename ResultValueType<std::vector<UniqueHandle<${handleType}, Dispatch>, Allocator>>::type ${commandName}Unique( ${argumentList} ) const;)";
str = replaceWithMap( functionTemplate,
std::map<std::string, std::string>( { { "argumentList", argumentList },
{ "commandName", commandName },
{ "handleType", handleType },
{ "nodiscard", nodiscard } } ) );
}
return str;
}
std::string VulkanHppGenerator::constructCommandGetVectorSingular( std::string const & name,
CommandData const & commandData,
std::pair<size_t, size_t> const & vectorParamIndices,
bool definition ) const
{
std::string str;
std::string argumentList = constructArgumentListEnhanced(
commandData.params, { 0, vectorParamIndices.second, vectorParamIndices.first }, definition, false );
std::string commandName = stripPluralS( determineCommandName( name, commandData.params[0].type.type ) ); std::string commandName = stripPluralS( determineCommandName( name, commandData.params[0].type.type ) );
std::string nodiscard = constructNoDiscardEnhanced( commandData ); std::string nodiscard = constructNoDiscardEnhanced( commandData );
std::string returnType = constructReturnType( commandData, "T" ); std::string returnType = constructReturnType( commandData, "T" );
@ -4809,10 +5059,10 @@ std::string VulkanHppGenerator::constructCommandGetVectorSingular( std::string c
functionTemplate, functionTemplate,
std::map<std::string, std::string>( std::map<std::string, std::string>(
{ { "argumentList", argumentList }, { { "argumentList", argumentList },
{ "callArguments", constructCallArgumentsGetVector( commandData.params, *vectorParamIndices.begin(), true ) }, { "callArguments", constructCallArgumentsGetVector( commandData.params, vectorParamIndices, true ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) }, { "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName }, { "commandName", commandName },
{ "dataName", startLowerCase( stripPrefix( commandData.params[vectorParamIndex].name, "p" ) ) }, { "dataName", startLowerCase( stripPrefix( commandData.params[vectorParamIndices.first].name, "p" ) ) },
{ "nodiscard", nodiscard }, { "nodiscard", nodiscard },
{ "returnType", returnType }, { "returnType", returnType },
{ "successCodeList", constructSuccessCodeList( commandData.successCodes ) }, { "successCodeList", constructSuccessCodeList( commandData.successCodes ) },
@ -6872,7 +7122,7 @@ std::map<size_t, size_t>
if ( !it->len.empty() ) if ( !it->len.empty() )
{ {
auto findIt = std::find_if( params.begin(), it, [this, &params, &it]( ParamData const & pd ) { auto findIt = std::find_if( params.begin(), it, [this, &params, &it]( ParamData const & pd ) {
return ( pd.name == it->len ) || isParamIndirect( it->len, params ); return ( pd.name == it->len ) || isParamIndirect( it->len, pd );
} ); } );
if ( findIt < it ) if ( findIt < it )
@ -7143,6 +7393,20 @@ std::set<std::string> VulkanHppGenerator::getPlatforms( std::set<std::string> co
return platforms; return platforms;
} }
std::pair<std::string, std::string> VulkanHppGenerator::getPoolTypeAndName( std::string const & type ) const
{
auto structIt = m_structures.find( type );
assert( structIt != m_structures.end() );
auto memberIt = std::find_if( structIt->second.members.begin(),
structIt->second.members.end(),
[]( MemberData const & md ) { return md.name.find( "Pool" ) != std::string::npos; } );
assert( memberIt != structIt->second.members.end() );
assert( std::find_if( std::next( memberIt ), structIt->second.members.end(), []( MemberData const & md ) {
return md.name.find( "Pool" ) != std::string::npos;
} ) == structIt->second.members.end() );
return std::make_pair( memberIt->type.type, memberIt->name );
}
bool VulkanHppGenerator::isChainableStructure( std::string const & type ) const bool VulkanHppGenerator::isChainableStructure( std::string const & type ) const
{ {
if ( beginsWith( type, "Vk" ) ) if ( beginsWith( type, "Vk" ) )
@ -7212,6 +7476,28 @@ bool VulkanHppGenerator::isParamIndirect( std::string const & name, std::vector<
return false; return false;
} }
bool VulkanHppGenerator::isParamIndirect( std::string const & name, ParamData const & param ) const
{
// check if name specifies a member of a struct
std::vector<std::string> nameParts = tokenize( name, "->" );
if ( nameParts.size() == 1 )
{
// older versions of vk.xml used the notation parameter::member
nameParts = tokenize( name, "::" );
}
if ( ( nameParts.size() == 2 ) && ( nameParts[0] == param.name ) )
{
auto structureIt = m_structures.find( param.type.type );
assert( structureIt != m_structures.end() );
assert( std::find_if( structureIt->second.members.begin(),
structureIt->second.members.end(),
[&n = nameParts[1]]( MemberData const & md ) { return md.name == n; } ) !=
structureIt->second.members.end() );
return true;
}
return false;
}
bool VulkanHppGenerator::isTwoStepAlgorithm( std::vector<ParamData> const & params ) const bool VulkanHppGenerator::isTwoStepAlgorithm( std::vector<ParamData> const & params ) const
{ {
// we generate a two-step algorithm for functions returning a vector of stuff, where the length is specified as a // we generate a two-step algorithm for functions returning a vector of stuff, where the length is specified as a

View File

@ -336,11 +336,16 @@ private:
CommandData const & commandData, CommandData const & commandData,
size_t nonConstPointerIndex, size_t nonConstPointerIndex,
bool definition ) const; bool definition ) const;
void appendCommandGetVector( std::string & str, void appendCommandGetVector( std::string & str,
std::string const & name, std::string const & name,
CommandData const & commandData, CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices, std::pair<size_t, size_t> const & vectorParamIndices,
bool definition ) const; bool definition ) const;
void appendCommandGetVectorOfHandles( std::string & str,
std::string const & name,
CommandData const & commandData,
std::pair<size_t, size_t> const & vectorParamIndices,
bool definition ) const;
void appendCommandSimple( std::string & str, void appendCommandSimple( std::string & str,
std::string const & name, std::string const & name,
CommandData const & commandData, CommandData const & commandData,
@ -405,7 +410,6 @@ private:
void appendFunctionBodyEnhancedLocalReturnVariableVectorSize( std::string & str, void appendFunctionBodyEnhancedLocalReturnVariableVectorSize( std::string & str,
std::vector<ParamData> const & params, std::vector<ParamData> const & params,
std::pair<size_t, size_t> const & vectorParamIndex, std::pair<size_t, size_t> const & vectorParamIndex,
size_t returnParamIndex,
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool withAllocator ) const; bool withAllocator ) const;
void appendFunctionBodyEnhancedMultiVectorSizeCheck( std::string & str, void appendFunctionBodyEnhancedMultiVectorSizeCheck( std::string & str,
@ -582,18 +586,31 @@ private:
CommandData const & commandData, CommandData const & commandData,
size_t nonConstPointerIndex, size_t nonConstPointerIndex,
bool definition ) const; bool definition ) const;
std::string constructCommandGetVector( std::string const & name, std::string constructCommandGetVector( std::string const & name,
CommandData const & commandData, CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices, std::pair<size_t, size_t> const & vectorParamIndices,
bool definition ) const; bool definition ) const;
std::string constructCommandGetVectorDeprecated( std::string const & name, std::string constructCommandGetVectorDeprecated( std::string const & name,
CommandData const & commandData, CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices, std::pair<size_t, size_t> const & vectorParamIndices,
bool definition ) const; bool definition ) const;
std::string constructCommandGetVectorSingular( std::string const & name, std::string constructCommandGetVectorOfHandles( std::string const & name,
CommandData const & commandData, CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices, std::pair<size_t, size_t> const & vectorParamIndices,
bool definition ) const; bool definition, bool withAllocator ) const;
std::string constructCommandGetVectorOfUniqueHandles( std::string const & name,
CommandData const & commandData,
std::pair<size_t, size_t> const & vectorParamIndices,
bool definition, bool withAllocator ) const;
std::string
constructCommandGetVectorOfUniqueHandlesWithAllocator( std::string const & name,
CommandData const & commandData,
std::pair<size_t, size_t> const & vectorParamIndices,
bool definition ) const;
std::string constructCommandGetVectorSingular( std::string const & name,
CommandData const & commandData,
std::pair<size_t, size_t> const & vectorParamIndices,
bool definition ) const;
std::string constructCommandSimple( std::string const & name, std::string constructCommandSimple( std::string const & name,
CommandData const & commandData, CommandData const & commandData,
bool definition, bool definition,
@ -680,12 +697,14 @@ private:
std::string const & structName, std::string const & structName,
std::string const & prefix ) const; std::string const & prefix ) const;
std::set<std::string> getPlatforms( std::set<std::string> const & extensions ) const; std::set<std::string> getPlatforms( std::set<std::string> const & extensions ) const;
bool isChainableStructure( std::string const & type ) const; std::pair<std::string, std::string> getPoolTypeAndName( std::string const & type ) const;
bool isHandleType( std::string const & type ) const; bool isChainableStructure( std::string const & type ) const;
bool isParam( std::string const & name, std::vector<ParamData> const & params ) const; bool isHandleType( std::string const & type ) const;
bool isParamIndirect( std::string const & name, std::vector<ParamData> const & params ) const; bool isParam( std::string const & name, std::vector<ParamData> const & params ) const;
bool isTwoStepAlgorithm( std::vector<ParamData> const & params ) const; bool isParamIndirect( std::string const & name, std::vector<ParamData> const & params ) const;
bool needsComplexBody( CommandData const & commandData ) const; bool isParamIndirect( std::string const & name, ParamData const & param ) const;
bool isTwoStepAlgorithm( std::vector<ParamData> const & params ) const;
bool needsComplexBody( CommandData const & commandData ) const;
std::pair<bool, std::map<size_t, std::vector<size_t>>> std::pair<bool, std::map<size_t, std::vector<size_t>>>
needsVectorSizeCheck( std::map<size_t, size_t> const & vectorParamIndices ) const; needsVectorSizeCheck( std::map<size_t, size_t> const & vectorParamIndices ) const;
void readBaseType( tinyxml2::XMLElement const * element, std::map<std::string, std::string> const & attributes ); void readBaseType( tinyxml2::XMLElement const * element, std::map<std::string, std::string> const & attributes );

View File

@ -52101,36 +52101,38 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NAMESPACE::CommandBuffer * pCommandBuffers, VULKAN_HPP_NAMESPACE::CommandBuffer * pCommandBuffers,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Allocator = std::allocator<CommandBuffer>, template <typename CommandBufferAllocator = std::allocator<CommandBuffer>,
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<std::vector<CommandBuffer, Allocator>>::type VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS
typename ResultValueType<std::vector<CommandBuffer, CommandBufferAllocator>>::type
allocateCommandBuffers( const CommandBufferAllocateInfo & allocateInfo, allocateCommandBuffers( const CommandBufferAllocateInfo & allocateInfo,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
template <typename Allocator = std::allocator<CommandBuffer>, template <typename CommandBufferAllocator = std::allocator<CommandBuffer>,
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE,
typename B = Allocator, typename B = CommandBufferAllocator,
typename std::enable_if<std::is_same<typename B::value_type, CommandBuffer>::value, int>::type = 0> typename std::enable_if<std::is_same<typename B::value_type, CommandBuffer>::value, int>::type = 0>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<std::vector<CommandBuffer, Allocator>>::type VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS
typename ResultValueType<std::vector<CommandBuffer, CommandBufferAllocator>>::type
allocateCommandBuffers( const CommandBufferAllocateInfo & allocateInfo, allocateCommandBuffers( const CommandBufferAllocateInfo & allocateInfo,
Allocator const & vectorAllocator, CommandBufferAllocator & commandBuffersAllocator,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
# ifndef VULKAN_HPP_NO_SMART_HANDLE # ifndef VULKAN_HPP_NO_SMART_HANDLE
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE, template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE,
typename Allocator = std::allocator<UniqueHandle<CommandBuffer, Dispatch>>> typename CommandBufferAllocator = std::allocator<UniqueHandle<CommandBuffer, Dispatch>>>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS
typename ResultValueType<std::vector<UniqueHandle<CommandBuffer, Dispatch>, Allocator>>::type typename ResultValueType<std::vector<UniqueHandle<CommandBuffer, Dispatch>, CommandBufferAllocator>>::type
allocateCommandBuffersUnique( const CommandBufferAllocateInfo & allocateInfo, allocateCommandBuffersUnique( const CommandBufferAllocateInfo & allocateInfo,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
template < template <
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE,
typename Allocator = std::allocator<UniqueHandle<CommandBuffer, Dispatch>>, typename CommandBufferAllocator = std::allocator<UniqueHandle<CommandBuffer, Dispatch>>,
typename B = Allocator, typename B = CommandBufferAllocator,
typename std::enable_if<std::is_same<typename B::value_type, UniqueHandle<CommandBuffer, Dispatch>>::value, typename std::enable_if<std::is_same<typename B::value_type, UniqueHandle<CommandBuffer, Dispatch>>::value,
int>::type = 0> int>::type = 0>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS
typename ResultValueType<std::vector<UniqueHandle<CommandBuffer, Dispatch>, Allocator>>::type typename ResultValueType<std::vector<UniqueHandle<CommandBuffer, Dispatch>, CommandBufferAllocator>>::type
allocateCommandBuffersUnique( const CommandBufferAllocateInfo & allocateInfo, allocateCommandBuffersUnique( const CommandBufferAllocateInfo & allocateInfo,
Allocator const & vectorAllocator, CommandBufferAllocator & commandBuffersAllocator,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
# endif /*VULKAN_HPP_NO_SMART_HANDLE*/ # endif /*VULKAN_HPP_NO_SMART_HANDLE*/
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -52141,36 +52143,38 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NAMESPACE::DescriptorSet * pDescriptorSets, VULKAN_HPP_NAMESPACE::DescriptorSet * pDescriptorSets,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Allocator = std::allocator<DescriptorSet>, template <typename DescriptorSetAllocator = std::allocator<DescriptorSet>,
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<std::vector<DescriptorSet, Allocator>>::type VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS
typename ResultValueType<std::vector<DescriptorSet, DescriptorSetAllocator>>::type
allocateDescriptorSets( const DescriptorSetAllocateInfo & allocateInfo, allocateDescriptorSets( const DescriptorSetAllocateInfo & allocateInfo,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
template <typename Allocator = std::allocator<DescriptorSet>, template <typename DescriptorSetAllocator = std::allocator<DescriptorSet>,
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE,
typename B = Allocator, typename B = DescriptorSetAllocator,
typename std::enable_if<std::is_same<typename B::value_type, DescriptorSet>::value, int>::type = 0> typename std::enable_if<std::is_same<typename B::value_type, DescriptorSet>::value, int>::type = 0>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<std::vector<DescriptorSet, Allocator>>::type VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS
typename ResultValueType<std::vector<DescriptorSet, DescriptorSetAllocator>>::type
allocateDescriptorSets( const DescriptorSetAllocateInfo & allocateInfo, allocateDescriptorSets( const DescriptorSetAllocateInfo & allocateInfo,
Allocator const & vectorAllocator, DescriptorSetAllocator & descriptorSetsAllocator,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
# ifndef VULKAN_HPP_NO_SMART_HANDLE # ifndef VULKAN_HPP_NO_SMART_HANDLE
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE, template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE,
typename Allocator = std::allocator<UniqueHandle<DescriptorSet, Dispatch>>> typename DescriptorSetAllocator = std::allocator<UniqueHandle<DescriptorSet, Dispatch>>>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS
typename ResultValueType<std::vector<UniqueHandle<DescriptorSet, Dispatch>, Allocator>>::type typename ResultValueType<std::vector<UniqueHandle<DescriptorSet, Dispatch>, DescriptorSetAllocator>>::type
allocateDescriptorSetsUnique( const DescriptorSetAllocateInfo & allocateInfo, allocateDescriptorSetsUnique( const DescriptorSetAllocateInfo & allocateInfo,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
template < template <
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE,
typename Allocator = std::allocator<UniqueHandle<DescriptorSet, Dispatch>>, typename DescriptorSetAllocator = std::allocator<UniqueHandle<DescriptorSet, Dispatch>>,
typename B = Allocator, typename B = DescriptorSetAllocator,
typename std::enable_if<std::is_same<typename B::value_type, UniqueHandle<DescriptorSet, Dispatch>>::value, typename std::enable_if<std::is_same<typename B::value_type, UniqueHandle<DescriptorSet, Dispatch>>::value,
int>::type = 0> int>::type = 0>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS
typename ResultValueType<std::vector<UniqueHandle<DescriptorSet, Dispatch>, Allocator>>::type typename ResultValueType<std::vector<UniqueHandle<DescriptorSet, Dispatch>, DescriptorSetAllocator>>::type
allocateDescriptorSetsUnique( const DescriptorSetAllocateInfo & allocateInfo, allocateDescriptorSetsUnique( const DescriptorSetAllocateInfo & allocateInfo,
Allocator const & vectorAllocator, DescriptorSetAllocator & descriptorSetsAllocator,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
# endif /*VULKAN_HPP_NO_SMART_HANDLE*/ # endif /*VULKAN_HPP_NO_SMART_HANDLE*/
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -92462,45 +92466,49 @@ namespace VULKAN_HPP_NAMESPACE
reinterpret_cast<const VkCommandBufferAllocateInfo *>( pAllocateInfo ), reinterpret_cast<const VkCommandBufferAllocateInfo *>( pAllocateInfo ),
reinterpret_cast<VkCommandBuffer *>( pCommandBuffers ) ) ); reinterpret_cast<VkCommandBuffer *>( pCommandBuffers ) ) );
} }
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Allocator, typename Dispatch> template <typename CommandBufferAllocator, typename Dispatch>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE
typename ResultValueType<std::vector<CommandBuffer, Allocator>>::type typename ResultValueType<std::vector<CommandBuffer, CommandBufferAllocator>>::type
Device::allocateCommandBuffers( const CommandBufferAllocateInfo & allocateInfo, Dispatch const & d ) const Device::allocateCommandBuffers( const CommandBufferAllocateInfo & allocateInfo, Dispatch const & d ) const
{ {
std::vector<CommandBuffer, Allocator> commandBuffers( allocateInfo.commandBufferCount ); std::vector<CommandBuffer, CommandBufferAllocator> commandBuffers( allocateInfo.commandBufferCount );
Result result = static_cast<Result>( Result result = static_cast<Result>(
d.vkAllocateCommandBuffers( m_device, d.vkAllocateCommandBuffers( m_device,
reinterpret_cast<const VkCommandBufferAllocateInfo *>( &allocateInfo ), reinterpret_cast<const VkCommandBufferAllocateInfo *>( &allocateInfo ),
reinterpret_cast<VkCommandBuffer *>( commandBuffers.data() ) ) ); reinterpret_cast<VkCommandBuffer *>( commandBuffers.data() ) ) );
return createResultValue( result, commandBuffers, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateCommandBuffers" ); return createResultValue( result, commandBuffers, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateCommandBuffers" );
} }
template <typename Allocator,
template <typename CommandBufferAllocator,
typename Dispatch, typename Dispatch,
typename B, typename B,
typename std::enable_if<std::is_same<typename B::value_type, CommandBuffer>::value, int>::type> typename std::enable_if<std::is_same<typename B::value_type, CommandBuffer>::value, int>::type>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE
typename ResultValueType<std::vector<CommandBuffer, Allocator>>::type typename ResultValueType<std::vector<CommandBuffer, CommandBufferAllocator>>::type
Device::allocateCommandBuffers( const CommandBufferAllocateInfo & allocateInfo, Device::allocateCommandBuffers( const CommandBufferAllocateInfo & allocateInfo,
Allocator const & vectorAllocator, CommandBufferAllocator & commandBuffersAllocator,
Dispatch const & d ) const Dispatch const & d ) const
{ {
std::vector<CommandBuffer, Allocator> commandBuffers( allocateInfo.commandBufferCount, vectorAllocator ); std::vector<CommandBuffer, CommandBufferAllocator> commandBuffers( allocateInfo.commandBufferCount,
Result result = static_cast<Result>( commandBuffersAllocator );
Result result = static_cast<Result>(
d.vkAllocateCommandBuffers( m_device, d.vkAllocateCommandBuffers( m_device,
reinterpret_cast<const VkCommandBufferAllocateInfo *>( &allocateInfo ), reinterpret_cast<const VkCommandBufferAllocateInfo *>( &allocateInfo ),
reinterpret_cast<VkCommandBuffer *>( commandBuffers.data() ) ) ); reinterpret_cast<VkCommandBuffer *>( commandBuffers.data() ) ) );
return createResultValue( result, commandBuffers, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateCommandBuffers" ); return createResultValue( result, commandBuffers, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateCommandBuffers" );
} }
# ifndef VULKAN_HPP_NO_SMART_HANDLE # ifndef VULKAN_HPP_NO_SMART_HANDLE
template <typename Dispatch, typename Allocator> template <typename Dispatch, typename CommandBufferAllocator>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE
typename ResultValueType<std::vector<UniqueHandle<CommandBuffer, Dispatch>, Allocator>>::type typename ResultValueType<std::vector<UniqueHandle<CommandBuffer, Dispatch>, CommandBufferAllocator>>::type
Device::allocateCommandBuffersUnique( const CommandBufferAllocateInfo & allocateInfo, Dispatch const & d ) const Device::allocateCommandBuffersUnique( const CommandBufferAllocateInfo & allocateInfo, Dispatch const & d ) const
{ {
std::vector<UniqueHandle<CommandBuffer, Dispatch>, Allocator> uniqueCommandBuffers; std::vector<UniqueHandle<CommandBuffer, Dispatch>, CommandBufferAllocator> uniqueCommandBuffers;
std::vector<CommandBuffer> commandBuffers( allocateInfo.commandBufferCount ); std::vector<CommandBuffer> commandBuffers( allocateInfo.commandBufferCount );
Result result = static_cast<Result>( Result result = static_cast<Result>(
d.vkAllocateCommandBuffers( m_device, d.vkAllocateCommandBuffers( m_device,
reinterpret_cast<const VkCommandBufferAllocateInfo *>( &allocateInfo ), reinterpret_cast<const VkCommandBufferAllocateInfo *>( &allocateInfo ),
reinterpret_cast<VkCommandBuffer *>( commandBuffers.data() ) ) ); reinterpret_cast<VkCommandBuffer *>( commandBuffers.data() ) ) );
@ -92513,24 +92521,25 @@ namespace VULKAN_HPP_NAMESPACE
uniqueCommandBuffers.push_back( UniqueHandle<CommandBuffer, Dispatch>( commandBuffers[i], deleter ) ); uniqueCommandBuffers.push_back( UniqueHandle<CommandBuffer, Dispatch>( commandBuffers[i], deleter ) );
} }
} }
return createResultValue( return createResultValue(
result, std::move( uniqueCommandBuffers ), VULKAN_HPP_NAMESPACE_STRING "::Device::allocateCommandBuffersUnique" ); result, std::move( uniqueCommandBuffers ), VULKAN_HPP_NAMESPACE_STRING "::Device::allocateCommandBuffersUnique" );
} }
template <typename Dispatch, template <typename Dispatch,
typename Allocator, typename CommandBufferAllocator,
typename B, typename B,
typename std::enable_if<std::is_same<typename B::value_type, UniqueHandle<CommandBuffer, Dispatch>>::value, typename std::enable_if<std::is_same<typename B::value_type, UniqueHandle<CommandBuffer, Dispatch>>::value,
int>::type> int>::type>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE
typename ResultValueType<std::vector<UniqueHandle<CommandBuffer, Dispatch>, Allocator>>::type typename ResultValueType<std::vector<UniqueHandle<CommandBuffer, Dispatch>, CommandBufferAllocator>>::type
Device::allocateCommandBuffersUnique( const CommandBufferAllocateInfo & allocateInfo, Device::allocateCommandBuffersUnique( const CommandBufferAllocateInfo & allocateInfo,
Allocator const & vectorAllocator, CommandBufferAllocator & commandBuffersAllocator,
Dispatch const & d ) const Dispatch const & d ) const
{ {
std::vector<UniqueHandle<CommandBuffer, Dispatch>, Allocator> uniqueCommandBuffers( vectorAllocator ); std::vector<UniqueHandle<CommandBuffer, Dispatch>, CommandBufferAllocator> uniqueCommandBuffers(
std::vector<CommandBuffer> commandBuffers( allocateInfo.commandBufferCount ); commandBuffersAllocator );
Result result = static_cast<Result>( std::vector<CommandBuffer> commandBuffers( allocateInfo.commandBufferCount );
Result result = static_cast<Result>(
d.vkAllocateCommandBuffers( m_device, d.vkAllocateCommandBuffers( m_device,
reinterpret_cast<const VkCommandBufferAllocateInfo *>( &allocateInfo ), reinterpret_cast<const VkCommandBufferAllocateInfo *>( &allocateInfo ),
reinterpret_cast<VkCommandBuffer *>( commandBuffers.data() ) ) ); reinterpret_cast<VkCommandBuffer *>( commandBuffers.data() ) ) );
@ -92543,7 +92552,6 @@ namespace VULKAN_HPP_NAMESPACE
uniqueCommandBuffers.push_back( UniqueHandle<CommandBuffer, Dispatch>( commandBuffers[i], deleter ) ); uniqueCommandBuffers.push_back( UniqueHandle<CommandBuffer, Dispatch>( commandBuffers[i], deleter ) );
} }
} }
return createResultValue( return createResultValue(
result, std::move( uniqueCommandBuffers ), VULKAN_HPP_NAMESPACE_STRING "::Device::allocateCommandBuffersUnique" ); result, std::move( uniqueCommandBuffers ), VULKAN_HPP_NAMESPACE_STRING "::Device::allocateCommandBuffersUnique" );
} }
@ -92561,45 +92569,49 @@ namespace VULKAN_HPP_NAMESPACE
reinterpret_cast<const VkDescriptorSetAllocateInfo *>( pAllocateInfo ), reinterpret_cast<const VkDescriptorSetAllocateInfo *>( pAllocateInfo ),
reinterpret_cast<VkDescriptorSet *>( pDescriptorSets ) ) ); reinterpret_cast<VkDescriptorSet *>( pDescriptorSets ) ) );
} }
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Allocator, typename Dispatch> template <typename DescriptorSetAllocator, typename Dispatch>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE
typename ResultValueType<std::vector<DescriptorSet, Allocator>>::type typename ResultValueType<std::vector<DescriptorSet, DescriptorSetAllocator>>::type
Device::allocateDescriptorSets( const DescriptorSetAllocateInfo & allocateInfo, Dispatch const & d ) const Device::allocateDescriptorSets( const DescriptorSetAllocateInfo & allocateInfo, Dispatch const & d ) const
{ {
std::vector<DescriptorSet, Allocator> descriptorSets( allocateInfo.descriptorSetCount ); std::vector<DescriptorSet, DescriptorSetAllocator> descriptorSets( allocateInfo.descriptorSetCount );
Result result = static_cast<Result>( Result result = static_cast<Result>(
d.vkAllocateDescriptorSets( m_device, d.vkAllocateDescriptorSets( m_device,
reinterpret_cast<const VkDescriptorSetAllocateInfo *>( &allocateInfo ), reinterpret_cast<const VkDescriptorSetAllocateInfo *>( &allocateInfo ),
reinterpret_cast<VkDescriptorSet *>( descriptorSets.data() ) ) ); reinterpret_cast<VkDescriptorSet *>( descriptorSets.data() ) ) );
return createResultValue( result, descriptorSets, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateDescriptorSets" ); return createResultValue( result, descriptorSets, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateDescriptorSets" );
} }
template <typename Allocator,
template <typename DescriptorSetAllocator,
typename Dispatch, typename Dispatch,
typename B, typename B,
typename std::enable_if<std::is_same<typename B::value_type, DescriptorSet>::value, int>::type> typename std::enable_if<std::is_same<typename B::value_type, DescriptorSet>::value, int>::type>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE
typename ResultValueType<std::vector<DescriptorSet, Allocator>>::type typename ResultValueType<std::vector<DescriptorSet, DescriptorSetAllocator>>::type
Device::allocateDescriptorSets( const DescriptorSetAllocateInfo & allocateInfo, Device::allocateDescriptorSets( const DescriptorSetAllocateInfo & allocateInfo,
Allocator const & vectorAllocator, DescriptorSetAllocator & descriptorSetsAllocator,
Dispatch const & d ) const Dispatch const & d ) const
{ {
std::vector<DescriptorSet, Allocator> descriptorSets( allocateInfo.descriptorSetCount, vectorAllocator ); std::vector<DescriptorSet, DescriptorSetAllocator> descriptorSets( allocateInfo.descriptorSetCount,
Result result = static_cast<Result>( descriptorSetsAllocator );
Result result = static_cast<Result>(
d.vkAllocateDescriptorSets( m_device, d.vkAllocateDescriptorSets( m_device,
reinterpret_cast<const VkDescriptorSetAllocateInfo *>( &allocateInfo ), reinterpret_cast<const VkDescriptorSetAllocateInfo *>( &allocateInfo ),
reinterpret_cast<VkDescriptorSet *>( descriptorSets.data() ) ) ); reinterpret_cast<VkDescriptorSet *>( descriptorSets.data() ) ) );
return createResultValue( result, descriptorSets, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateDescriptorSets" ); return createResultValue( result, descriptorSets, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateDescriptorSets" );
} }
# ifndef VULKAN_HPP_NO_SMART_HANDLE # ifndef VULKAN_HPP_NO_SMART_HANDLE
template <typename Dispatch, typename Allocator> template <typename Dispatch, typename DescriptorSetAllocator>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE
typename ResultValueType<std::vector<UniqueHandle<DescriptorSet, Dispatch>, Allocator>>::type typename ResultValueType<std::vector<UniqueHandle<DescriptorSet, Dispatch>, DescriptorSetAllocator>>::type
Device::allocateDescriptorSetsUnique( const DescriptorSetAllocateInfo & allocateInfo, Dispatch const & d ) const Device::allocateDescriptorSetsUnique( const DescriptorSetAllocateInfo & allocateInfo, Dispatch const & d ) const
{ {
std::vector<UniqueHandle<DescriptorSet, Dispatch>, Allocator> uniqueDescriptorSets; std::vector<UniqueHandle<DescriptorSet, Dispatch>, DescriptorSetAllocator> uniqueDescriptorSets;
std::vector<DescriptorSet> descriptorSets( allocateInfo.descriptorSetCount ); std::vector<DescriptorSet> descriptorSets( allocateInfo.descriptorSetCount );
Result result = static_cast<Result>( Result result = static_cast<Result>(
d.vkAllocateDescriptorSets( m_device, d.vkAllocateDescriptorSets( m_device,
reinterpret_cast<const VkDescriptorSetAllocateInfo *>( &allocateInfo ), reinterpret_cast<const VkDescriptorSetAllocateInfo *>( &allocateInfo ),
reinterpret_cast<VkDescriptorSet *>( descriptorSets.data() ) ) ); reinterpret_cast<VkDescriptorSet *>( descriptorSets.data() ) ) );
@ -92612,24 +92624,25 @@ namespace VULKAN_HPP_NAMESPACE
uniqueDescriptorSets.push_back( UniqueHandle<DescriptorSet, Dispatch>( descriptorSets[i], deleter ) ); uniqueDescriptorSets.push_back( UniqueHandle<DescriptorSet, Dispatch>( descriptorSets[i], deleter ) );
} }
} }
return createResultValue( return createResultValue(
result, std::move( uniqueDescriptorSets ), VULKAN_HPP_NAMESPACE_STRING "::Device::allocateDescriptorSetsUnique" ); result, std::move( uniqueDescriptorSets ), VULKAN_HPP_NAMESPACE_STRING "::Device::allocateDescriptorSetsUnique" );
} }
template <typename Dispatch, template <typename Dispatch,
typename Allocator, typename DescriptorSetAllocator,
typename B, typename B,
typename std::enable_if<std::is_same<typename B::value_type, UniqueHandle<DescriptorSet, Dispatch>>::value, typename std::enable_if<std::is_same<typename B::value_type, UniqueHandle<DescriptorSet, Dispatch>>::value,
int>::type> int>::type>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE
typename ResultValueType<std::vector<UniqueHandle<DescriptorSet, Dispatch>, Allocator>>::type typename ResultValueType<std::vector<UniqueHandle<DescriptorSet, Dispatch>, DescriptorSetAllocator>>::type
Device::allocateDescriptorSetsUnique( const DescriptorSetAllocateInfo & allocateInfo, Device::allocateDescriptorSetsUnique( const DescriptorSetAllocateInfo & allocateInfo,
Allocator const & vectorAllocator, DescriptorSetAllocator & descriptorSetsAllocator,
Dispatch const & d ) const Dispatch const & d ) const
{ {
std::vector<UniqueHandle<DescriptorSet, Dispatch>, Allocator> uniqueDescriptorSets( vectorAllocator ); std::vector<UniqueHandle<DescriptorSet, Dispatch>, DescriptorSetAllocator> uniqueDescriptorSets(
std::vector<DescriptorSet> descriptorSets( allocateInfo.descriptorSetCount ); descriptorSetsAllocator );
Result result = static_cast<Result>( std::vector<DescriptorSet> descriptorSets( allocateInfo.descriptorSetCount );
Result result = static_cast<Result>(
d.vkAllocateDescriptorSets( m_device, d.vkAllocateDescriptorSets( m_device,
reinterpret_cast<const VkDescriptorSetAllocateInfo *>( &allocateInfo ), reinterpret_cast<const VkDescriptorSetAllocateInfo *>( &allocateInfo ),
reinterpret_cast<VkDescriptorSet *>( descriptorSets.data() ) ) ); reinterpret_cast<VkDescriptorSet *>( descriptorSets.data() ) ) );
@ -92642,7 +92655,6 @@ namespace VULKAN_HPP_NAMESPACE
uniqueDescriptorSets.push_back( UniqueHandle<DescriptorSet, Dispatch>( descriptorSets[i], deleter ) ); uniqueDescriptorSets.push_back( UniqueHandle<DescriptorSet, Dispatch>( descriptorSets[i], deleter ) );
} }
} }
return createResultValue( return createResultValue(
result, std::move( uniqueDescriptorSets ), VULKAN_HPP_NAMESPACE_STRING "::Device::allocateDescriptorSetsUnique" ); result, std::move( uniqueDescriptorSets ), VULKAN_HPP_NAMESPACE_STRING "::Device::allocateDescriptorSetsUnique" );
} }