From a7d6e1be5d1fb70a52bfd7e5659a62d5753ccc4a Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Wed, 8 Jun 2022 16:39:15 +0200 Subject: [PATCH] Combine two types of commands into one generation function --- VulkanHppGenerator.cpp | 67 +-------------- VulkanHppGenerator.hpp | 4 - vulkan/vulkan_raii.hpp | 181 +++++++++++++++++++---------------------- 3 files changed, 84 insertions(+), 168 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 5d01343..63fc7d2 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -6459,8 +6459,8 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultMultiSuccessWithE switch ( returnParams.size() ) { case 0: - return generateRAIIHandleCommandResultMultiSuccessWithErrors0Return( - commandIt, initialSkipCount, determineVectorParams( commandIt->second.params ), definition ); + return generateRAIIHandleCommandEnhanced( + commandIt, initialSkipCount, returnParams, determineVectorParams( commandIt->second.params ), definition, false ); break; case 1: return generateRAIIHandleCommandResultMultiSuccessWithErrors1Return( commandIt, initialSkipCount, definition, returnParams[0] ); break; case 2: return generateRAIIHandleCommandResultMultiSuccessWithErrors2Return( commandIt, initialSkipCount, definition, returnParams ); break; @@ -6469,69 +6469,6 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultMultiSuccessWithE return ""; } -std::string VulkanHppGenerator::generateRAIIHandleCommandResultMultiSuccessWithErrors0Return( std::map::const_iterator commandIt, - size_t initialSkipCount, - std::map const & vectorParams, - bool definition ) const -{ - std::set skippedParams = determineSkippedParams( commandIt->second.params, initialSkipCount, vectorParams, {}, false ); - std::set templatedParams = determineVoidPointerParams( commandIt->second.params ); - std::string argumentList = - generateArgumentListEnhanced( commandIt->second.params, {}, vectorParams, skippedParams, {}, templatedParams, definition, false, false, false ); - std::string argumentTemplates = generateArgumentTemplates( commandIt->second.params, {}, vectorParams, templatedParams, false, true ); - std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags, false, false ); - - if ( definition ) - { - std::string const definitionTemplate = - R"( - ${argumentTemplates} - VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::Result ${className}::${commandName}( ${argumentList} ) const - {${functionPointerCheck} -${vectorSizeCheck} - VULKAN_HPP_NAMESPACE::Result result = static_cast( getDispatcher()->${vkCommand}( ${callArguments} ) ); - if ( ${failureCheck} ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING"::${className}::${commandName}" ); - } - return result; - } -)"; - - std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true ); - std::pair>> vectorSizeCheck = needsVectorSizeCheck( commandIt->second.params, vectorParams, {}, {} ); - std::string vectorSizeCheckString = - vectorSizeCheck.first ? generateRAIIHandleVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams ) - : ""; - - return replaceWithMap( definitionTemplate, - { { "argumentList", argumentList }, - { "argumentTemplates", argumentTemplates }, - { "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 ) }, - { "vectorSizeCheck", vectorSizeCheckString }, - { "vkCommand", commandIt->first } } ); - } - else - { - std::string const declarationTemplate = - R"( - ${argumentTemplates} - VULKAN_HPP_NODISCARD VULKAN_HPP_NAMESPACE::Result ${commandName}( ${argumentList} ) const; -)"; - - return replaceWithMap( declarationTemplate, - { - { "argumentList", argumentList }, - { "argumentTemplates", argumentTemplates }, - { "commandName", commandName }, - } ); - } -} - std::string VulkanHppGenerator::generateRAIIHandleCommandResultMultiSuccessWithErrors1Return( std::map::const_iterator commandIt, size_t initialSkipCount, bool definition, diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index 9ad1f3c..eb8495d 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -707,10 +707,6 @@ private: std::string generateRAIIHandleCommandResultMultiSuccessWithErrors( std::map::const_iterator commandIt, size_t initialSkipCount, bool definition ) const; - std::string generateRAIIHandleCommandResultMultiSuccessWithErrors0Return( std::map::const_iterator commandIt, - size_t initialSkipCount, - std::map const & vectorParamIndices, - bool definition ) const; std::string generateRAIIHandleCommandResultMultiSuccessWithErrors1Return( std::map::const_iterator commandIt, size_t initialSkipCount, bool definition, diff --git a/vulkan/vulkan_raii.hpp b/vulkan/vulkan_raii.hpp index 365575f..249f77d 100644 --- a/vulkan/vulkan_raii.hpp +++ b/vulkan/vulkan_raii.hpp @@ -10549,25 +10549,22 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::Result Fence::getStatus() const { - VULKAN_HPP_NAMESPACE::Result result = - static_cast( getDispatcher()->vkGetFenceStatus( static_cast( m_device ), static_cast( m_fence ) ) ); - if ( ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) && ( result != VULKAN_HPP_NAMESPACE::Result::eNotReady ) ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Fence::getStatus" ); - } - return result; + VkResult result = getDispatcher()->vkGetFenceStatus( static_cast( m_device ), static_cast( m_fence ) ); + resultCheck( static_cast( result ), + VULKAN_HPP_NAMESPACE_STRING "::Fence::getStatus", + { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::eNotReady } ); + return static_cast( result ); } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::Result Device::waitForFences( ArrayProxy const & fences, VULKAN_HPP_NAMESPACE::Bool32 waitAll, uint64_t timeout ) const { - VULKAN_HPP_NAMESPACE::Result result = static_cast( getDispatcher()->vkWaitForFences( - static_cast( m_device ), fences.size(), reinterpret_cast( fences.data() ), static_cast( waitAll ), timeout ) ); - if ( ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) && ( result != VULKAN_HPP_NAMESPACE::Result::eTimeout ) ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Device::waitForFences" ); - } - return result; + VkResult result = getDispatcher()->vkWaitForFences( + static_cast( m_device ), fences.size(), reinterpret_cast( fences.data() ), static_cast( waitAll ), timeout ); + resultCheck( static_cast( result ), + VULKAN_HPP_NAMESPACE_STRING "::Device::waitForFences", + { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::eTimeout } ); + return static_cast( result ); } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_RAII_NAMESPACE::Semaphore @@ -10586,13 +10583,11 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::Result Event::getStatus() const { - VULKAN_HPP_NAMESPACE::Result result = - static_cast( getDispatcher()->vkGetEventStatus( static_cast( m_device ), static_cast( m_event ) ) ); - if ( ( result != VULKAN_HPP_NAMESPACE::Result::eEventSet ) && ( result != VULKAN_HPP_NAMESPACE::Result::eEventReset ) ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Event::getStatus" ); - } - return result; + VkResult result = getDispatcher()->vkGetEventStatus( static_cast( m_device ), static_cast( m_event ) ); + resultCheck( static_cast( result ), + VULKAN_HPP_NAMESPACE_STRING "::Event::getStatus", + { VULKAN_HPP_NAMESPACE::Result::eEventSet, VULKAN_HPP_NAMESPACE::Result::eEventReset } ); + return static_cast( result ); } VULKAN_HPP_INLINE void Event::set() const @@ -11809,13 +11804,12 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::Result Device::waitSemaphores( const VULKAN_HPP_NAMESPACE::SemaphoreWaitInfo & waitInfo, uint64_t timeout ) const { - VULKAN_HPP_NAMESPACE::Result result = static_cast( - getDispatcher()->vkWaitSemaphores( static_cast( m_device ), reinterpret_cast( &waitInfo ), timeout ) ); - if ( ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) && ( result != VULKAN_HPP_NAMESPACE::Result::eTimeout ) ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Device::waitSemaphores" ); - } - return result; + VkResult result = + getDispatcher()->vkWaitSemaphores( static_cast( m_device ), reinterpret_cast( &waitInfo ), timeout ); + resultCheck( static_cast( result ), + VULKAN_HPP_NAMESPACE_STRING "::Device::waitSemaphores", + { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::eTimeout } ); + return static_cast( result ); } VULKAN_HPP_INLINE void Device::signalSemaphore( const VULKAN_HPP_NAMESPACE::SemaphoreSignalInfo & signalInfo ) const @@ -12345,13 +12339,11 @@ namespace VULKAN_HPP_NAMESPACE { VULKAN_HPP_ASSERT( getDispatcher()->vkQueuePresentKHR && "Function needs extension enabled!" ); - VULKAN_HPP_NAMESPACE::Result result = static_cast( - getDispatcher()->vkQueuePresentKHR( static_cast( m_queue ), reinterpret_cast( &presentInfo ) ) ); - if ( ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) && ( result != VULKAN_HPP_NAMESPACE::Result::eSuboptimalKHR ) ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Queue::presentKHR" ); - } - return result; + VkResult result = getDispatcher()->vkQueuePresentKHR( static_cast( m_queue ), reinterpret_cast( &presentInfo ) ); + resultCheck( static_cast( result ), + VULKAN_HPP_NAMESPACE_STRING "::Queue::presentKHR", + { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::eSuboptimalKHR } ); + return static_cast( result ); } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::DeviceGroupPresentCapabilitiesKHR Device::getGroupPresentCapabilitiesKHR() const @@ -13995,13 +13987,11 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkGetSwapchainStatusKHR && "Function needs extension enabled!" ); - VULKAN_HPP_NAMESPACE::Result result = static_cast( - getDispatcher()->vkGetSwapchainStatusKHR( static_cast( m_device ), static_cast( m_swapchain ) ) ); - if ( ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) && ( result != VULKAN_HPP_NAMESPACE::Result::eSuboptimalKHR ) ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::SwapchainKHR::getStatus" ); - } - return result; + VkResult result = getDispatcher()->vkGetSwapchainStatusKHR( static_cast( m_device ), static_cast( m_swapchain ) ); + resultCheck( static_cast( result ), + VULKAN_HPP_NAMESPACE_STRING "::SwapchainKHR::getStatus", + { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::eSuboptimalKHR } ); + return static_cast( result ); } //=== VK_KHR_external_fence_capabilities === @@ -14715,18 +14705,18 @@ namespace VULKAN_HPP_NAMESPACE throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::Device::buildAccelerationStructuresKHR: infos.size() != pBuildRangeInfos.size()" ); } - VULKAN_HPP_NAMESPACE::Result result = static_cast( getDispatcher()->vkBuildAccelerationStructuresKHR( + VkResult result = getDispatcher()->vkBuildAccelerationStructuresKHR( static_cast( m_device ), static_cast( deferredOperation ), infos.size(), reinterpret_cast( infos.data() ), - reinterpret_cast( pBuildRangeInfos.data() ) ) ); - if ( ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) && ( result != VULKAN_HPP_NAMESPACE::Result::eOperationDeferredKHR ) && - ( result != VULKAN_HPP_NAMESPACE::Result::eOperationNotDeferredKHR ) ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Device::buildAccelerationStructuresKHR" ); - } - return result; + reinterpret_cast( pBuildRangeInfos.data() ) ); + resultCheck( static_cast( result ), + VULKAN_HPP_NAMESPACE_STRING "::Device::buildAccelerationStructuresKHR", + { VULKAN_HPP_NAMESPACE::Result::eSuccess, + VULKAN_HPP_NAMESPACE::Result::eOperationDeferredKHR, + VULKAN_HPP_NAMESPACE::Result::eOperationNotDeferredKHR } ); + return static_cast( result ); } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::Result @@ -14736,16 +14726,15 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkCopyAccelerationStructureKHR && "Function needs extension enabled!" ); - VULKAN_HPP_NAMESPACE::Result result = static_cast( - getDispatcher()->vkCopyAccelerationStructureKHR( static_cast( m_device ), - static_cast( deferredOperation ), - reinterpret_cast( &info ) ) ); - if ( ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) && ( result != VULKAN_HPP_NAMESPACE::Result::eOperationDeferredKHR ) && - ( result != VULKAN_HPP_NAMESPACE::Result::eOperationNotDeferredKHR ) ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Device::copyAccelerationStructureKHR" ); - } - return result; + VkResult result = getDispatcher()->vkCopyAccelerationStructureKHR( static_cast( m_device ), + static_cast( deferredOperation ), + reinterpret_cast( &info ) ); + resultCheck( static_cast( result ), + VULKAN_HPP_NAMESPACE_STRING "::Device::copyAccelerationStructureKHR", + { VULKAN_HPP_NAMESPACE::Result::eSuccess, + VULKAN_HPP_NAMESPACE::Result::eOperationDeferredKHR, + VULKAN_HPP_NAMESPACE::Result::eOperationNotDeferredKHR } ); + return static_cast( result ); } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::Result @@ -14755,16 +14744,16 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkCopyAccelerationStructureToMemoryKHR && "Function needs extension enabled!" ); - VULKAN_HPP_NAMESPACE::Result result = static_cast( + VkResult result = getDispatcher()->vkCopyAccelerationStructureToMemoryKHR( static_cast( m_device ), static_cast( deferredOperation ), - reinterpret_cast( &info ) ) ); - if ( ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) && ( result != VULKAN_HPP_NAMESPACE::Result::eOperationDeferredKHR ) && - ( result != VULKAN_HPP_NAMESPACE::Result::eOperationNotDeferredKHR ) ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Device::copyAccelerationStructureToMemoryKHR" ); - } - return result; + reinterpret_cast( &info ) ); + resultCheck( static_cast( result ), + VULKAN_HPP_NAMESPACE_STRING "::Device::copyAccelerationStructureToMemoryKHR", + { VULKAN_HPP_NAMESPACE::Result::eSuccess, + VULKAN_HPP_NAMESPACE::Result::eOperationDeferredKHR, + VULKAN_HPP_NAMESPACE::Result::eOperationNotDeferredKHR } ); + return static_cast( result ); } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::Result @@ -14774,16 +14763,16 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkCopyMemoryToAccelerationStructureKHR && "Function needs extension enabled!" ); - VULKAN_HPP_NAMESPACE::Result result = static_cast( + VkResult result = getDispatcher()->vkCopyMemoryToAccelerationStructureKHR( static_cast( m_device ), static_cast( deferredOperation ), - reinterpret_cast( &info ) ) ); - if ( ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) && ( result != VULKAN_HPP_NAMESPACE::Result::eOperationDeferredKHR ) && - ( result != VULKAN_HPP_NAMESPACE::Result::eOperationNotDeferredKHR ) ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Device::copyMemoryToAccelerationStructureKHR" ); - } - return result; + reinterpret_cast( &info ) ); + resultCheck( static_cast( result ), + VULKAN_HPP_NAMESPACE_STRING "::Device::copyMemoryToAccelerationStructureKHR", + { VULKAN_HPP_NAMESPACE::Result::eSuccess, + VULKAN_HPP_NAMESPACE::Result::eOperationDeferredKHR, + VULKAN_HPP_NAMESPACE::Result::eOperationNotDeferredKHR } ); + return static_cast( result ); } template @@ -15586,13 +15575,12 @@ namespace VULKAN_HPP_NAMESPACE { VULKAN_HPP_ASSERT( getDispatcher()->vkWaitSemaphoresKHR && "Function needs extension enabled!" ); - VULKAN_HPP_NAMESPACE::Result result = static_cast( - getDispatcher()->vkWaitSemaphoresKHR( static_cast( m_device ), reinterpret_cast( &waitInfo ), timeout ) ); - if ( ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) && ( result != VULKAN_HPP_NAMESPACE::Result::eTimeout ) ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::Device::waitSemaphoresKHR" ); - } - return result; + VkResult result = + getDispatcher()->vkWaitSemaphoresKHR( static_cast( m_device ), reinterpret_cast( &waitInfo ), timeout ); + resultCheck( static_cast( result ), + VULKAN_HPP_NAMESPACE_STRING "::Device::waitSemaphoresKHR", + { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::eTimeout } ); + return static_cast( result ); } VULKAN_HPP_INLINE void Device::signalSemaphoreKHR( const VULKAN_HPP_NAMESPACE::SemaphoreSignalInfo & signalInfo ) const @@ -15820,14 +15808,12 @@ namespace VULKAN_HPP_NAMESPACE { VULKAN_HPP_ASSERT( getDispatcher()->vkWaitForPresentKHR && "Function needs extension enabled!" ); - VULKAN_HPP_NAMESPACE::Result result = static_cast( - getDispatcher()->vkWaitForPresentKHR( static_cast( m_device ), static_cast( m_swapchain ), presentId, timeout ) ); - if ( ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) && ( result != VULKAN_HPP_NAMESPACE::Result::eTimeout ) && - ( result != VULKAN_HPP_NAMESPACE::Result::eSuboptimalKHR ) ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::SwapchainKHR::waitForPresent" ); - } - return result; + VkResult result = + getDispatcher()->vkWaitForPresentKHR( static_cast( m_device ), static_cast( m_swapchain ), presentId, timeout ); + resultCheck( static_cast( result ), + VULKAN_HPP_NAMESPACE_STRING "::SwapchainKHR::waitForPresent", + { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::eTimeout, VULKAN_HPP_NAMESPACE::Result::eSuboptimalKHR } ); + return static_cast( result ); } //=== VK_NV_cooperative_matrix === @@ -16210,14 +16196,11 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkDeferredOperationJoinKHR && "Function needs extension enabled!" ); - VULKAN_HPP_NAMESPACE::Result result = static_cast( - getDispatcher()->vkDeferredOperationJoinKHR( static_cast( m_device ), static_cast( m_operation ) ) ); - if ( ( result != VULKAN_HPP_NAMESPACE::Result::eSuccess ) && ( result != VULKAN_HPP_NAMESPACE::Result::eThreadDoneKHR ) && - ( result != VULKAN_HPP_NAMESPACE::Result::eThreadIdleKHR ) ) - { - throwResultException( result, VULKAN_HPP_NAMESPACE_STRING "::DeferredOperationKHR::join" ); - } - return result; + VkResult result = getDispatcher()->vkDeferredOperationJoinKHR( static_cast( m_device ), static_cast( m_operation ) ); + resultCheck( static_cast( result ), + VULKAN_HPP_NAMESPACE_STRING "::DeferredOperationKHR::join", + { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::eThreadDoneKHR, VULKAN_HPP_NAMESPACE::Result::eThreadIdleKHR } ); + return static_cast( result ); } //=== VK_KHR_pipeline_executable_properties ===