mirror of
https://github.com/KhronosGroup/Vulkan-Hpp
synced 2024-11-09 22:20:07 +00:00
Combine two types of commands into one generation function
This commit is contained in:
parent
fae2b5ce6f
commit
39be44dc65
@ -2638,7 +2638,7 @@ std::string VulkanHppGenerator::generateArgumentTemplates( std::vector<ParamData
|
||||
std::map<size_t, size_t> const & vectorParams,
|
||||
std::set<size_t> const & templatedParams,
|
||||
bool chained,
|
||||
bool complete ) const
|
||||
bool raii ) const
|
||||
{
|
||||
std::string argumentTemplates;
|
||||
if ( !templatedParams.empty() )
|
||||
@ -2660,7 +2660,7 @@ std::string VulkanHppGenerator::generateArgumentTemplates( std::vector<ParamData
|
||||
{
|
||||
argumentTemplates = ( returnParams.size() == 1 ) ? "typename X, typename Y, typename... Z, " : "typename StructureChain, ";
|
||||
}
|
||||
if ( !argumentTemplates.empty() && complete )
|
||||
if ( !argumentTemplates.empty() && raii )
|
||||
{
|
||||
argumentTemplates = "template <" + stripPostfix( argumentTemplates, ", " ) + ">";
|
||||
}
|
||||
@ -6671,8 +6671,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultMultiSuccessWithE
|
||||
std::string str = generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, returnParams, vectorParams, definition, false, false );
|
||||
if ( isStructureChainAnchor( commandIt->second.params[returnParams[1]].type.type ) )
|
||||
{
|
||||
str += generateRAIIHandleCommandResultMultiSuccessWithErrors2Return1VectorEnumerateChain(
|
||||
commandIt, initialSkipCount, vectorParams, returnParams, definition );
|
||||
str += generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, returnParams, vectorParams, definition, true, false );
|
||||
}
|
||||
return str;
|
||||
}
|
||||
@ -6686,98 +6685,6 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultMultiSuccessWithE
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string VulkanHppGenerator::generateRAIIHandleCommandResultMultiSuccessWithErrors2Return1VectorEnumerateChain(
|
||||
std::map<std::string, CommandData>::const_iterator commandIt,
|
||||
size_t initialSkipCount,
|
||||
std::map<size_t, size_t> const & vectorParams,
|
||||
std::vector<size_t> const & returnParams,
|
||||
bool definition ) const
|
||||
{
|
||||
std::set<size_t> skippedParams = determineSkippedParams( commandIt->second.params, initialSkipCount, vectorParams, returnParams, false );
|
||||
std::string argumentList =
|
||||
generateArgumentListEnhanced( commandIt->second.params, returnParams, vectorParams, skippedParams, {}, {}, definition, false, true, false );
|
||||
std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags, false, false );
|
||||
std::string vectorElementType = commandIt->second.params[vectorParams.begin()->first].type.type;
|
||||
if ( !isHandleType( vectorElementType ) )
|
||||
{
|
||||
assert( commandIt->second.params[vectorParams.begin()->first].type.isNonConstPointer() );
|
||||
vectorElementType = ( vectorElementType == "void" )
|
||||
? "uint8_t"
|
||||
: stripPostfix( commandIt->second.params[vectorParams.begin()->first].type.compose( "VULKAN_HPP_NAMESPACE" ), "*" );
|
||||
}
|
||||
|
||||
if ( definition )
|
||||
{
|
||||
const std::string definitionTemplate =
|
||||
R"(
|
||||
template <typename X, typename Y, typename... Z>
|
||||
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector<StructureChain<X, Y, Z...>> ${className}::${commandName}( ${argumentList} ) const
|
||||
{${functionPointerCheck}
|
||||
std::vector<StructureChain<X, Y, Z...>> returnVector;
|
||||
std::vector<${vectorElementType}> ${vectorName};
|
||||
${counterType} ${counterName};
|
||||
VULKAN_HPP_NAMESPACE::Result result;
|
||||
do
|
||||
{
|
||||
result = static_cast<VULKAN_HPP_NAMESPACE::Result>( getDispatcher()->${vkCommand}( ${firstCallArguments} ) );
|
||||
if ( ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) && ${counterName} )
|
||||
{
|
||||
returnVector.resize( ${counterName} );
|
||||
${vectorName}.resize( ${counterName} );
|
||||
for ( ${counterType} i = 0; i < ${counterName}; i++ )
|
||||
{
|
||||
${vectorName}[i].pNext = returnVector[i].template get<${vectorElementType}>().pNext;
|
||||
}
|
||||
result = static_cast<VULKAN_HPP_NAMESPACE::Result>( getDispatcher()->${vkCommand}( ${secondCallArguments} ) );
|
||||
}
|
||||
} while ( result == VULKAN_HPP_NAMESPACE::Result::eIncomplete );
|
||||
if ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess )
|
||||
{
|
||||
throwResultException( result, VULKAN_HPP_NAMESPACE_STRING"::${className}::${commandName}" );
|
||||
}
|
||||
VULKAN_HPP_ASSERT( ${counterName} <= ${vectorName}.size() );
|
||||
if ( ${counterName} < ${vectorName}.size() )
|
||||
{
|
||||
returnVector.resize( ${counterName} );
|
||||
}
|
||||
for ( ${counterType} i = 0; i < ${counterName}; i++ )
|
||||
{
|
||||
returnVector[i].template get<${vectorElementType}>() = ${vectorName}[i];
|
||||
}
|
||||
return ${vectorName};
|
||||
}
|
||||
)";
|
||||
|
||||
std::string counterName = startLowerCase( stripPrefix( commandIt->second.params[vectorParams.begin()->second].name, "p" ) );
|
||||
std::string firstCallArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, true, {}, {}, true );
|
||||
std::string secondCallArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true );
|
||||
std::string vectorName = startLowerCase( stripPrefix( commandIt->second.params[vectorParams.begin()->first].name, "p" ) );
|
||||
|
||||
return replaceWithMap( definitionTemplate,
|
||||
{ { "argumentList", argumentList },
|
||||
{ "className", initialSkipCount ? stripPrefix( commandIt->second.params[initialSkipCount - 1].type.type, "Vk" ) : "Context" },
|
||||
{ "commandName", commandName },
|
||||
{ "counterName", counterName },
|
||||
{ "counterType", commandIt->second.params[vectorParams.begin()->second].type.type },
|
||||
{ "firstCallArguments", firstCallArguments },
|
||||
{ "functionPointerCheck", generateFunctionPointerCheck( commandIt->first, commandIt->second.referencedIn ) },
|
||||
{ "secondCallArguments", secondCallArguments },
|
||||
{ "vectorElementType", vectorElementType },
|
||||
{ "vectorName", vectorName },
|
||||
{ "vkCommand", commandIt->first } } );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string const declarationTemplate =
|
||||
R"(
|
||||
template <typename X, typename Y, typename... Z>
|
||||
VULKAN_HPP_NODISCARD std::vector<StructureChain<X, Y, Z...>> ${commandName}( ${argumentList} ) const;
|
||||
)";
|
||||
|
||||
return replaceWithMap( declarationTemplate, { { "argumentList", argumentList }, { "commandName", commandName } } );
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
VulkanHppGenerator::generateRAIIHandleCommandResultMultiSuccessWithErrors2ReturnValues( std::map<std::string, CommandData>::const_iterator commandIt,
|
||||
size_t initialSkipCount,
|
||||
|
@ -455,7 +455,7 @@ private:
|
||||
std::map<size_t, size_t> const & vectorParams,
|
||||
std::set<size_t> const & templatedParams,
|
||||
bool chained,
|
||||
bool complete ) const;
|
||||
bool raii ) const;
|
||||
std::string generateBitmask( std::map<std::string, BitmaskData>::const_iterator bitmaskIt ) const;
|
||||
std::string generateBitmasks( std::vector<RequireData> const & requireData, std::set<std::string> & listedBitmasks, std::string const & title ) const;
|
||||
std::string generateCallArgumentsEnhanced( CommandData const & commandData,
|
||||
@ -726,11 +726,6 @@ private:
|
||||
size_t initialSkipCount,
|
||||
bool definition,
|
||||
std::vector<size_t> const & returnParamIndices ) const;
|
||||
std::string generateRAIIHandleCommandResultMultiSuccessWithErrors2Return1VectorEnumerateChain( std::map<std::string, CommandData>::const_iterator commandIt,
|
||||
size_t initialSkipCount,
|
||||
std::map<size_t, size_t> const & vectorParamIndices,
|
||||
std::vector<size_t> const & returnParamIndices,
|
||||
bool definition ) const;
|
||||
std::string generateRAIIHandleCommandResultMultiSuccessWithErrors2ReturnValues( std::map<std::string, CommandData>::const_iterator commandIt,
|
||||
size_t initialSkipCount,
|
||||
std::map<size_t, size_t> const & vectorParams,
|
||||
|
@ -2913,9 +2913,8 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
VULKAN_HPP_NODISCARD std::vector<VULKAN_HPP_NAMESPACE::SurfaceFormat2KHR>
|
||||
getSurfaceFormats2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSurfaceInfo2KHR & surfaceInfo ) const;
|
||||
|
||||
template <typename X, typename Y, typename... Z>
|
||||
VULKAN_HPP_NODISCARD std::vector<StructureChain<X, Y, Z...>>
|
||||
getSurfaceFormats2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSurfaceInfo2KHR & surfaceInfo ) const;
|
||||
template <typename StructureChain>
|
||||
VULKAN_HPP_NODISCARD std::vector<StructureChain> getSurfaceFormats2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSurfaceInfo2KHR & surfaceInfo ) const;
|
||||
|
||||
//=== VK_KHR_get_display_properties2 ===
|
||||
|
||||
@ -14206,52 +14205,48 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
return surfaceFormats;
|
||||
}
|
||||
|
||||
template <typename X, typename Y, typename... Z>
|
||||
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector<StructureChain<X, Y, Z...>>
|
||||
template <typename StructureChain>
|
||||
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector<StructureChain>
|
||||
PhysicalDevice::getSurfaceFormats2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSurfaceInfo2KHR & surfaceInfo ) const
|
||||
{
|
||||
VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceSurfaceFormats2KHR &&
|
||||
"Function <vkGetPhysicalDeviceSurfaceFormats2KHR> needs extension <VK_KHR_get_surface_capabilities2> enabled!" );
|
||||
std::vector<StructureChain<X, Y, Z...>> returnVector;
|
||||
|
||||
std::vector<StructureChain> structureChains;
|
||||
std::vector<VULKAN_HPP_NAMESPACE::SurfaceFormat2KHR> surfaceFormats;
|
||||
uint32_t surfaceFormatCount;
|
||||
VULKAN_HPP_NAMESPACE::Result result;
|
||||
VkResult result;
|
||||
do
|
||||
{
|
||||
result = static_cast<VULKAN_HPP_NAMESPACE::Result>(
|
||||
getDispatcher()->vkGetPhysicalDeviceSurfaceFormats2KHR( static_cast<VkPhysicalDevice>( m_physicalDevice ),
|
||||
reinterpret_cast<const VkPhysicalDeviceSurfaceInfo2KHR *>( &surfaceInfo ),
|
||||
&surfaceFormatCount,
|
||||
nullptr ) );
|
||||
if ( ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) && surfaceFormatCount )
|
||||
result = getDispatcher()->vkGetPhysicalDeviceSurfaceFormats2KHR( static_cast<VkPhysicalDevice>( m_physicalDevice ),
|
||||
reinterpret_cast<const VkPhysicalDeviceSurfaceInfo2KHR *>( &surfaceInfo ),
|
||||
&surfaceFormatCount,
|
||||
nullptr );
|
||||
if ( ( result == VK_SUCCESS ) && surfaceFormatCount )
|
||||
{
|
||||
returnVector.resize( surfaceFormatCount );
|
||||
structureChains.resize( surfaceFormatCount );
|
||||
surfaceFormats.resize( surfaceFormatCount );
|
||||
for ( uint32_t i = 0; i < surfaceFormatCount; i++ )
|
||||
{
|
||||
surfaceFormats[i].pNext = returnVector[i].template get<VULKAN_HPP_NAMESPACE::SurfaceFormat2KHR>().pNext;
|
||||
surfaceFormats[i].pNext = structureChains[i].template get<VULKAN_HPP_NAMESPACE::SurfaceFormat2KHR>().pNext;
|
||||
}
|
||||
result = static_cast<VULKAN_HPP_NAMESPACE::Result>(
|
||||
getDispatcher()->vkGetPhysicalDeviceSurfaceFormats2KHR( static_cast<VkPhysicalDevice>( m_physicalDevice ),
|
||||
reinterpret_cast<const VkPhysicalDeviceSurfaceInfo2KHR *>( &surfaceInfo ),
|
||||
&surfaceFormatCount,
|
||||
reinterpret_cast<VkSurfaceFormat2KHR *>( surfaceFormats.data() ) ) );
|
||||
result = getDispatcher()->vkGetPhysicalDeviceSurfaceFormats2KHR( static_cast<VkPhysicalDevice>( m_physicalDevice ),
|
||||
reinterpret_cast<const VkPhysicalDeviceSurfaceInfo2KHR *>( &surfaceInfo ),
|
||||
&surfaceFormatCount,
|
||||
reinterpret_cast<VkSurfaceFormat2KHR *>( surfaceFormats.data() ) );
|
||||
}
|
||||
} while ( result == VULKAN_HPP_NAMESPACE::Result::eIncomplete );
|
||||
if ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess )
|
||||
{
|
||||
throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::PhysicalDevice::getSurfaceFormats2KHR" );
|
||||
}
|
||||
} while ( result == VK_INCOMPLETE );
|
||||
resultCheck( static_cast<VULKAN_HPP_NAMESPACE::Result>( result ), VULKAN_HPP_NAMESPACE_STRING "::PhysicalDevice::getSurfaceFormats2KHR" );
|
||||
VULKAN_HPP_ASSERT( surfaceFormatCount <= surfaceFormats.size() );
|
||||
if ( surfaceFormatCount < surfaceFormats.size() )
|
||||
{
|
||||
returnVector.resize( surfaceFormatCount );
|
||||
structureChains.resize( surfaceFormatCount );
|
||||
}
|
||||
for ( uint32_t i = 0; i < surfaceFormatCount; i++ )
|
||||
{
|
||||
returnVector[i].template get<VULKAN_HPP_NAMESPACE::SurfaceFormat2KHR>() = surfaceFormats[i];
|
||||
structureChains[i].template get<VULKAN_HPP_NAMESPACE::SurfaceFormat2KHR>() = surfaceFormats[i];
|
||||
}
|
||||
return surfaceFormats;
|
||||
return structureChains;
|
||||
}
|
||||
|
||||
//=== VK_KHR_get_display_properties2 ===
|
||||
|
Loading…
Reference in New Issue
Block a user