Merge pull request #1286 from asuessenbach/function

Combine two types of commands into one generation function
This commit is contained in:
Andreas Süßenbach 2022-04-14 09:40:22 +02:00 committed by GitHub
commit 25256d1d59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 84 deletions

View File

@ -3445,51 +3445,6 @@ std::string VulkanHppGenerator::generateCommandResultEnumerateTwoVectors( std::s
}
}
std::string VulkanHppGenerator::generateCommandResultGetChain(
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam ) const
{
assert( !commandData.handle.empty() && ( commandData.returnType == "VkResult" ) && !commandData.errorCodes.empty() );
std::set<size_t> skippedParams = determineSkippedParams( commandData.params, initialSkipCount, {}, { returnParam }, false );
std::string argumentList = generateArgumentListEnhanced( commandData.params, skippedParams, {}, {}, definition, false, false, true );
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags, false, false );
std::string nodiscard = generateNoDiscard( true, 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
std::string returnType = stripPostfix( commandData.params[returnParam].type.compose( "VULKAN_HPP_NAMESPACE" ), " *" );
if ( definition )
{
std::string const functionTemplate =
R"( template <typename X, typename Y, typename... Z, typename Dispatch>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<StructureChain<X, Y, Z...>>::type ${className}${classSeparator}${commandName}( ${argumentList} ) const
{
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
StructureChain<X, Y, Z...> structureChain;
${returnType} & ${returnVariable} = structureChain.template get<${returnType}>();
Result result = static_cast<Result>( d.${vkCommand}( ${callArguments} ) );
return createResultValue( result, structureChain, VULKAN_HPP_NAMESPACE_STRING"::${className}${classSeparator}${commandName}"${successCodeList} );
})";
return replaceWithMap( functionTemplate,
{ { "argumentList", argumentList },
{ "callArguments", generateCallArgumentsEnhanced( commandData, initialSkipCount, false, {}, {}, false ) },
{ "className", initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "" },
{ "classSeparator", commandData.handle.empty() ? "" : "::" },
{ "commandName", commandName },
{ "returnVariable", startLowerCase( stripPrefix( commandData.params[returnParam].name, "p" ) ) },
{ "returnType", returnType },
{ "successCodeList", generateSuccessCodeList( commandData.successCodes ) },
{ "vkCommand", name } } );
}
else
{
std::string const functionTemplate =
R"( template <typename X, typename Y, typename... Z, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<StructureChain<X, Y, Z...>>::type ${commandName}( ${argumentList} ) const;)";
return replaceWithMap( functionTemplate, { { "argumentList", argumentList }, { "commandName", commandName } } );
}
}
std::string VulkanHppGenerator::generateCommandResultGetVectorAndValue( std::string const & name,
CommandData const & commandData,
size_t initialSkipCount,
@ -4007,7 +3962,7 @@ std::string VulkanHppGenerator::generateCommandResultSingleSuccessWithErrors1Ret
definition,
generateCommandStandard( name, commandData, initialSkipCount, definition ),
generateCommandSingle( name, commandData, initialSkipCount, definition, vectorParams, { returnParam }, false, false, false, false ),
generateCommandResultGetChain( name, commandData, initialSkipCount, definition, returnParam ) );
generateCommandSingle( name, commandData, initialSkipCount, definition, vectorParams, { returnParam }, false, false, true, false ) );
}
return "";
}
@ -5030,7 +4985,7 @@ std::string VulkanHppGenerator::generateDataDeclarations( CommandData const &
case 1:
if ( chained )
{
assert( commandData.returnType == "void" );
assert( ( commandData.returnType == "void" ) || ( commandData.returnType == "VkResult" ) );
assert( vectorParams.empty() );
std::string const dataDeclarationsTemplate = R"(${returnType} ${returnVariable};
${dataType} & ${dataVariable} = ${returnVariable}.template get<${dataType}>();)";
@ -5038,7 +4993,7 @@ std::string VulkanHppGenerator::generateDataDeclarations( CommandData const &
dataDeclarations = replaceWithMap( dataDeclarationsTemplate,
{ { "dataType", dataTypes[0] },
{ "dataVariable", startLowerCase( stripPrefix( commandData.params[returnParams[0]].name, "p" ) ) },
{ "returnType", returnType },
{ "returnType", ( commandData.returnType == "void" ) ? returnType : "StructureChain<X, Y, Z...>" },
{ "returnVariable", returnVariable } } );
}
else
@ -10129,9 +10084,14 @@ std::string VulkanHppGenerator::generateReturnType( CommandData const &
std::string returnType;
if ( chained )
{
assert( ( commandData.returnType == "void" ) && ( returnParams.size() == 1 ) );
assert( ( commandData.returnType == "void" ) || ( commandData.returnType == "VkResult" ) );
assert( returnParams.size() == 1 );
assert( isStructureChainAnchor( commandData.params[returnParams[0]].type.type ) );
returnType = "StructureChain<X, Y, Z...>";
if ( commandData.returnType == "VkResult" )
{
returnType = "typename ResultValueType<" + returnType + ">::type";
}
}
else if ( commandData.returnType == "VkResult" )
{

View File

@ -484,8 +484,6 @@ private:
std::map<size_t, size_t> const & vectorParamIndices,
std::vector<size_t> const & returnParamIndices,
bool withAllocators ) const;
std::string generateCommandResultGetChain(
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam ) const;
std::string generateCommandResultGetVectorAndValue( std::string const & name,
CommandData const & commandData,
size_t initialSkipCount,

View File

@ -5528,17 +5528,18 @@ namespace VULKAN_HPP_NAMESPACE
}
template <typename X, typename Y, typename... Z, typename Dispatch>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<StructureChain<X, Y, Z...>>::type
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE typename ResultValueType<StructureChain<X, Y, Z...>>::type
PhysicalDevice::getImageFormatProperties2( const VULKAN_HPP_NAMESPACE::PhysicalDeviceImageFormatInfo2 & imageFormatInfo, Dispatch const & d ) const
{
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
StructureChain<X, Y, Z...> structureChain;
VULKAN_HPP_NAMESPACE::ImageFormatProperties2 & imageFormatProperties = structureChain.template get<VULKAN_HPP_NAMESPACE::ImageFormatProperties2>();
Result result =
static_cast<Result>( d.vkGetPhysicalDeviceImageFormatProperties2( m_physicalDevice,
reinterpret_cast<const VkPhysicalDeviceImageFormatInfo2 *>( &imageFormatInfo ),
reinterpret_cast<VkImageFormatProperties2 *>( &imageFormatProperties ) ) );
return createResultValue( result, structureChain, VULKAN_HPP_NAMESPACE_STRING "::PhysicalDevice::getImageFormatProperties2" );
VkResult result = d.vkGetPhysicalDeviceImageFormatProperties2( m_physicalDevice,
reinterpret_cast<const VkPhysicalDeviceImageFormatInfo2 *>( &imageFormatInfo ),
reinterpret_cast<VkImageFormatProperties2 *>( &imageFormatProperties ) );
resultCheck( static_cast<VULKAN_HPP_NAMESPACE::Result>( result ), VULKAN_HPP_NAMESPACE_STRING "::PhysicalDevice::getImageFormatProperties2" );
return createResultValueType( static_cast<VULKAN_HPP_NAMESPACE::Result>( result ), structureChain );
}
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -9117,15 +9118,17 @@ namespace VULKAN_HPP_NAMESPACE
}
template <typename X, typename Y, typename... Z, typename Dispatch>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<StructureChain<X, Y, Z...>>::type
PhysicalDevice::getVideoCapabilitiesKHR( const VULKAN_HPP_NAMESPACE::VideoProfileKHR & videoProfile, Dispatch const & d ) const
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE typename ResultValueType<StructureChain<X, Y, Z...>>::type
PhysicalDevice::getVideoCapabilitiesKHR( const VULKAN_HPP_NAMESPACE::VideoProfileKHR & videoProfile, Dispatch const & d ) const
{
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
StructureChain<X, Y, Z...> structureChain;
VULKAN_HPP_NAMESPACE::VideoCapabilitiesKHR & capabilities = structureChain.template get<VULKAN_HPP_NAMESPACE::VideoCapabilitiesKHR>();
Result result = static_cast<Result>( d.vkGetPhysicalDeviceVideoCapabilitiesKHR(
m_physicalDevice, reinterpret_cast<const VkVideoProfileKHR *>( &videoProfile ), reinterpret_cast<VkVideoCapabilitiesKHR *>( &capabilities ) ) );
return createResultValue( result, structureChain, VULKAN_HPP_NAMESPACE_STRING "::PhysicalDevice::getVideoCapabilitiesKHR" );
VkResult result = d.vkGetPhysicalDeviceVideoCapabilitiesKHR(
m_physicalDevice, reinterpret_cast<const VkVideoProfileKHR *>( &videoProfile ), reinterpret_cast<VkVideoCapabilitiesKHR *>( &capabilities ) );
resultCheck( static_cast<VULKAN_HPP_NAMESPACE::Result>( result ), VULKAN_HPP_NAMESPACE_STRING "::PhysicalDevice::getVideoCapabilitiesKHR" );
return createResultValueType( static_cast<VULKAN_HPP_NAMESPACE::Result>( result ), structureChain );
}
# endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -10545,17 +10548,18 @@ namespace VULKAN_HPP_NAMESPACE
}
template <typename X, typename Y, typename... Z, typename Dispatch>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<StructureChain<X, Y, Z...>>::type
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE typename ResultValueType<StructureChain<X, Y, Z...>>::type
PhysicalDevice::getImageFormatProperties2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceImageFormatInfo2 & imageFormatInfo, Dispatch const & d ) const
{
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
StructureChain<X, Y, Z...> structureChain;
VULKAN_HPP_NAMESPACE::ImageFormatProperties2 & imageFormatProperties = structureChain.template get<VULKAN_HPP_NAMESPACE::ImageFormatProperties2>();
Result result =
static_cast<Result>( d.vkGetPhysicalDeviceImageFormatProperties2KHR( m_physicalDevice,
reinterpret_cast<const VkPhysicalDeviceImageFormatInfo2 *>( &imageFormatInfo ),
reinterpret_cast<VkImageFormatProperties2 *>( &imageFormatProperties ) ) );
return createResultValue( result, structureChain, VULKAN_HPP_NAMESPACE_STRING "::PhysicalDevice::getImageFormatProperties2KHR" );
VkResult result = d.vkGetPhysicalDeviceImageFormatProperties2KHR( m_physicalDevice,
reinterpret_cast<const VkPhysicalDeviceImageFormatInfo2 *>( &imageFormatInfo ),
reinterpret_cast<VkImageFormatProperties2 *>( &imageFormatProperties ) );
resultCheck( static_cast<VULKAN_HPP_NAMESPACE::Result>( result ), VULKAN_HPP_NAMESPACE_STRING "::PhysicalDevice::getImageFormatProperties2KHR" );
return createResultValueType( static_cast<VULKAN_HPP_NAMESPACE::Result>( result ), structureChain );
}
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -12360,17 +12364,18 @@ namespace VULKAN_HPP_NAMESPACE
}
template <typename X, typename Y, typename... Z, typename Dispatch>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<StructureChain<X, Y, Z...>>::type
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE typename ResultValueType<StructureChain<X, Y, Z...>>::type
PhysicalDevice::getSurfaceCapabilities2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSurfaceInfo2KHR & surfaceInfo, Dispatch const & d ) const
{
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
StructureChain<X, Y, Z...> structureChain;
VULKAN_HPP_NAMESPACE::SurfaceCapabilities2KHR & surfaceCapabilities = structureChain.template get<VULKAN_HPP_NAMESPACE::SurfaceCapabilities2KHR>();
Result result =
static_cast<Result>( d.vkGetPhysicalDeviceSurfaceCapabilities2KHR( m_physicalDevice,
reinterpret_cast<const VkPhysicalDeviceSurfaceInfo2KHR *>( &surfaceInfo ),
reinterpret_cast<VkSurfaceCapabilities2KHR *>( &surfaceCapabilities ) ) );
return createResultValue( result, structureChain, VULKAN_HPP_NAMESPACE_STRING "::PhysicalDevice::getSurfaceCapabilities2KHR" );
VkResult result = d.vkGetPhysicalDeviceSurfaceCapabilities2KHR( m_physicalDevice,
reinterpret_cast<const VkPhysicalDeviceSurfaceInfo2KHR *>( &surfaceInfo ),
reinterpret_cast<VkSurfaceCapabilities2KHR *>( &surfaceCapabilities ) );
resultCheck( static_cast<VULKAN_HPP_NAMESPACE::Result>( result ), VULKAN_HPP_NAMESPACE_STRING "::PhysicalDevice::getSurfaceCapabilities2KHR" );
return createResultValueType( static_cast<VULKAN_HPP_NAMESPACE::Result>( result ), structureChain );
}
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -13126,16 +13131,18 @@ namespace VULKAN_HPP_NAMESPACE
}
template <typename X, typename Y, typename... Z, typename Dispatch>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<StructureChain<X, Y, Z...>>::type
Device::getAndroidHardwareBufferPropertiesANDROID( const struct AHardwareBuffer & buffer, Dispatch const & d ) const
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE typename ResultValueType<StructureChain<X, Y, Z...>>::type
Device::getAndroidHardwareBufferPropertiesANDROID( const struct AHardwareBuffer & buffer, Dispatch const & d ) const
{
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
StructureChain<X, Y, Z...> structureChain;
VULKAN_HPP_NAMESPACE::AndroidHardwareBufferPropertiesANDROID & properties =
structureChain.template get<VULKAN_HPP_NAMESPACE::AndroidHardwareBufferPropertiesANDROID>();
Result result = static_cast<Result>(
d.vkGetAndroidHardwareBufferPropertiesANDROID( m_device, &buffer, reinterpret_cast<VkAndroidHardwareBufferPropertiesANDROID *>( &properties ) ) );
return createResultValue( result, structureChain, VULKAN_HPP_NAMESPACE_STRING "::Device::getAndroidHardwareBufferPropertiesANDROID" );
VkResult result =
d.vkGetAndroidHardwareBufferPropertiesANDROID( m_device, &buffer, reinterpret_cast<VkAndroidHardwareBufferPropertiesANDROID *>( &properties ) );
resultCheck( static_cast<VULKAN_HPP_NAMESPACE::Result>( result ), VULKAN_HPP_NAMESPACE_STRING "::Device::getAndroidHardwareBufferPropertiesANDROID" );
return createResultValueType( static_cast<VULKAN_HPP_NAMESPACE::Result>( result ), structureChain );
}
# endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/

View File

@ -9806,7 +9806,7 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NODISCARD typename ResultValueType<VULKAN_HPP_NAMESPACE::AndroidHardwareBufferPropertiesANDROID>::type
getAndroidHardwareBufferPropertiesANDROID( const struct AHardwareBuffer & buffer, Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
template <typename X, typename Y, typename... Z, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<StructureChain<X, Y, Z...>>::type
VULKAN_HPP_NODISCARD typename ResultValueType<StructureChain<X, Y, Z...>>::type
getAndroidHardwareBufferPropertiesANDROID( const struct AHardwareBuffer & buffer, Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
# endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -11620,7 +11620,7 @@ namespace VULKAN_HPP_NAMESPACE
getImageFormatProperties2( const VULKAN_HPP_NAMESPACE::PhysicalDeviceImageFormatInfo2 & imageFormatInfo,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
template <typename X, typename Y, typename... Z, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<StructureChain<X, Y, Z...>>::type
VULKAN_HPP_NODISCARD typename ResultValueType<StructureChain<X, Y, Z...>>::type
getImageFormatProperties2( const VULKAN_HPP_NAMESPACE::PhysicalDeviceImageFormatInfo2 & imageFormatInfo,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -11996,7 +11996,7 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NODISCARD typename ResultValueType<VULKAN_HPP_NAMESPACE::VideoCapabilitiesKHR>::type
getVideoCapabilitiesKHR( const VULKAN_HPP_NAMESPACE::VideoProfileKHR & videoProfile, Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
template <typename X, typename Y, typename... Z, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<StructureChain<X, Y, Z...>>::type
VULKAN_HPP_NODISCARD typename ResultValueType<StructureChain<X, Y, Z...>>::type
getVideoCapabilitiesKHR( const VULKAN_HPP_NAMESPACE::VideoProfileKHR & videoProfile, Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
# endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -12091,7 +12091,7 @@ namespace VULKAN_HPP_NAMESPACE
getImageFormatProperties2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceImageFormatInfo2 & imageFormatInfo,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
template <typename X, typename Y, typename... Z, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<StructureChain<X, Y, Z...>>::type
VULKAN_HPP_NODISCARD typename ResultValueType<StructureChain<X, Y, Z...>>::type
getImageFormatProperties2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceImageFormatInfo2 & imageFormatInfo,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -12304,7 +12304,7 @@ namespace VULKAN_HPP_NAMESPACE
getSurfaceCapabilities2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSurfaceInfo2KHR & surfaceInfo,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
template <typename X, typename Y, typename... Z, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<StructureChain<X, Y, Z...>>::type
VULKAN_HPP_NODISCARD typename ResultValueType<StructureChain<X, Y, Z...>>::type
getSurfaceCapabilities2KHR( const VULKAN_HPP_NAMESPACE::PhysicalDeviceSurfaceInfo2KHR & surfaceInfo,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/