From e3e124e5e216ffa5db170000e253b1c01600f36f Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Thu, 19 May 2022 08:34:26 +0200 Subject: [PATCH] Combine two types of commands into one generation function --- VulkanHppGenerator.cpp | 62 +----------------------------------------- VulkanHppGenerator.hpp | 4 --- vulkan/vulkan_raii.hpp | 54 +++++++++++++++++++++--------------- 3 files changed, 33 insertions(+), 87 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 625027c..e355f25 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -7979,72 +7979,12 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandValue( std::map vectorParams = determineVectorParams( commandIt->second.params ); if ( vectorParams.empty() ) { - if ( beginsWith( commandIt->second.returnType, "Vk" ) ) - { - return generateRAIIHandleCommandValue0Return0VectorVkType( commandIt, initialSkipCount, vectorParams, definition ); - } - else - { - return generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, returnParams, vectorParams, definition ); - } + return generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, returnParams, vectorParams, definition ); } } return ""; } -std::string VulkanHppGenerator::generateRAIIHandleCommandValue0Return0VectorVkType( 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::string argumentList = generateArgumentListEnhanced( commandIt->second.params, {}, vectorParams, skippedParams, {}, {}, definition, false, false, false ); - std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags, false, false ); - std::string returnType = generateNamespacedType( commandIt->second.returnType ); - - if ( definition ) - { - std::string const definitionTemplate = - R"( - VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE ${returnType} ${className}::${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT - {${functionPointerCheck} -${vectorSizeCheck} - return static_cast<${returnType}>( getDispatcher()->${vkCommand}( ${callArguments} ) ); - } -)"; - - std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, 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 }, - { "callArguments", callArguments }, - { "className", stripPrefix( commandIt->second.params[initialSkipCount - 1].type.type, "Vk" ) }, - { "commandName", commandName }, - { "functionPointerCheck", generateFunctionPointerCheck( commandIt->first, commandIt->second.referencedIn ) }, - { "returnType", returnType }, - { "vectorSizeCheck", vectorSizeCheckString }, - { "vkCommand", commandIt->first } } ); - } - else - { - std::string const declarationTemplate = - R"( - VULKAN_HPP_NODISCARD ${returnType} ${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT; -)"; - - return replaceWithMap( declarationTemplate, - { - { "argumentList", argumentList }, - { "commandName", commandName }, - { "returnType", returnType }, - } ); - } -} - std::string VulkanHppGenerator::generateRAIIHandleCommandVoid( std::map::const_iterator commandIt, size_t initialSkipCount, bool definition ) const diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index 416342f..f76e2a6 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -819,10 +819,6 @@ private: std::vector const & returnParamIndices, bool definition ) const; std::string generateRAIIHandleCommandValue( std::map::const_iterator commandIt, size_t initialSkipCount, bool definition ) const; - std::string generateRAIIHandleCommandValue0Return0VectorVkType( std::map::const_iterator commandIt, - size_t initialSkipCount, - std::map const & vectorParamIndices, - bool definition ) const; std::string generateRAIIHandleCommandVoid( std::map::const_iterator commandIt, size_t initialSkipCount, bool definition ) const; std::string generateRAIIHandleCommandVoid1ReturnChain( std::map::const_iterator commandIt, size_t initialSkipCount, diff --git a/vulkan/vulkan_raii.hpp b/vulkan/vulkan_raii.hpp index e4707cb..658c735 100644 --- a/vulkan/vulkan_raii.hpp +++ b/vulkan/vulkan_raii.hpp @@ -11882,8 +11882,9 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::DeviceAddress Device::getBufferAddress( const VULKAN_HPP_NAMESPACE::BufferDeviceAddressInfo & info ) const VULKAN_HPP_NOEXCEPT { - return static_cast( - getDispatcher()->vkGetBufferDeviceAddress( static_cast( m_device ), reinterpret_cast( &info ) ) ); + VkDeviceAddress result = + getDispatcher()->vkGetBufferDeviceAddress( static_cast( m_device ), reinterpret_cast( &info ) ); + return static_cast( result ); } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE uint64_t @@ -12669,8 +12670,9 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceXlibPresentationSupportKHR && "Function needs extension enabled!" ); - return static_cast( - getDispatcher()->vkGetPhysicalDeviceXlibPresentationSupportKHR( static_cast( m_physicalDevice ), queueFamilyIndex, &dpy, visualID ) ); + VkBool32 result = + getDispatcher()->vkGetPhysicalDeviceXlibPresentationSupportKHR( static_cast( m_physicalDevice ), queueFamilyIndex, &dpy, visualID ); + return static_cast( result ); } # endif /*VK_USE_PLATFORM_XLIB_KHR*/ @@ -12690,8 +12692,9 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceXcbPresentationSupportKHR && "Function needs extension enabled!" ); - return static_cast( getDispatcher()->vkGetPhysicalDeviceXcbPresentationSupportKHR( - static_cast( m_physicalDevice ), queueFamilyIndex, &connection, visual_id ) ); + VkBool32 result = getDispatcher()->vkGetPhysicalDeviceXcbPresentationSupportKHR( + static_cast( m_physicalDevice ), queueFamilyIndex, &connection, visual_id ); + return static_cast( result ); } # endif /*VK_USE_PLATFORM_XCB_KHR*/ @@ -12711,8 +12714,9 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceWaylandPresentationSupportKHR && "Function needs extension enabled!" ); - return static_cast( - getDispatcher()->vkGetPhysicalDeviceWaylandPresentationSupportKHR( static_cast( m_physicalDevice ), queueFamilyIndex, &display ) ); + VkBool32 result = + getDispatcher()->vkGetPhysicalDeviceWaylandPresentationSupportKHR( static_cast( m_physicalDevice ), queueFamilyIndex, &display ); + return static_cast( result ); } # endif /*VK_USE_PLATFORM_WAYLAND_KHR*/ @@ -12743,8 +12747,8 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceWin32PresentationSupportKHR && "Function needs extension enabled!" ); - return static_cast( - getDispatcher()->vkGetPhysicalDeviceWin32PresentationSupportKHR( static_cast( m_physicalDevice ), queueFamilyIndex ) ); + VkBool32 result = getDispatcher()->vkGetPhysicalDeviceWin32PresentationSupportKHR( static_cast( m_physicalDevice ), queueFamilyIndex ); + return static_cast( result ); } # endif /*VK_USE_PLATFORM_WIN32_KHR*/ @@ -14993,8 +14997,9 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkGetAccelerationStructureDeviceAddressKHR && "Function needs extension enabled!" ); - return static_cast( getDispatcher()->vkGetAccelerationStructureDeviceAddressKHR( - static_cast( m_device ), reinterpret_cast( &info ) ) ); + VkDeviceAddress result = getDispatcher()->vkGetAccelerationStructureDeviceAddressKHR( + static_cast( m_device ), reinterpret_cast( &info ) ); + return static_cast( result ); } VULKAN_HPP_INLINE void @@ -15929,8 +15934,9 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkGetBufferDeviceAddressEXT && "Function needs extension enabled!" ); - return static_cast( - getDispatcher()->vkGetBufferDeviceAddressEXT( static_cast( m_device ), reinterpret_cast( &info ) ) ); + VkDeviceAddress result = + getDispatcher()->vkGetBufferDeviceAddressEXT( static_cast( m_device ), reinterpret_cast( &info ) ); + return static_cast( result ); } //=== VK_EXT_tooling_info === @@ -16163,8 +16169,9 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkGetBufferDeviceAddressKHR && "Function needs extension enabled!" ); - return static_cast( - getDispatcher()->vkGetBufferDeviceAddressKHR( static_cast( m_device ), reinterpret_cast( &info ) ) ); + VkDeviceAddress result = + getDispatcher()->vkGetBufferDeviceAddressKHR( static_cast( m_device ), reinterpret_cast( &info ) ); + return static_cast( result ); } VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE uint64_t @@ -16871,8 +16878,9 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceDirectFBPresentationSupportEXT && "Function needs extension enabled!" ); - return static_cast( - getDispatcher()->vkGetPhysicalDeviceDirectFBPresentationSupportEXT( static_cast( m_physicalDevice ), queueFamilyIndex, &dfb ) ); + VkBool32 result = + getDispatcher()->vkGetPhysicalDeviceDirectFBPresentationSupportEXT( static_cast( m_physicalDevice ), queueFamilyIndex, &dfb ); + return static_cast( result ); } # endif /*VK_USE_PLATFORM_DIRECTFB_EXT*/ @@ -17015,8 +17023,9 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkGetRayTracingShaderGroupStackSizeKHR && "Function needs extension enabled!" ); - return static_cast( getDispatcher()->vkGetRayTracingShaderGroupStackSizeKHR( - static_cast( m_device ), static_cast( m_pipeline ), group, static_cast( groupShader ) ) ); + VkDeviceSize result = getDispatcher()->vkGetRayTracingShaderGroupStackSizeKHR( + static_cast( m_device ), static_cast( m_pipeline ), group, static_cast( groupShader ) ); + return static_cast( result ); } VULKAN_HPP_INLINE void CommandBuffer::setRayTracingPipelineStackSizeKHR( uint32_t pipelineStackSize ) const VULKAN_HPP_NOEXCEPT @@ -17319,8 +17328,9 @@ namespace VULKAN_HPP_NAMESPACE VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceScreenPresentationSupportQNX && "Function needs extension enabled!" ); - return static_cast( - getDispatcher()->vkGetPhysicalDeviceScreenPresentationSupportQNX( static_cast( m_physicalDevice ), queueFamilyIndex, &window ) ); + VkBool32 result = + getDispatcher()->vkGetPhysicalDeviceScreenPresentationSupportQNX( static_cast( m_physicalDevice ), queueFamilyIndex, &window ); + return static_cast( result ); } # endif /*VK_USE_PLATFORM_SCREEN_QNX*/