diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 75b89cc..f2ab62a 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -1271,14 +1271,10 @@ void VulkanHppGenerator::appendCommand( std::string & str, ( vectorParamIndices.begin()->second == std::next( vectorParamIndices.begin() )->second ) ) { assert( commandData.params[vectorParamIndices.begin()->second].type.isValue() ); - if ( commandData.params[vectorParamIndices.begin()->second].type.isValue() && - ( commandData.returnType == "void" ) ) - { - // size is given by value and the vectors are const pointers, that is input parameters; function returns - // void - appendCommandTwoVectorsVoid( str, name, commandData, vectorParamIndices, definition ); - appendedFunction = true; - } + assert( commandData.returnType == "VkResult" ); + // size is given by value and the vectors are const pointers, that is input parameters + appendCommandTwoVectors( str, name, commandData, vectorParamIndices, definition ); + appendedFunction = true; } } } @@ -1944,13 +1940,12 @@ ${commandStandard} } ) ); } -void VulkanHppGenerator::appendCommandTwoVectorsVoid( std::string & str, - std::string const & name, - CommandData const & commandData, - std::map const & vectorParamIndices, - bool definition ) const +void VulkanHppGenerator::appendCommandTwoVectors( std::string & str, + std::string const & name, + CommandData const & commandData, + std::map const & vectorParamIndices, + bool definition ) const { - assert( commandData.returnType == "void" ); assert( vectorParamIndices.size() == 2 ); std::string enter, leave; @@ -1963,15 +1958,14 @@ ${commandEnhanced} #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ ${leave})"; - str += - replaceWithMap( functionTemplate, - std::map( - { { "commandEnhanced", - constructCommandTwoVectorsVoid( name, commandData, vectorParamIndices, definition, false ) }, - { "commandStandard", constructCommandStandard( name, commandData, definition ) }, - { "enter", enter }, - { "leave", leave }, - { "newlineOnDefinition", definition ? "\n" : "" } } ) ); + str += replaceWithMap( + functionTemplate, + std::map( + { { "commandEnhanced", constructCommandTwoVectors( name, commandData, vectorParamIndices, definition ) }, + { "commandStandard", constructCommandStandard( name, commandData, definition ) }, + { "enter", enter }, + { "leave", leave }, + { "newlineOnDefinition", definition ? "\n" : "" } } ) ); } void VulkanHppGenerator::appendDispatchLoaderDynamic( std::string & str ) @@ -4854,7 +4848,8 @@ std::string R"( template , typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE${typenameCheck}> ${nodiscard}typename ResultValueType>::type ${commandName}( ${argumentList} ) const;)"; - std::string typenameCheck = ", typename B = " + handleType + "Allocator, typename std::enable_if::value, int>::type = 0"; str = replaceWithMap( @@ -4913,8 +4908,9 @@ std::string 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>::value, int>::type "; + std::string typenameCheck = + ", typename B, typename std::enable_if>::value, int>::type "; std::string vectorName = startLowerCase( stripPrefix( commandData.params[vectorParamIndices.first].name, "p" ) ); str = replaceWithMap( @@ -4941,15 +4937,18 @@ std::string R"( template >${typenameCheck}> ${nodiscard}typename ResultValueType, ${handleType}Allocator>>::type ${commandName}Unique( ${argumentList} ) const;)"; - std::string typenameCheck = ", typename B = " + handleType + "Allocator, typename std::enable_if>::value, int>::type = 0"; + std::string typenameCheck = + ", typename B = " + handleType + + "Allocator, typename std::enable_if>::value, int>::type = 0"; - str = replaceWithMap( functionTemplate, - std::map( { { "argumentList", argumentList }, - { "commandName", commandName }, - { "handleType", handleType }, - { "nodiscard", nodiscard }, - { "typenameCheck", withAllocator ? typenameCheck : "" } } ) ); + str = replaceWithMap( + functionTemplate, + std::map( { { "argumentList", argumentList }, + { "commandName", commandName }, + { "handleType", handleType }, + { "nodiscard", nodiscard }, + { "typenameCheck", withAllocator ? typenameCheck : "" } } ) ); } return str; @@ -5313,12 +5312,12 @@ std::string VulkanHppGenerator::constructCommandStandardVoid( std::string const return str; } -std::string VulkanHppGenerator::constructCommandTwoVectorsVoid( std::string const & name, - CommandData const & commandData, - std::map const & vectorParamIndices, - bool definition, - bool withAllocators ) const +std::string VulkanHppGenerator::constructCommandTwoVectors( std::string const & name, + CommandData const & commandData, + std::map const & vectorParamIndices, + bool definition ) const { + assert( !commandData.handle.empty() ); std::string str; auto firstVectorParamIt = vectorParamIndices.begin(); @@ -5327,33 +5326,22 @@ std::string VulkanHppGenerator::constructCommandTwoVectorsVoid( std::string cons assert( commandData.params[0].type.type == commandData.handle ); assert( firstVectorParamIt->second == secondVectorParamIt->second ); - std::string argumentList = - constructArgumentListEnhanced( commandData.params, { 0, firstVectorParamIt->second }, definition, withAllocators ); - std::string commandName = determineCommandName( name, commandData.params[0].type.type ); + std::set skippedParameters = { 0, firstVectorParamIt->second }; + + std::string argumentList = constructArgumentListEnhanced( commandData.params, skippedParameters, definition, false ); + std::string commandName = determineCommandName( name, commandData.params[0].type.type ); + std::pair>> vectorSizeCheck = needsVectorSizeCheck( vectorParamIndices ); + std::string noexceptString = vectorSizeCheck.first ? "VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : "VULKAN_HPP_NOEXCEPT"; if ( definition ) { const std::string functionTemplate = - R"x( template - VULKAN_HPP_INLINE void ${className}::${commandName}( ${argumentList} ) const - { -# ifdef VULKAN_HPP_NO_EXCEPTIONS - VULKAN_HPP_ASSERT( ${firstVectorName}.size() == ${secondVectorName}.size() ); -# else - if ( ${firstVectorName}.size() != ${secondVectorName}.size() ) - { - throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}: ${firstVectorName}.size() != ${secondVectorName}.size()" ); - } -#endif /*VULKAN_HPP_NO_EXCEPTIONS*/ - d.${vkCommand}( ${callArguments} ); - })x"; - - assert( beginsWith( commandData.params[firstVectorParamIt->first].name, "p" ) ); - std::string firstVectorName = - startLowerCase( stripPrefix( commandData.params[firstVectorParamIt->first].name, "p" ) ); - assert( beginsWith( commandData.params[secondVectorParamIt->first].name, "p" ) ); - std::string secondVectorName = - startLowerCase( stripPrefix( commandData.params[secondVectorParamIt->first].name, "p" ) ); + R"( template + VULKAN_HPP_INLINE Result ${className}::${commandName}( ${argumentList} ) const ${noexcept} + {${vectorSizeCheck} + Result result = static_cast( d.${vkCommand}( ${callArguments} ) ); + return createResultValue( result, VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}"${successCodeList} ); + })"; str = replaceWithMap( functionTemplate, @@ -5362,19 +5350,26 @@ std::string VulkanHppGenerator::constructCommandTwoVectorsVoid( std::string cons { "callArguments", constructCallArgumentsVectors( commandData.params, vectorParamIndices ) }, { "className", stripPrefix( commandData.handle, "Vk" ) }, { "commandName", commandName }, - { "firstVectorName", firstVectorName }, - { "secondVectorName", secondVectorName }, + { "noexcept", noexceptString }, + { "successCodeList", constructSuccessCodeList( commandData.successCodes ) }, + { "vectorSizeCheck", + vectorSizeCheck.first + ? constructVectorSizeCheck( name, commandData, vectorSizeCheck.second, skippedParameters ) + : "" }, { "vkCommand", name } } ) ); } else { const std::string functionTemplate = R"( template - void ${commandName}( ${argumentList} ) const;)"; + Result ${commandName}( ${argumentList} ) const ${noexcept};)"; - str = replaceWithMap( - functionTemplate, - std::map( { { "argumentList", argumentList }, { "commandName", commandName } } ) ); + str = replaceWithMap( functionTemplate, + std::map( { + { "argumentList", argumentList }, + { "commandName", commandName }, + { "noexcept", noexceptString }, + } ) ); } return str; } diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index d8fd142..5e5dda4 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -364,11 +364,11 @@ private: std::string const & name, CommandData const & commandData, bool definition ) const; - void appendCommandTwoVectorsVoid( std::string & str, - std::string const & name, - CommandData const & commandData, - std::map const & vectorParamIndices, - bool definition ) const; + void appendCommandTwoVectors( std::string & str, + std::string const & name, + CommandData const & commandData, + std::map const & vectorParamIndices, + bool definition ) const; void appendDispatchLoaderDynamicCommand( std::string & str, std::string & emptyFunctions, std::string & deviceFunctions, @@ -597,11 +597,13 @@ private: std::string constructCommandGetVectorOfHandles( std::string const & name, CommandData const & commandData, std::pair const & vectorParamIndices, - bool definition, bool withAllocator ) const; + bool definition, + bool withAllocator ) const; std::string constructCommandGetVectorOfUniqueHandles( std::string const & name, CommandData const & commandData, std::pair const & vectorParamIndices, - bool definition, bool withAllocator ) const; + bool definition, + bool withAllocator ) const; std::string constructCommandGetVectorOfUniqueHandlesWithAllocator( std::string const & name, CommandData const & commandData, @@ -623,11 +625,10 @@ private: constructCommandStandard( std::string const & name, CommandData const & commandData, bool definition ) const; std::string constructCommandStandardVoid( std::string const & name, CommandData const & commandData, bool definition ) const; - std::string constructCommandTwoVectorsVoid( std::string const & name, + std::string constructCommandTwoVectors( std::string const & name, CommandData const & commandData, std::map const & vectorParamIndices, - bool definition, - bool withAllocators ) const; + bool definition ) const; std::string constructConstexprString( std::pair const & structData ) const; std::string constructFunctionBodyEnhanced( std::string const & indentation, std::string const & name, diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index b1d8cf4..c21f935 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -52317,10 +52317,10 @@ namespace VULKAN_HPP_NAMESPACE Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT; # ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template - VULKAN_HPP_NODISCARD Result buildAccelerationStructureKHR( + Result buildAccelerationStructureKHR( ArrayProxy const & infos, ArrayProxy const & pOffsetInfos, - Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; + Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS; # endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VK_ENABLE_BETA_EXTENSIONS*/ @@ -92924,12 +92924,13 @@ namespace VULKAN_HPP_NAMESPACE reinterpret_cast( pInfos ), reinterpret_cast( ppOffsetInfos ) ) ); } + # ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template - VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE Result Device::buildAccelerationStructureKHR( + VULKAN_HPP_INLINE Result Device::buildAccelerationStructureKHR( ArrayProxy const & infos, ArrayProxy const & pOffsetInfos, - Dispatch const & d ) const + Dispatch const & d ) const VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS { # ifdef VULKAN_HPP_NO_EXCEPTIONS VULKAN_HPP_ASSERT( infos.size() == pOffsetInfos.size() ); @@ -92937,9 +92938,10 @@ namespace VULKAN_HPP_NAMESPACE if ( infos.size() != pOffsetInfos.size() ) { throw LogicError( VULKAN_HPP_NAMESPACE_STRING - "::VkDevice::buildAccelerationStructureKHR: infos.size() != pOffsetInfos.size()" ); + "::Device::buildAccelerationStructureKHR: infos.size() != pOffsetInfos.size()" ); } # endif /*VULKAN_HPP_NO_EXCEPTIONS*/ + Result result = static_cast( d.vkBuildAccelerationStructureKHR( m_device, infos.size(),