From 296cc72e5f2092a82b128df9487892c58431501c Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Mon, 1 Aug 2022 14:54:48 +0200 Subject: [PATCH] Combine two types of commands into one generation function --- VulkanHppGenerator.cpp | 70 +-------------------------- VulkanHppGenerator.hpp | 5 -- vulkan/vulkan_raii.hpp | 105 +++++++++++++++++++++-------------------- 3 files changed, 57 insertions(+), 123 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 1ed41c0..3282e63 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -6776,8 +6776,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWith if ( commandIt->second.params[vectorParams.begin()->second].type.type == "size_t" ) { str = generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, { returnParam }, vectorParams, definition, false, false ); - str += - generateRAIIHandleCommandResultSingleSuccessWithErrors1ReturnVoidSingular( commandIt, initialSkipCount, vectorParams, returnParam, definition ); + str += generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, { returnParam }, vectorParams, definition, false, true ); } } break; @@ -6791,8 +6790,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWith if ( commandIt->second.params[std::next( vectorParams.begin() )->second].type.type == "size_t" ) { str = generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, { returnParam }, vectorParams, definition, false, false ); - str += generateRAIIHandleCommandResultSingleSuccessWithErrors1ReturnVoidSingular( - commandIt, initialSkipCount, vectorParams, returnParam, definition ); + str += generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, { returnParam }, vectorParams, definition, false, true ); } } } @@ -6847,70 +6845,6 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWith return str; } -std::string - VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWithErrors1ReturnVoidSingular( std::map::const_iterator commandIt, - size_t initialSkipCount, - std::map const & vectorParams, - size_t returnParam, - bool definition ) const -{ - std::set skippedParams = determineSkippedParams( commandIt->second.params, initialSkipCount, vectorParams, { returnParam }, true ); - std::set singularParams = determineSingularParams( returnParam, vectorParams ); - std::string argumentList = generateArgumentListEnhanced( - commandIt->second.params, { returnParam }, vectorParams, skippedParams, singularParams, { returnParam }, definition, false, false, false ); - std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags, true, false ); - std::string argumentTemplates = generateArgumentTemplates( commandIt->second.params, { returnParam }, vectorParams, { returnParam }, false, true ); - std::string dataType = stripPrefix( commandIt->second.params[returnParam].name, "p" ) + "Type"; - - if ( definition ) - { - std::string const singularDefinitionTemplate = - R"( - ${argumentTemplates} - VULKAN_HPP_NODISCARD ${dataType} ${className}::${commandName}( ${argumentList} ) const - { - ${dataType} ${dataName}; - Result result = static_cast( getDispatcher()->${vkCommand}( ${callArguments} ) ); - if ( ${failureCheck} ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING"::${className}::${commandName}" ); - } - return ${dataName}; - } -)"; - - std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, singularParams, {}, true ); - std::string dataName = startLowerCase( stripPrefix( commandIt->second.params[returnParam].name, "p" ) ); - - return replaceWithMap( singularDefinitionTemplate, - { { "argumentList", argumentList }, - { "argumentTemplates", argumentTemplates }, - { "callArguments", callArguments }, - { "className", stripPrefix( commandIt->second.params[initialSkipCount - 1].type.type, "Vk" ) }, - { "commandName", commandName }, - { "dataName", dataName }, - { "dataType", dataType }, - { "failureCheck", generateFailureCheck( commandIt->second.successCodes ) }, - { "vkCommand", commandIt->first } } ); - } - else - { - std::string const singularDeclarationTemplate = - R"( - ${argumentTemplates} - VULKAN_HPP_NODISCARD ${dataType} ${commandName}( ${argumentList} ) const; -)"; - - return replaceWithMap( singularDeclarationTemplate, - { - { "argumentList", argumentList }, - { "argumentTemplates", argumentTemplates }, - { "commandName", commandName }, - { "dataType", dataType }, - } ); - } -} - std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWithErrors2Return( std::map::const_iterator commandIt, size_t initialSkipCount, bool definition, diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index 09199b0..c7b285a 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -736,11 +736,6 @@ private: size_t initialSkipCount, bool definition, size_t returnParam ) const; - std::string generateRAIIHandleCommandResultSingleSuccessWithErrors1ReturnVoidSingular( std::map::const_iterator commandIt, - size_t initialSkipCount, - std::map const & vectorParamIndices, - size_t returnParam, - bool definition ) const; std::string generateRAIIHandleCommandResultSingleSuccessWithErrors2Return( std::map::const_iterator commandIt, size_t initialSkipCount, bool definition, diff --git a/vulkan/vulkan_raii.hpp b/vulkan/vulkan_raii.hpp index 47d2f0f..aaef17a 100644 --- a/vulkan/vulkan_raii.hpp +++ b/vulkan/vulkan_raii.hpp @@ -14827,24 +14827,25 @@ namespace VULKAN_HPP_NAMESPACE } template - VULKAN_HPP_NODISCARD DataType + VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE DataType Device::writeAccelerationStructuresPropertyKHR( ArrayProxy const & accelerationStructures, VULKAN_HPP_NAMESPACE::QueryType queryType, size_t stride ) const { + VULKAN_HPP_ASSERT( getDispatcher()->vkWriteAccelerationStructuresPropertiesKHR && + "Function needs extension enabled!" ); + DataType data; - Result result = static_cast( + VkResult result = getDispatcher()->vkWriteAccelerationStructuresPropertiesKHR( static_cast( m_device ), accelerationStructures.size(), reinterpret_cast( accelerationStructures.data() ), static_cast( queryType ), sizeof( DataType ), reinterpret_cast( &data ), - stride ) ); - if ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Device::writeAccelerationStructuresPropertyKHR" ); - } + stride ); + resultCheck( static_cast( result ), VULKAN_HPP_NAMESPACE_STRING "::Device::writeAccelerationStructuresPropertyKHR" ); + return data; } @@ -15243,19 +15244,20 @@ namespace VULKAN_HPP_NAMESPACE } template - VULKAN_HPP_NODISCARD DataType Pipeline::getRayTracingShaderGroupHandleNV( uint32_t firstGroup, uint32_t groupCount ) const + VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE DataType Pipeline::getRayTracingShaderGroupHandleNV( uint32_t firstGroup, uint32_t groupCount ) const { + VULKAN_HPP_ASSERT( getDispatcher()->vkGetRayTracingShaderGroupHandlesNV && + "Function needs extension enabled!" ); + DataType data; - Result result = static_cast( getDispatcher()->vkGetRayTracingShaderGroupHandlesNV( static_cast( m_device ), - static_cast( m_pipeline ), - firstGroup, - groupCount, - sizeof( DataType ), - reinterpret_cast( &data ) ) ); - if ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Pipeline::getRayTracingShaderGroupHandleNV" ); - } + VkResult result = getDispatcher()->vkGetRayTracingShaderGroupHandlesNV( static_cast( m_device ), + static_cast( m_pipeline ), + firstGroup, + groupCount, + sizeof( DataType ), + reinterpret_cast( &data ) ); + resultCheck( static_cast( result ), VULKAN_HPP_NAMESPACE_STRING "::Pipeline::getRayTracingShaderGroupHandleNV" ); + return data; } @@ -15277,18 +15279,18 @@ namespace VULKAN_HPP_NAMESPACE } template - VULKAN_HPP_NODISCARD DataType AccelerationStructureNV::getHandle() const + VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE DataType AccelerationStructureNV::getHandle() const { + VULKAN_HPP_ASSERT( getDispatcher()->vkGetAccelerationStructureHandleNV && + "Function needs extension enabled!" ); + DataType data; - Result result = - static_cast( getDispatcher()->vkGetAccelerationStructureHandleNV( static_cast( m_device ), - static_cast( m_accelerationStructure ), - sizeof( DataType ), - reinterpret_cast( &data ) ) ); - if ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::AccelerationStructureNV::getHandle" ); - } + VkResult result = getDispatcher()->vkGetAccelerationStructureHandleNV( static_cast( m_device ), + static_cast( m_accelerationStructure ), + sizeof( DataType ), + reinterpret_cast( &data ) ); + resultCheck( static_cast( result ), VULKAN_HPP_NAMESPACE_STRING "::AccelerationStructureNV::getHandle" ); + return data; } @@ -16769,19 +16771,20 @@ namespace VULKAN_HPP_NAMESPACE } template - VULKAN_HPP_NODISCARD DataType Pipeline::getRayTracingShaderGroupHandleKHR( uint32_t firstGroup, uint32_t groupCount ) const + VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE DataType Pipeline::getRayTracingShaderGroupHandleKHR( uint32_t firstGroup, uint32_t groupCount ) const { + VULKAN_HPP_ASSERT( getDispatcher()->vkGetRayTracingShaderGroupHandlesKHR && + "Function needs extension enabled!" ); + DataType data; - Result result = static_cast( getDispatcher()->vkGetRayTracingShaderGroupHandlesKHR( static_cast( m_device ), - static_cast( m_pipeline ), - firstGroup, - groupCount, - sizeof( DataType ), - reinterpret_cast( &data ) ) ); - if ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Pipeline::getRayTracingShaderGroupHandleKHR" ); - } + VkResult result = getDispatcher()->vkGetRayTracingShaderGroupHandlesKHR( static_cast( m_device ), + static_cast( m_pipeline ), + firstGroup, + groupCount, + sizeof( DataType ), + reinterpret_cast( &data ) ); + resultCheck( static_cast( result ), VULKAN_HPP_NAMESPACE_STRING "::Pipeline::getRayTracingShaderGroupHandleKHR" ); + return data; } @@ -16807,19 +16810,21 @@ namespace VULKAN_HPP_NAMESPACE } template - VULKAN_HPP_NODISCARD DataType Pipeline::getRayTracingCaptureReplayShaderGroupHandleKHR( uint32_t firstGroup, uint32_t groupCount ) const + VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE DataType Pipeline::getRayTracingCaptureReplayShaderGroupHandleKHR( uint32_t firstGroup, uint32_t groupCount ) const { + VULKAN_HPP_ASSERT( getDispatcher()->vkGetRayTracingCaptureReplayShaderGroupHandlesKHR && + "Function needs extension enabled!" ); + DataType data; - Result result = static_cast( getDispatcher()->vkGetRayTracingCaptureReplayShaderGroupHandlesKHR( static_cast( m_device ), - static_cast( m_pipeline ), - firstGroup, - groupCount, - sizeof( DataType ), - reinterpret_cast( &data ) ) ); - if ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Pipeline::getRayTracingCaptureReplayShaderGroupHandleKHR" ); - } + VkResult result = getDispatcher()->vkGetRayTracingCaptureReplayShaderGroupHandlesKHR( static_cast( m_device ), + static_cast( m_pipeline ), + firstGroup, + groupCount, + sizeof( DataType ), + reinterpret_cast( &data ) ); + resultCheck( static_cast( result ), + VULKAN_HPP_NAMESPACE_STRING "::Pipeline::getRayTracingCaptureReplayShaderGroupHandleKHR" ); + return data; }