Combine two types of commands into one generation function

This commit is contained in:
asuessenbach 2022-05-19 08:34:26 +02:00
parent c63ab110f5
commit e3e124e5e2
3 changed files with 33 additions and 87 deletions

View File

@ -7979,72 +7979,12 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandValue( std::map<std::st
std::map<size_t, size_t> vectorParams = determineVectorParams( commandIt->second.params ); std::map<size_t, size_t> vectorParams = determineVectorParams( commandIt->second.params );
if ( vectorParams.empty() ) if ( vectorParams.empty() )
{ {
if ( beginsWith( commandIt->second.returnType, "Vk" ) ) return generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, returnParams, vectorParams, definition );
{
return generateRAIIHandleCommandValue0Return0VectorVkType( commandIt, initialSkipCount, vectorParams, definition );
}
else
{
return generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, returnParams, vectorParams, definition );
}
} }
} }
return ""; return "";
} }
std::string VulkanHppGenerator::generateRAIIHandleCommandValue0Return0VectorVkType( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
std::map<size_t, size_t> const & vectorParams,
bool definition ) const
{
std::set<size_t> 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<bool, std::map<size_t, std::vector<size_t>>> 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<std::string, CommandData>::const_iterator commandIt, std::string VulkanHppGenerator::generateRAIIHandleCommandVoid( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount, size_t initialSkipCount,
bool definition ) const bool definition ) const

View File

@ -819,10 +819,6 @@ private:
std::vector<size_t> const & returnParamIndices, std::vector<size_t> const & returnParamIndices,
bool definition ) const; bool definition ) const;
std::string generateRAIIHandleCommandValue( std::map<std::string, CommandData>::const_iterator commandIt, size_t initialSkipCount, bool definition ) const; std::string generateRAIIHandleCommandValue( std::map<std::string, CommandData>::const_iterator commandIt, size_t initialSkipCount, bool definition ) const;
std::string generateRAIIHandleCommandValue0Return0VectorVkType( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
std::map<size_t, size_t> const & vectorParamIndices,
bool definition ) const;
std::string generateRAIIHandleCommandVoid( std::map<std::string, CommandData>::const_iterator commandIt, size_t initialSkipCount, bool definition ) const; std::string generateRAIIHandleCommandVoid( std::map<std::string, CommandData>::const_iterator commandIt, size_t initialSkipCount, bool definition ) const;
std::string generateRAIIHandleCommandVoid1ReturnChain( std::map<std::string, CommandData>::const_iterator commandIt, std::string generateRAIIHandleCommandVoid1ReturnChain( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount, size_t initialSkipCount,

View File

@ -11882,8 +11882,9 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::DeviceAddress VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::DeviceAddress
Device::getBufferAddress( const VULKAN_HPP_NAMESPACE::BufferDeviceAddressInfo & info ) const VULKAN_HPP_NOEXCEPT Device::getBufferAddress( const VULKAN_HPP_NAMESPACE::BufferDeviceAddressInfo & info ) const VULKAN_HPP_NOEXCEPT
{ {
return static_cast<VULKAN_HPP_NAMESPACE::DeviceAddress>( VkDeviceAddress result =
getDispatcher()->vkGetBufferDeviceAddress( static_cast<VkDevice>( m_device ), reinterpret_cast<const VkBufferDeviceAddressInfo *>( &info ) ) ); getDispatcher()->vkGetBufferDeviceAddress( static_cast<VkDevice>( m_device ), reinterpret_cast<const VkBufferDeviceAddressInfo *>( &info ) );
return static_cast<VULKAN_HPP_NAMESPACE::DeviceAddress>( result );
} }
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE uint64_t VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE uint64_t
@ -12669,8 +12670,9 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceXlibPresentationSupportKHR && VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceXlibPresentationSupportKHR &&
"Function <vkGetPhysicalDeviceXlibPresentationSupportKHR> needs extension <VK_KHR_xlib_surface> enabled!" ); "Function <vkGetPhysicalDeviceXlibPresentationSupportKHR> needs extension <VK_KHR_xlib_surface> enabled!" );
return static_cast<VULKAN_HPP_NAMESPACE::Bool32>( VkBool32 result =
getDispatcher()->vkGetPhysicalDeviceXlibPresentationSupportKHR( static_cast<VkPhysicalDevice>( m_physicalDevice ), queueFamilyIndex, &dpy, visualID ) ); getDispatcher()->vkGetPhysicalDeviceXlibPresentationSupportKHR( static_cast<VkPhysicalDevice>( m_physicalDevice ), queueFamilyIndex, &dpy, visualID );
return static_cast<VULKAN_HPP_NAMESPACE::Bool32>( result );
} }
# endif /*VK_USE_PLATFORM_XLIB_KHR*/ # endif /*VK_USE_PLATFORM_XLIB_KHR*/
@ -12690,8 +12692,9 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceXcbPresentationSupportKHR && VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceXcbPresentationSupportKHR &&
"Function <vkGetPhysicalDeviceXcbPresentationSupportKHR> needs extension <VK_KHR_xcb_surface> enabled!" ); "Function <vkGetPhysicalDeviceXcbPresentationSupportKHR> needs extension <VK_KHR_xcb_surface> enabled!" );
return static_cast<VULKAN_HPP_NAMESPACE::Bool32>( getDispatcher()->vkGetPhysicalDeviceXcbPresentationSupportKHR( VkBool32 result = getDispatcher()->vkGetPhysicalDeviceXcbPresentationSupportKHR(
static_cast<VkPhysicalDevice>( m_physicalDevice ), queueFamilyIndex, &connection, visual_id ) ); static_cast<VkPhysicalDevice>( m_physicalDevice ), queueFamilyIndex, &connection, visual_id );
return static_cast<VULKAN_HPP_NAMESPACE::Bool32>( result );
} }
# endif /*VK_USE_PLATFORM_XCB_KHR*/ # endif /*VK_USE_PLATFORM_XCB_KHR*/
@ -12711,8 +12714,9 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceWaylandPresentationSupportKHR && VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceWaylandPresentationSupportKHR &&
"Function <vkGetPhysicalDeviceWaylandPresentationSupportKHR> needs extension <VK_KHR_wayland_surface> enabled!" ); "Function <vkGetPhysicalDeviceWaylandPresentationSupportKHR> needs extension <VK_KHR_wayland_surface> enabled!" );
return static_cast<VULKAN_HPP_NAMESPACE::Bool32>( VkBool32 result =
getDispatcher()->vkGetPhysicalDeviceWaylandPresentationSupportKHR( static_cast<VkPhysicalDevice>( m_physicalDevice ), queueFamilyIndex, &display ) ); getDispatcher()->vkGetPhysicalDeviceWaylandPresentationSupportKHR( static_cast<VkPhysicalDevice>( m_physicalDevice ), queueFamilyIndex, &display );
return static_cast<VULKAN_HPP_NAMESPACE::Bool32>( result );
} }
# endif /*VK_USE_PLATFORM_WAYLAND_KHR*/ # endif /*VK_USE_PLATFORM_WAYLAND_KHR*/
@ -12743,8 +12747,8 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceWin32PresentationSupportKHR && VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceWin32PresentationSupportKHR &&
"Function <vkGetPhysicalDeviceWin32PresentationSupportKHR> needs extension <VK_KHR_win32_surface> enabled!" ); "Function <vkGetPhysicalDeviceWin32PresentationSupportKHR> needs extension <VK_KHR_win32_surface> enabled!" );
return static_cast<VULKAN_HPP_NAMESPACE::Bool32>( VkBool32 result = getDispatcher()->vkGetPhysicalDeviceWin32PresentationSupportKHR( static_cast<VkPhysicalDevice>( m_physicalDevice ), queueFamilyIndex );
getDispatcher()->vkGetPhysicalDeviceWin32PresentationSupportKHR( static_cast<VkPhysicalDevice>( m_physicalDevice ), queueFamilyIndex ) ); return static_cast<VULKAN_HPP_NAMESPACE::Bool32>( result );
} }
# endif /*VK_USE_PLATFORM_WIN32_KHR*/ # endif /*VK_USE_PLATFORM_WIN32_KHR*/
@ -14993,8 +14997,9 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_ASSERT( getDispatcher()->vkGetAccelerationStructureDeviceAddressKHR && VULKAN_HPP_ASSERT( getDispatcher()->vkGetAccelerationStructureDeviceAddressKHR &&
"Function <vkGetAccelerationStructureDeviceAddressKHR> needs extension <VK_KHR_acceleration_structure> enabled!" ); "Function <vkGetAccelerationStructureDeviceAddressKHR> needs extension <VK_KHR_acceleration_structure> enabled!" );
return static_cast<VULKAN_HPP_NAMESPACE::DeviceAddress>( getDispatcher()->vkGetAccelerationStructureDeviceAddressKHR( VkDeviceAddress result = getDispatcher()->vkGetAccelerationStructureDeviceAddressKHR(
static_cast<VkDevice>( m_device ), reinterpret_cast<const VkAccelerationStructureDeviceAddressInfoKHR *>( &info ) ) ); static_cast<VkDevice>( m_device ), reinterpret_cast<const VkAccelerationStructureDeviceAddressInfoKHR *>( &info ) );
return static_cast<VULKAN_HPP_NAMESPACE::DeviceAddress>( result );
} }
VULKAN_HPP_INLINE void VULKAN_HPP_INLINE void
@ -15929,8 +15934,9 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_ASSERT( getDispatcher()->vkGetBufferDeviceAddressEXT && VULKAN_HPP_ASSERT( getDispatcher()->vkGetBufferDeviceAddressEXT &&
"Function <vkGetBufferDeviceAddressEXT> needs extension <VK_EXT_buffer_device_address> enabled!" ); "Function <vkGetBufferDeviceAddressEXT> needs extension <VK_EXT_buffer_device_address> enabled!" );
return static_cast<VULKAN_HPP_NAMESPACE::DeviceAddress>( VkDeviceAddress result =
getDispatcher()->vkGetBufferDeviceAddressEXT( static_cast<VkDevice>( m_device ), reinterpret_cast<const VkBufferDeviceAddressInfo *>( &info ) ) ); getDispatcher()->vkGetBufferDeviceAddressEXT( static_cast<VkDevice>( m_device ), reinterpret_cast<const VkBufferDeviceAddressInfo *>( &info ) );
return static_cast<VULKAN_HPP_NAMESPACE::DeviceAddress>( result );
} }
//=== VK_EXT_tooling_info === //=== VK_EXT_tooling_info ===
@ -16163,8 +16169,9 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_ASSERT( getDispatcher()->vkGetBufferDeviceAddressKHR && VULKAN_HPP_ASSERT( getDispatcher()->vkGetBufferDeviceAddressKHR &&
"Function <vkGetBufferDeviceAddressKHR> needs extension <VK_KHR_buffer_device_address> enabled!" ); "Function <vkGetBufferDeviceAddressKHR> needs extension <VK_KHR_buffer_device_address> enabled!" );
return static_cast<VULKAN_HPP_NAMESPACE::DeviceAddress>( VkDeviceAddress result =
getDispatcher()->vkGetBufferDeviceAddressKHR( static_cast<VkDevice>( m_device ), reinterpret_cast<const VkBufferDeviceAddressInfo *>( &info ) ) ); getDispatcher()->vkGetBufferDeviceAddressKHR( static_cast<VkDevice>( m_device ), reinterpret_cast<const VkBufferDeviceAddressInfo *>( &info ) );
return static_cast<VULKAN_HPP_NAMESPACE::DeviceAddress>( result );
} }
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE uint64_t VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE uint64_t
@ -16871,8 +16878,9 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceDirectFBPresentationSupportEXT && VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceDirectFBPresentationSupportEXT &&
"Function <vkGetPhysicalDeviceDirectFBPresentationSupportEXT> needs extension <VK_EXT_directfb_surface> enabled!" ); "Function <vkGetPhysicalDeviceDirectFBPresentationSupportEXT> needs extension <VK_EXT_directfb_surface> enabled!" );
return static_cast<VULKAN_HPP_NAMESPACE::Bool32>( VkBool32 result =
getDispatcher()->vkGetPhysicalDeviceDirectFBPresentationSupportEXT( static_cast<VkPhysicalDevice>( m_physicalDevice ), queueFamilyIndex, &dfb ) ); getDispatcher()->vkGetPhysicalDeviceDirectFBPresentationSupportEXT( static_cast<VkPhysicalDevice>( m_physicalDevice ), queueFamilyIndex, &dfb );
return static_cast<VULKAN_HPP_NAMESPACE::Bool32>( result );
} }
# endif /*VK_USE_PLATFORM_DIRECTFB_EXT*/ # endif /*VK_USE_PLATFORM_DIRECTFB_EXT*/
@ -17015,8 +17023,9 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_ASSERT( getDispatcher()->vkGetRayTracingShaderGroupStackSizeKHR && VULKAN_HPP_ASSERT( getDispatcher()->vkGetRayTracingShaderGroupStackSizeKHR &&
"Function <vkGetRayTracingShaderGroupStackSizeKHR> needs extension <VK_KHR_ray_tracing_pipeline> enabled!" ); "Function <vkGetRayTracingShaderGroupStackSizeKHR> needs extension <VK_KHR_ray_tracing_pipeline> enabled!" );
return static_cast<VULKAN_HPP_NAMESPACE::DeviceSize>( getDispatcher()->vkGetRayTracingShaderGroupStackSizeKHR( VkDeviceSize result = getDispatcher()->vkGetRayTracingShaderGroupStackSizeKHR(
static_cast<VkDevice>( m_device ), static_cast<VkPipeline>( m_pipeline ), group, static_cast<VkShaderGroupShaderKHR>( groupShader ) ) ); static_cast<VkDevice>( m_device ), static_cast<VkPipeline>( m_pipeline ), group, static_cast<VkShaderGroupShaderKHR>( groupShader ) );
return static_cast<VULKAN_HPP_NAMESPACE::DeviceSize>( result );
} }
VULKAN_HPP_INLINE void CommandBuffer::setRayTracingPipelineStackSizeKHR( uint32_t pipelineStackSize ) const VULKAN_HPP_NOEXCEPT 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 && VULKAN_HPP_ASSERT( getDispatcher()->vkGetPhysicalDeviceScreenPresentationSupportQNX &&
"Function <vkGetPhysicalDeviceScreenPresentationSupportQNX> needs extension <VK_QNX_screen_surface> enabled!" ); "Function <vkGetPhysicalDeviceScreenPresentationSupportQNX> needs extension <VK_QNX_screen_surface> enabled!" );
return static_cast<VULKAN_HPP_NAMESPACE::Bool32>( VkBool32 result =
getDispatcher()->vkGetPhysicalDeviceScreenPresentationSupportQNX( static_cast<VkPhysicalDevice>( m_physicalDevice ), queueFamilyIndex, &window ) ); getDispatcher()->vkGetPhysicalDeviceScreenPresentationSupportQNX( static_cast<VkPhysicalDevice>( m_physicalDevice ), queueFamilyIndex, &window );
return static_cast<VULKAN_HPP_NAMESPACE::Bool32>( result );
} }
# endif /*VK_USE_PLATFORM_SCREEN_QNX*/ # endif /*VK_USE_PLATFORM_SCREEN_QNX*/