diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 522a30c..3d44e9a 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -2638,7 +2638,7 @@ std::string VulkanHppGenerator::generateArgumentTemplates( std::vector const & vectorParams, std::set 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"; } @@ -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::const_iterator commandIt, - size_t initialSkipCount, - std::map const & vectorParams, - std::vector const & returnParams, - bool definition ) const -{ - std::set 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 - VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector> ${className}::${commandName}( ${argumentList} ) const - {${functionPointerCheck} - std::vector> returnVector; - std::vector<${vectorElementType}> ${vectorName}; - ${counterType} ${counterName}; - VULKAN_HPP_NAMESPACE::Result result; - do - { - result = static_cast( 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( 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 - VULKAN_HPP_NODISCARD std::vector> ${commandName}( ${argumentList} ) const; -)"; - - return replaceWithMap( declarationTemplate, { { "argumentList", argumentList }, { "commandName", commandName } } ); - } -} - std::string VulkanHppGenerator::generateRAIIHandleCommandResultMultiSuccessWithErrors2ReturnValues( std::map::const_iterator commandIt, size_t initialSkipCount, diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index b39b06b..9633b86 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -455,7 +455,7 @@ private: std::map const & vectorParams, std::set const & templatedParams, bool chained, - bool complete ) const; + bool raii ) const; std::string generateBitmask( std::map::const_iterator bitmaskIt ) const; std::string generateBitmasks( std::vector const & requireData, std::set & listedBitmasks, std::string const & title ) const; std::string generateCallArgumentsEnhanced( CommandData const & commandData, @@ -726,11 +726,6 @@ private: size_t initialSkipCount, bool definition, std::vector const & returnParamIndices ) const; - std::string generateRAIIHandleCommandResultMultiSuccessWithErrors2Return1VectorEnumerateChain( std::map::const_iterator commandIt, - size_t initialSkipCount, - std::map const & vectorParamIndices, - std::vector const & returnParamIndices, - bool definition ) const; std::string generateRAIIHandleCommandResultMultiSuccessWithErrors2ReturnValues( std::map::const_iterator commandIt, size_t initialSkipCount, std::map const & vectorParams, diff --git a/vulkan/vulkan_raii.hpp b/vulkan/vulkan_raii.hpp index ce7223f..95cdbbc 100644 --- a/vulkan/vulkan_raii.hpp +++ b/vulkan/vulkan_raii.hpp @@ -2913,9 +2913,8 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_NODISCARD std::vector getSurfaceFormats2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSurfaceInfo2KHR & surfaceInfo ) const; - template - VULKAN_HPP_NODISCARD std::vector> - getSurfaceFormats2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSurfaceInfo2KHR & surfaceInfo ) const; + template + VULKAN_HPP_NODISCARD std::vector getSurfaceFormats2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSurfaceInfo2KHR & surfaceInfo ) const; //=== VK_KHR_get_display_properties2 === @@ -14206,52 +14205,48 @@ namespace VULKAN_HPP_NAMESPACE return surfaceFormats; } - template - VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector> + template + VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector PhysicalDevice::getSurfaceFormats2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSurfaceInfo2KHR & surfaceInfo ) const { VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceSurfaceFormats2KHR && "Function needs extension enabled!" ); - std::vector> returnVector; + + std::vector structureChains; std::vector surfaceFormats; uint32_t surfaceFormatCount; - VULKAN_HPP_NAMESPACE::Result result; + VkResult result; do { - result = static_cast( - getDispatcher()->vkGetPhysicalDeviceSurfaceFormats2KHR( static_cast( m_physicalDevice ), - reinterpret_cast( &surfaceInfo ), - &surfaceFormatCount, - nullptr ) ); - if ( ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) && surfaceFormatCount ) + result = getDispatcher()->vkGetPhysicalDeviceSurfaceFormats2KHR( static_cast( m_physicalDevice ), + reinterpret_cast( &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().pNext; + surfaceFormats[i].pNext = structureChains[i].template get().pNext; } - result = static_cast( - getDispatcher()->vkGetPhysicalDeviceSurfaceFormats2KHR( static_cast( m_physicalDevice ), - reinterpret_cast( &surfaceInfo ), - &surfaceFormatCount, - reinterpret_cast( surfaceFormats.data() ) ) ); + result = getDispatcher()->vkGetPhysicalDeviceSurfaceFormats2KHR( static_cast( m_physicalDevice ), + reinterpret_cast( &surfaceInfo ), + &surfaceFormatCount, + reinterpret_cast( 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( 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() = surfaceFormats[i]; + structureChains[i].template get() = surfaceFormats[i]; } - return surfaceFormats; + return structureChains; } //=== VK_KHR_get_display_properties2 ===