From 5075c94b8aa3e21d8894c35fdcdcff566acf48c7 Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Wed, 22 Jun 2022 09:21:34 +0200 Subject: [PATCH] Combine two types of commands into one generation function --- VulkanHppGenerator.cpp | 227 +++++++++++------------------------------ VulkanHppGenerator.hpp | 11 +- vulkan/vulkan_raii.hpp | 115 +++++++++++---------- 3 files changed, 124 insertions(+), 229 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 3008deb..5e0d7b8 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -38,6 +38,12 @@ std::pair generateEnumSuffixes( std::string const & na std::string generateEnumValueName( std::string const & enumName, std::string const & valueName, bool bitmask, std::set const & tags ); std::string generateNamespacedType( std::string const & type ); std::string generateNoDiscard( bool returnsSomething, bool multiSuccessCodes, bool multiErrorCodes ); +std::string generateNoExcept( std::vector const & errorCodes, + std::vector const & returnParams, + std::map const & vectorParams, + bool singular, + bool vectorSizeCheck, + bool raii ); std::string generateStandardArray( std::string const & type, std::vector const & sizes ); std::string generateStandardArrayWrapper( std::string const & type, std::vector const & sizes ); std::string generateSuccessCode( std::string const & code, std::set const & tags ); @@ -3460,25 +3466,28 @@ std::string VulkanHppGenerator::generateCommandEnhanced( std::string const & std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags, singular, unique ); std::string argumentList = generateArgumentListEnhanced( commandData.params, returnParams, vectorParams, skippedParams, singularParams, templatedParams, definition, withAllocator, chained, true ); - std::string constString = commandData.handle.empty() ? "" : " const"; - - // noexcept is only possible with no error codes, and the return param (if any) is not a vector param (unless it's the singular version) - std::string noexceptString = - ( commandData.errorCodes.empty() && - ( singular || returnParams.empty() || - ( std::find_if( returnParams.begin(), returnParams.end(), [&vectorParams]( size_t rp ) { return vectorParams.find( rp ) != vectorParams.end(); } ) == - returnParams.end() ) ) ) - ? ( vectorSizeCheck.first ? " VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : " VULKAN_HPP_NOEXCEPT" ) - : ""; + std::string constString = commandData.handle.empty() ? "" : " const"; + std::string noexceptString = generateNoExcept( commandData.errorCodes, returnParams, vectorParams, singular, vectorSizeCheck.first, false ); if ( definition ) { std::string vectorSizeCheckString = vectorSizeCheck.first ? generateVectorSizeCheck( name, commandData, initialSkipCount, vectorSizeCheck.second, skippedParams, false ) : ""; std::string returnVariable = generateReturnVariable( commandData, returnParams, vectorParams, chained, singular ); - std::string dataDeclarations = generateDataDeclarations( - commandData, returnParams, vectorParams, templatedParams, singular, withAllocator, chained, unique, dataTypes, dataType, returnType, returnVariable ); - std::string dataPreparation = generateDataPreparation( + std::string dataDeclarations = generateDataDeclarations( commandData, + returnParams, + vectorParams, + templatedParams, + singular, + withAllocator, + chained, + unique, + false, + dataTypes, + dataType, + returnType, + returnVariable ); + std::string dataPreparation = generateDataPreparation( commandData, initialSkipCount, returnParams, vectorParams, templatedParams, singular, withAllocator, unique, chained, enumerating ); std::string dataSizeChecks = generateDataSizeChecks( commandData, returnParams, dataTypes, vectorParams, templatedParams, singular ); std::string callSequence = @@ -4660,6 +4669,7 @@ std::string VulkanHppGenerator::generateDataDeclarations( CommandData const & bool withAllocator, bool chained, bool unique, + bool raii, std::vector const & dataTypes, std::string const & dataType, std::string const & returnType, @@ -4736,10 +4746,11 @@ std::string VulkanHppGenerator::generateDataDeclarations( CommandData const & } else { - std::string structureChainAllocator = withAllocator ? ( "( structureChainAllocator )" ) : ""; - std::string vectorVariable = startLowerCase( stripPrefix( commandData.params[returnParams[1]].name, "p" ) ); + std::string structureChainAllocator = raii ? "" : ", StructureChainAllocator"; + std::string structureChainInitializer = withAllocator ? ( "( structureChainAllocator )" ) : ""; + std::string vectorVariable = startLowerCase( stripPrefix( commandData.params[returnParams[1]].name, "p" ) ); - std::string const dataDeclarationTemplate = R"(std::vector structureChains${structureChainAllocator}; + std::string const dataDeclarationTemplate = R"(std::vector structureChains${structureChainInitializer}; std::vector<${vectorElementType}> ${vectorVariable}; ${counterType} ${counterVariable};)"; @@ -4748,6 +4759,7 @@ std::string VulkanHppGenerator::generateDataDeclarations( CommandData const & { "counterType", dataTypes[0] }, { "counterVariable", counterVariable }, { "structureChainAllocator", structureChainAllocator }, + { "structureChainInitializer", structureChainInitializer }, { "vectorElementType", dataTypes[1] }, { "vectorVariable", vectorVariable }, } ); @@ -4776,13 +4788,17 @@ std::string VulkanHppGenerator::generateDataDeclarations( CommandData const & } else { - std::string allocatorType = startUpperCase( stripPrefix( dataTypes[0], "VULKAN_HPP_NAMESPACE::" ) ) + "Allocator"; + std::string allocatorType = raii ? "" : ( startUpperCase( stripPrefix( dataTypes[0], "VULKAN_HPP_NAMESPACE::" ) ) + "Allocator" ); std::string allocateInitializer = withAllocator ? ( ", " + startLowerCase( allocatorType ) ) : ""; - std::string vectorSize = startLowerCase( stripPrefix( commandData.params[vectorParams.begin()->first].name, "p" ) ) + ".size()"; + if ( !raii ) + { + allocatorType = ", " + allocatorType; + } + std::string vectorSize = startLowerCase( stripPrefix( commandData.params[vectorParams.begin()->first].name, "p" ) ) + ".size()"; std::string const dataDeclarationTemplate = - R"(std::pair,${secondDataType}> data( std::piecewise_construct, std::forward_as_tuple( ${vectorSize}${allocateInitializer} ), std::forward_as_tuple( 0 ) ); - std::vector<${firstDataType}, ${allocatorType}> & ${firstDataVariable} = data.first; + R"(std::pair,${secondDataType}> data( std::piecewise_construct, std::forward_as_tuple( ${vectorSize}${allocateInitializer} ), std::forward_as_tuple( 0 ) ); + std::vector<${firstDataType}${allocatorType}> & ${firstDataVariable} = data.first; ${secondDataType} & ${secondDataVariable} = data.second;)"; dataDeclarations = replaceWithMap( dataDeclarationTemplate, @@ -6152,7 +6168,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandEnhanced( std::map>> vectorSizeCheck = needsVectorSizeCheck( commandIt->second.params, vectorParams, returnParams, singularParams ); - std::string noexceptString = ( vectorSizeCheck.first || !commandIt->second.errorCodes.empty() ) ? "" : " VULKAN_HPP_NOEXCEPT"; + std::string noexceptString = generateNoExcept( commandIt->second.errorCodes, returnParams, vectorParams, singular, vectorSizeCheck.first, true ); std::string returnType = generateReturnType( commandIt->second, returnParams, false, chained, true, dataType ); if ( definition ) @@ -6174,11 +6190,11 @@ ${vectorSizeCheck} )"; std::string callSequence = - generateCallSequence( commandIt->first, commandIt->second, returnParams, vectorParams, initialSkipCount, singularParams, templatedParams, false, true ); + generateCallSequence( commandIt->first, commandIt->second, returnParams, vectorParams, initialSkipCount, singularParams, templatedParams, chained, true ); std::string className = initialSkipCount ? stripPrefix( commandIt->second.params[initialSkipCount - 1].type.type, "Vk" ) : "Context"; std::string returnVariable = generateReturnVariable( commandIt->second, returnParams, vectorParams, chained, singular ); std::string dataDeclarations = generateDataDeclarations( - commandIt->second, returnParams, vectorParams, templatedParams, singular, false, chained, false, dataTypes, dataType, returnType, returnVariable ); + commandIt->second, returnParams, vectorParams, templatedParams, singular, false, chained, false, true, dataTypes, dataType, returnType, returnVariable ); std::string dataPreparation = generateDataPreparation( commandIt->second, initialSkipCount, returnParams, vectorParams, templatedParams, singular, false, false, chained, enumerating ); std::string dataSizeChecks = generateDataSizeChecks( commandIt->second, returnParams, dataTypes, vectorParams, templatedParams, singular ); @@ -7432,8 +7448,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWith { // two returns and two vectors! But one input vector, one output vector of the same size, // and one output value - str = generateRAIIHandleCommandResultSingleSuccessWithErrors2ReturnValueVectorValue( - commandIt, initialSkipCount, vectorParams, returnParams, definition ); + str = generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, returnParams, vectorParams, definition, false, false ); str += generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, returnParams, vectorParams, definition, false, true ); } } @@ -7446,74 +7461,6 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWith return str; } -std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWithErrors2ReturnValueVectorValue( - 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, false, false ); - std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags, false, false ); - std::string valueType = commandIt->second.params[returnParams[1]].type.type; - std::string vectorElementType = commandIt->second.params[returnParams[0]].type.type; - - if ( definition ) - { - std::string const definitionTemplate = - R"( - VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::pair, ${valueType}> ${className}::${commandName}( ${argumentList} ) const - {${functionPointerCheck} - std::pair, ${valueType}> data( std::piecewise_construct, std::forward_as_tuple( ${vectorSize} ), std::forward_as_tuple( 0 ) ); - std::vector<${vectorElementType}> & ${vectorName} = data.first; - ${valueType} & ${valueName} = data.second; - VULKAN_HPP_NAMESPACE::Result result = static_cast( getDispatcher()->${vkCommand}( ${callArguments} ) ); - if ( ${failureCheck} ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING"::${className}::${commandName}" ); - } - return data; - } -)"; - - std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true ); - std::string valueName = startLowerCase( stripPrefix( commandIt->second.params[returnParams[1]].name, "p" ) ); - std::string vectorName = startLowerCase( stripPrefix( commandIt->second.params[returnParams[0]].name, "p" ) ); - std::string vectorSize = startLowerCase( stripPrefix( commandIt->second.params[vectorParams.begin()->first].name, "p" ) ) + ".size()"; - - return replaceWithMap( definitionTemplate, - { { "argumentList", argumentList }, - { "callArguments", callArguments }, - { "className", stripPrefix( commandIt->second.params[initialSkipCount - 1].type.type, "Vk" ) }, - { "commandName", commandName }, - { "failureCheck", generateFailureCheck( commandIt->second.successCodes ) }, - { "functionPointerCheck", generateFunctionPointerCheck( commandIt->first, commandIt->second.referencedIn ) }, - { "valueName", valueName }, - { "valueType", valueType }, - { "vectorElementType", vectorElementType }, - { "vectorName", vectorName }, - { "vectorSize", vectorSize }, - { "vkCommand", commandIt->first } } ); - } - else - { - std::string const declarationTemplate = - R"( - VULKAN_HPP_NODISCARD std::pair, ${valueType}> ${commandName}( ${argumentList} ) const; -)"; - - return replaceWithMap( declarationTemplate, - { - { "argumentList", argumentList }, - { "commandName", commandName }, - { "valueType", valueType }, - { "vectorElementType", vectorElementType }, - } ); - } -} - std::string VulkanHppGenerator::generateRAIIHandleCommandValue( std::map::const_iterator commandIt, size_t initialSkipCount, bool definition ) const @@ -7602,7 +7549,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandVoid( std::mapsecond.params[returnParams[1]].type.type ) ) { - str += generateRAIIHandleCommandVoid2ReturnEnumerateChain( commandIt, initialSkipCount, vectorParams, returnParams, definition ); + str += generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, returnParams, vectorParams, definition, true, false ); } } } @@ -7732,77 +7679,6 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandVoid1ReturnVoidVectorSi } } -std::string VulkanHppGenerator::generateRAIIHandleCommandVoid2ReturnEnumerateChain( 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, false, false ); - std::string counterName = startLowerCase( stripPrefix( commandIt->second.params[vectorParams.begin()->second].name, "p" ) ); - std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags, false, false ); - - if ( definition ) - { - const std::string definitionTemplate = - R"( - template - VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector ${className}::${commandName}( ${argumentList} ) const - {${functionPointerCheck} - ${counterType} ${counterName}; - getDispatcher()->${vkCommand}( ${firstCallArguments} ); - std::vector returnVector( ${counterName} ); - std::vector<${vectorElementType}> ${vectorName}( ${counterName} ); - for ( ${counterType} i = 0; i < ${counterName}; i++ ) - { - ${vectorName}[i].pNext = returnVector[i].template get<${vectorElementType}>().pNext; - } - getDispatcher()->${vkCommand}( ${secondCallArguments} ); - VULKAN_HPP_ASSERT( ${counterName} <= ${vectorName}.size() ); - for ( ${counterType} i = 0; i < ${counterName}; i++ ) - { - returnVector[i].template get<${vectorElementType}>() = ${vectorName}[i]; - } - return returnVector; - } -)"; - - std::string firstCallArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, true, {}, {}, true ); - std::string secondCallArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true ); - std::string vectorElementType = stripPostfix( commandIt->second.params[vectorParams.begin()->first].type.compose( "VULKAN_HPP_NAMESPACE" ), "*" ); - std::string vectorName = startLowerCase( stripPrefix( commandIt->second.params[vectorParams.begin()->first].name, "p" ) ); - - return replaceWithMap( definitionTemplate, - { { "argumentList", argumentList }, - { "className", stripPrefix( commandIt->second.params[initialSkipCount - 1].type.type, "Vk" ) }, - { "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::pair VulkanHppGenerator::generateRAIIHandleConstructor( std::pair const & handle, std::map::const_iterator constructorIt, @@ -9217,7 +9093,9 @@ std::string VulkanHppGenerator::generateReturnType( if ( chained ) { assert( !unique ); - modifiedDataType = beginsWith( dataType, "std::vector" ) ? "std::vector" : "StructureChain"; + modifiedDataType = beginsWith( dataType, "std::vector" ) + ? ( std::string( "std::vector " ) + : " StructureChain "; } else if ( unique ) { @@ -13627,6 +13505,23 @@ std::string generateNoDiscard( bool returnsSomething, bool multiSuccessCodes, bo return ( returnsSomething || multiSuccessCodes ) ? "VULKAN_HPP_NODISCARD " : ( multiErrorCodes ? "VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS " : "" ); } +std::string generateNoExcept( std::vector const & errorCodes, + std::vector const & returnParams, + std::map const & vectorParams, + bool singular, + bool vectorSizeCheck, + bool raii ) +{ + // noexcept is only possible with no error codes, and the return param (if any) is not a vector param (unless it's the singular version) + return ( errorCodes.empty() && + ( singular || returnParams.empty() || + ( std::find_if( returnParams.begin(), + returnParams.end(), + [&vectorParams]( size_t rp ) { return vectorParams.find( rp ) != vectorParams.end(); } ) == returnParams.end() ) ) ) + ? ( vectorSizeCheck ? ( raii ? "" : " VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" ) : " VULKAN_HPP_NOEXCEPT" ) + : ""; +} + std::string generateStandardArray( std::string const & type, std::vector const & sizes ) { std::string arrayString = "std::array<" + type + "," + sizes.back() + ">"; diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index d887cb5..3ca23b5 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -623,6 +623,7 @@ private: bool withAllocator, bool chained, bool unique, + bool raii, std::vector const & dataTypes, std::string const & dataType, std::string const & returnType, @@ -782,11 +783,6 @@ private: size_t initialSkipCount, bool definition, std::vector const & returnParamIndices ) const; - std::string generateRAIIHandleCommandResultSingleSuccessWithErrors2ReturnValueVectorValue( std::map::const_iterator commandIt, - size_t initialSkipCount, - std::map const & vectorParamIndices, - std::vector const & returnParamIndices, - bool definition ) const; std::string generateRAIIHandleCommandValue( std::map::const_iterator commandIt, size_t initialSkipCount, bool definition ) const; std::string generateRAIIHandleCommandVoid( std::map::const_iterator commandIt, size_t initialSkipCount, bool definition ) const; std::string generateRAIIHandleCommandVoid1ReturnVector( std::map::const_iterator commandIt, @@ -799,11 +795,6 @@ private: std::map const & vectorParamIndices, size_t returnParam, bool definition ) const; - std::string generateRAIIHandleCommandVoid2ReturnEnumerateChain( std::map::const_iterator commandIt, - size_t initialSkipCount, - std::map const & vectorParamIndices, - std::vector const & returnParamIndices, - bool definition ) const; std::pair generateRAIIHandleConstructor( std::pair const & handle, std::map::const_iterator constructorIt, std::string const & enter, diff --git a/vulkan/vulkan_raii.hpp b/vulkan/vulkan_raii.hpp index 9700082..654f049 100644 --- a/vulkan/vulkan_raii.hpp +++ b/vulkan/vulkan_raii.hpp @@ -2684,7 +2684,7 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_NODISCARD VULKAN_HPP_NAMESPACE::PhysicalDeviceProperties getProperties() const VULKAN_HPP_NOEXCEPT; - VULKAN_HPP_NODISCARD std::vector getQueueFamilyProperties() const VULKAN_HPP_NOEXCEPT; + VULKAN_HPP_NODISCARD std::vector getQueueFamilyProperties() const; VULKAN_HPP_NODISCARD VULKAN_HPP_NAMESPACE::PhysicalDeviceMemoryProperties getMemoryProperties() const VULKAN_HPP_NOEXCEPT; @@ -2702,7 +2702,7 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_NAMESPACE::ImageType type, VULKAN_HPP_NAMESPACE::SampleCountFlagBits samples, VULKAN_HPP_NAMESPACE::ImageUsageFlags usage, - VULKAN_HPP_NAMESPACE::ImageTiling tiling ) const VULKAN_HPP_NOEXCEPT; + VULKAN_HPP_NAMESPACE::ImageTiling tiling ) const; //=== VK_VERSION_1_1 === @@ -2728,7 +2728,7 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_NODISCARD StructureChain getImageFormatProperties2( const VULKAN_HPP_NAMESPACE::PhysicalDeviceImageFormatInfo2 & imageFormatInfo ) const; - VULKAN_HPP_NODISCARD std::vector getQueueFamilyProperties2() const VULKAN_HPP_NOEXCEPT; + VULKAN_HPP_NODISCARD std::vector getQueueFamilyProperties2() const; template VULKAN_HPP_NODISCARD std::vector getQueueFamilyProperties2() const; @@ -2739,7 +2739,7 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_NODISCARD StructureChain getMemoryProperties2() const VULKAN_HPP_NOEXCEPT; VULKAN_HPP_NODISCARD std::vector - getSparseImageFormatProperties2( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSparseImageFormatInfo2 & formatInfo ) const VULKAN_HPP_NOEXCEPT; + getSparseImageFormatProperties2( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSparseImageFormatInfo2 & formatInfo ) const; VULKAN_HPP_NODISCARD VULKAN_HPP_NAMESPACE::ExternalBufferProperties getExternalBufferProperties( const VULKAN_HPP_NAMESPACE::PhysicalDeviceExternalBufferInfo & externalBufferInfo ) const VULKAN_HPP_NOEXCEPT; @@ -2852,7 +2852,7 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_NODISCARD StructureChain getImageFormatProperties2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceImageFormatInfo2 & imageFormatInfo ) const; - VULKAN_HPP_NODISCARD std::vector getQueueFamilyProperties2KHR() const VULKAN_HPP_NOEXCEPT; + VULKAN_HPP_NODISCARD std::vector getQueueFamilyProperties2KHR() const; template VULKAN_HPP_NODISCARD std::vector getQueueFamilyProperties2KHR() const; @@ -2863,7 +2863,7 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_NODISCARD StructureChain getMemoryProperties2KHR() const VULKAN_HPP_NOEXCEPT; VULKAN_HPP_NODISCARD std::vector - getSparseImageFormatProperties2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSparseImageFormatInfo2 & formatInfo ) const VULKAN_HPP_NOEXCEPT; + getSparseImageFormatProperties2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSparseImageFormatInfo2 & formatInfo ) const; //=== VK_KHR_external_memory_capabilities === @@ -3268,7 +3268,7 @@ namespace VULKAN_HPP_NAMESPACE getBufferMemoryRequirements2( const VULKAN_HPP_NAMESPACE::BufferMemoryRequirementsInfo2 & info ) const VULKAN_HPP_NOEXCEPT; VULKAN_HPP_NODISCARD std::vector - getImageSparseMemoryRequirements2( const VULKAN_HPP_NAMESPACE::ImageSparseMemoryRequirementsInfo2 & info ) const VULKAN_HPP_NOEXCEPT; + getImageSparseMemoryRequirements2( const VULKAN_HPP_NAMESPACE::ImageSparseMemoryRequirementsInfo2 & info ) const; VULKAN_HPP_NODISCARD VULKAN_HPP_RAII_NAMESPACE::Queue getQueue2( VULKAN_HPP_NAMESPACE::DeviceQueueInfo2 const & queueInfo ) const; @@ -3335,7 +3335,7 @@ namespace VULKAN_HPP_NAMESPACE getImageMemoryRequirements( const VULKAN_HPP_NAMESPACE::DeviceImageMemoryRequirements & info ) const VULKAN_HPP_NOEXCEPT; VULKAN_HPP_NODISCARD std::vector - getImageSparseMemoryRequirements( const VULKAN_HPP_NAMESPACE::DeviceImageMemoryRequirements & info ) const VULKAN_HPP_NOEXCEPT; + getImageSparseMemoryRequirements( const VULKAN_HPP_NAMESPACE::DeviceImageMemoryRequirements & info ) const; //=== VK_KHR_swapchain === @@ -3518,7 +3518,7 @@ namespace VULKAN_HPP_NAMESPACE getBufferMemoryRequirements2KHR( const VULKAN_HPP_NAMESPACE::BufferMemoryRequirementsInfo2 & info ) const VULKAN_HPP_NOEXCEPT; VULKAN_HPP_NODISCARD std::vector - getImageSparseMemoryRequirements2KHR( const VULKAN_HPP_NAMESPACE::ImageSparseMemoryRequirementsInfo2 & info ) const VULKAN_HPP_NOEXCEPT; + getImageSparseMemoryRequirements2KHR( const VULKAN_HPP_NAMESPACE::ImageSparseMemoryRequirementsInfo2 & info ) const; //=== VK_KHR_acceleration_structure === @@ -3802,7 +3802,7 @@ namespace VULKAN_HPP_NAMESPACE getImageMemoryRequirementsKHR( const VULKAN_HPP_NAMESPACE::DeviceImageMemoryRequirements & info ) const VULKAN_HPP_NOEXCEPT; VULKAN_HPP_NODISCARD std::vector - getImageSparseMemoryRequirementsKHR( const VULKAN_HPP_NAMESPACE::DeviceImageMemoryRequirements & info ) const VULKAN_HPP_NOEXCEPT; + getImageSparseMemoryRequirementsKHR( const VULKAN_HPP_NAMESPACE::DeviceImageMemoryRequirements & info ) const; //=== VK_VALVE_descriptor_set_host_mapping === @@ -7310,7 +7310,7 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_NODISCARD VULKAN_HPP_NAMESPACE::MemoryRequirements getMemoryRequirements() const VULKAN_HPP_NOEXCEPT; - VULKAN_HPP_NODISCARD std::vector getSparseMemoryRequirements() const VULKAN_HPP_NOEXCEPT; + VULKAN_HPP_NODISCARD std::vector getSparseMemoryRequirements() const; VULKAN_HPP_NODISCARD VULKAN_HPP_NAMESPACE::SubresourceLayout getSubresourceLayout( const VULKAN_HPP_NAMESPACE::ImageSubresource & subresource ) const VULKAN_HPP_NOEXCEPT; @@ -8609,7 +8609,7 @@ namespace VULKAN_HPP_NAMESPACE //=== VK_NV_device_diagnostic_checkpoints === - VULKAN_HPP_NODISCARD std::vector getCheckpointDataNV() const VULKAN_HPP_NOEXCEPT; + VULKAN_HPP_NODISCARD std::vector getCheckpointDataNV() const; //=== VK_INTEL_performance_query === @@ -8620,7 +8620,7 @@ namespace VULKAN_HPP_NAMESPACE void submit2KHR( ArrayProxy const & submits, VULKAN_HPP_NAMESPACE::Fence fence VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT ) const; - VULKAN_HPP_NODISCARD std::vector getCheckpointData2NV() const VULKAN_HPP_NOEXCEPT; + VULKAN_HPP_NODISCARD std::vector getCheckpointData2NV() const; private: VULKAN_HPP_NAMESPACE::Queue m_queue = {}; @@ -10226,8 +10226,7 @@ namespace VULKAN_HPP_NAMESPACE return properties; } - VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector - PhysicalDevice::getQueueFamilyProperties() const VULKAN_HPP_NOEXCEPT + VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector PhysicalDevice::getQueueFamilyProperties() const { std::vector queueFamilyProperties; uint32_t queueFamilyPropertyCount; @@ -10512,8 +10511,7 @@ namespace VULKAN_HPP_NAMESPACE return memoryRequirements; } - VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector - Image::getSparseMemoryRequirements() const VULKAN_HPP_NOEXCEPT + VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector Image::getSparseMemoryRequirements() const { std::vector sparseMemoryRequirements; uint32_t sparseMemoryRequirementCount; @@ -10538,7 +10536,7 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_NAMESPACE::ImageType type, VULKAN_HPP_NAMESPACE::SampleCountFlagBits samples, VULKAN_HPP_NAMESPACE::ImageUsageFlags usage, - VULKAN_HPP_NAMESPACE::ImageTiling tiling ) const VULKAN_HPP_NOEXCEPT + VULKAN_HPP_NAMESPACE::ImageTiling tiling ) const { std::vector properties; uint32_t propertyCount; @@ -11499,7 +11497,7 @@ namespace VULKAN_HPP_NAMESPACE } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector - Device::getImageSparseMemoryRequirements2( const VULKAN_HPP_NAMESPACE::ImageSparseMemoryRequirementsInfo2 & info ) const VULKAN_HPP_NOEXCEPT + Device::getImageSparseMemoryRequirements2( const VULKAN_HPP_NAMESPACE::ImageSparseMemoryRequirementsInfo2 & info ) const { std::vector sparseMemoryRequirements; uint32_t sparseMemoryRequirementCount; @@ -11611,8 +11609,7 @@ namespace VULKAN_HPP_NAMESPACE return structureChain; } - VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector - PhysicalDevice::getQueueFamilyProperties2() const VULKAN_HPP_NOEXCEPT + VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector PhysicalDevice::getQueueFamilyProperties2() const { std::vector queueFamilyProperties; uint32_t queueFamilyPropertyCount; @@ -11633,23 +11630,30 @@ namespace VULKAN_HPP_NAMESPACE template VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector PhysicalDevice::getQueueFamilyProperties2() const { - uint32_t queueFamilyPropertyCount; + std::vector structureChains; + std::vector queueFamilyProperties; + uint32_t queueFamilyPropertyCount; getDispatcher()->vkGetPhysicalDeviceQueueFamilyProperties2( static_cast( m_physicalDevice ), &queueFamilyPropertyCount, nullptr ); - std::vector returnVector( queueFamilyPropertyCount ); - std::vector queueFamilyProperties( queueFamilyPropertyCount ); + structureChains.resize( queueFamilyPropertyCount ); + queueFamilyProperties.resize( queueFamilyPropertyCount ); for ( uint32_t i = 0; i < queueFamilyPropertyCount; i++ ) { - queueFamilyProperties[i].pNext = returnVector[i].template get().pNext; + queueFamilyProperties[i].pNext = structureChains[i].template get().pNext; } getDispatcher()->vkGetPhysicalDeviceQueueFamilyProperties2( static_cast( m_physicalDevice ), &queueFamilyPropertyCount, reinterpret_cast( queueFamilyProperties.data() ) ); + VULKAN_HPP_ASSERT( queueFamilyPropertyCount <= queueFamilyProperties.size() ); + if ( queueFamilyPropertyCount < queueFamilyProperties.size() ) + { + structureChains.resize( queueFamilyPropertyCount ); + } for ( uint32_t i = 0; i < queueFamilyPropertyCount; i++ ) { - returnVector[i].template get() = queueFamilyProperties[i]; + structureChains[i].template get() = queueFamilyProperties[i]; } - return returnVector; + return structureChains; } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::PhysicalDeviceMemoryProperties2 @@ -11675,7 +11679,7 @@ namespace VULKAN_HPP_NAMESPACE } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector - PhysicalDevice::getSparseImageFormatProperties2( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSparseImageFormatInfo2 & formatInfo ) const VULKAN_HPP_NOEXCEPT + PhysicalDevice::getSparseImageFormatProperties2( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSparseImageFormatInfo2 & formatInfo ) const { std::vector properties; uint32_t propertyCount; @@ -12223,7 +12227,7 @@ namespace VULKAN_HPP_NAMESPACE } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector - Device::getImageSparseMemoryRequirements( const VULKAN_HPP_NAMESPACE::DeviceImageMemoryRequirements & info ) const VULKAN_HPP_NOEXCEPT + Device::getImageSparseMemoryRequirements( const VULKAN_HPP_NAMESPACE::DeviceImageMemoryRequirements & info ) const { std::vector sparseMemoryRequirements; uint32_t sparseMemoryRequirementCount; @@ -13442,8 +13446,7 @@ namespace VULKAN_HPP_NAMESPACE return structureChain; } - VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector - PhysicalDevice::getQueueFamilyProperties2KHR() const VULKAN_HPP_NOEXCEPT + VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector PhysicalDevice::getQueueFamilyProperties2KHR() const { VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceQueueFamilyProperties2KHR && "Function needs extension enabled!" ); @@ -13469,23 +13472,31 @@ namespace VULKAN_HPP_NAMESPACE { VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceQueueFamilyProperties2KHR && "Function needs extension enabled!" ); - uint32_t queueFamilyPropertyCount; + + std::vector structureChains; + std::vector queueFamilyProperties; + uint32_t queueFamilyPropertyCount; getDispatcher()->vkGetPhysicalDeviceQueueFamilyProperties2KHR( static_cast( m_physicalDevice ), &queueFamilyPropertyCount, nullptr ); - std::vector returnVector( queueFamilyPropertyCount ); - std::vector queueFamilyProperties( queueFamilyPropertyCount ); + structureChains.resize( queueFamilyPropertyCount ); + queueFamilyProperties.resize( queueFamilyPropertyCount ); for ( uint32_t i = 0; i < queueFamilyPropertyCount; i++ ) { - queueFamilyProperties[i].pNext = returnVector[i].template get().pNext; + queueFamilyProperties[i].pNext = structureChains[i].template get().pNext; } getDispatcher()->vkGetPhysicalDeviceQueueFamilyProperties2KHR( static_cast( m_physicalDevice ), &queueFamilyPropertyCount, reinterpret_cast( queueFamilyProperties.data() ) ); + VULKAN_HPP_ASSERT( queueFamilyPropertyCount <= queueFamilyProperties.size() ); + if ( queueFamilyPropertyCount < queueFamilyProperties.size() ) + { + structureChains.resize( queueFamilyPropertyCount ); + } for ( uint32_t i = 0; i < queueFamilyPropertyCount; i++ ) { - returnVector[i].template get() = queueFamilyProperties[i]; + structureChains[i].template get() = queueFamilyProperties[i]; } - return returnVector; + return structureChains; } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::PhysicalDeviceMemoryProperties2 @@ -13516,8 +13527,8 @@ namespace VULKAN_HPP_NAMESPACE return structureChain; } - VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector PhysicalDevice::getSparseImageFormatProperties2KHR( - const VULKAN_HPP_NAMESPACE::PhysicalDeviceSparseImageFormatInfo2 & formatInfo ) const VULKAN_HPP_NOEXCEPT + VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector + PhysicalDevice::getSparseImageFormatProperties2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSparseImageFormatInfo2 & formatInfo ) const { VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceSparseImageFormatProperties2KHR && "Function needs extension enabled!" ); @@ -14738,7 +14749,7 @@ namespace VULKAN_HPP_NAMESPACE } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector - Device::getImageSparseMemoryRequirements2KHR( const VULKAN_HPP_NAMESPACE::ImageSparseMemoryRequirementsInfo2 & info ) const VULKAN_HPP_NOEXCEPT + Device::getImageSparseMemoryRequirements2KHR( const VULKAN_HPP_NAMESPACE::ImageSparseMemoryRequirementsInfo2 & info ) const { VULKAN_HPP_ASSERT( getDispatcher()->vkGetImageSparseMemoryRequirements2KHR && "Function needs extension enabled!" ); @@ -15572,19 +15583,17 @@ namespace VULKAN_HPP_NAMESPACE { VULKAN_HPP_ASSERT( getDispatcher()->vkGetCalibratedTimestampsEXT && "Function needs extension enabled!" ); + std::pair, uint64_t> data( std::piecewise_construct, std::forward_as_tuple( timestampInfos.size() ), std::forward_as_tuple( 0 ) ); std::vector & timestamps = data.first; uint64_t & maxDeviation = data.second; - VULKAN_HPP_NAMESPACE::Result result = static_cast( - getDispatcher()->vkGetCalibratedTimestampsEXT( static_cast( m_device ), - timestampInfos.size(), - reinterpret_cast( timestampInfos.data() ), - timestamps.data(), - &maxDeviation ) ); - if ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Device::getCalibratedTimestampsEXT" ); - } + VkResult result = getDispatcher()->vkGetCalibratedTimestampsEXT( static_cast( m_device ), + timestampInfos.size(), + reinterpret_cast( timestampInfos.data() ), + timestamps.data(), + &maxDeviation ); + resultCheck( static_cast( result ), VULKAN_HPP_NAMESPACE_STRING "::Device::getCalibratedTimestampsEXT" ); + return data; } @@ -15670,7 +15679,7 @@ namespace VULKAN_HPP_NAMESPACE getDispatcher()->vkCmdSetCheckpointNV( static_cast( m_commandBuffer ), reinterpret_cast( &checkpointMarker ) ); } - VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector Queue::getCheckpointDataNV() const VULKAN_HPP_NOEXCEPT + VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector Queue::getCheckpointDataNV() const { VULKAN_HPP_ASSERT( getDispatcher()->vkGetQueueCheckpointDataNV && "Function needs extension enabled!" ); @@ -16709,7 +16718,7 @@ namespace VULKAN_HPP_NAMESPACE marker ); } - VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector Queue::getCheckpointData2NV() const VULKAN_HPP_NOEXCEPT + VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector Queue::getCheckpointData2NV() const { VULKAN_HPP_ASSERT( getDispatcher()->vkGetQueueCheckpointData2NV && "Function needs extension enabled!" ); @@ -17432,7 +17441,7 @@ namespace VULKAN_HPP_NAMESPACE } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE std::vector - Device::getImageSparseMemoryRequirementsKHR( const VULKAN_HPP_NAMESPACE::DeviceImageMemoryRequirements & info ) const VULKAN_HPP_NOEXCEPT + Device::getImageSparseMemoryRequirementsKHR( const VULKAN_HPP_NAMESPACE::DeviceImageMemoryRequirements & info ) const { VULKAN_HPP_ASSERT( getDispatcher()->vkGetDeviceImageSparseMemoryRequirementsKHR && "Function needs extension enabled!" );