Skip to content

Commit

Permalink
Removed special handling for enumerating commands with complex size i…
Browse files Browse the repository at this point in the history
…nformation via a struct, generating just the standard function in such cases (#1952)
  • Loading branch information
asuessenbach authored Aug 26, 2024
1 parent bd70384 commit 98ea600
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 197 deletions.
117 changes: 21 additions & 96 deletions VulkanHppGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3100,7 +3100,7 @@ std::string VulkanHppGenerator::generateCallSequence( std::string const &
{
std::string dispatcher = raii ? "getDispatcher()->" : "d.";

// first some special handling on vkCreatePipelineBinariesKHR and vkGetDeviceFaultInfoEXT!!
// first some special handling on vkCreatePipelineBinariesKHR !!
if ( name == "vkCreatePipelineBinariesKHR" )
{
#if !defined( NDEBUG )
Expand Down Expand Up @@ -3152,36 +3152,6 @@ std::string VulkanHppGenerator::generateCallSequence( std::string const &

return replaceWithMap( callSequenceTemplate, { { "callArguments", callArguments }, { "dispatcher", dispatcher }, { "vkCommand", name } } );
}
else if ( name == "vkGetDeviceFaultInfoEXT" )
{
const std::string callSequenceTemplate =
R"( VULKAN_HPP_NAMESPACE::Result result;
do
{
result = static_cast<VULKAN_HPP_NAMESPACE::Result>( ${dispatcher}vkGetDeviceFaultInfoEXT( m_device, reinterpret_cast<VkDeviceFaultCountsEXT *>( &faultCounts ), nullptr ) );
if ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess )
{
std::free( faultInfo.pAddressInfos );
if ( faultCounts.addressInfoCount )
{
faultInfo.pAddressInfos = reinterpret_cast<VULKAN_HPP_NAMESPACE::DeviceFaultAddressInfoEXT *>( std::malloc( faultCounts.addressInfoCount * sizeof( VULKAN_HPP_NAMESPACE::DeviceFaultAddressInfoEXT ) ) );
}
std::free( faultInfo.pVendorInfos );
if ( faultCounts.vendorInfoCount )
{
faultInfo.pVendorInfos = reinterpret_cast<VULKAN_HPP_NAMESPACE::DeviceFaultVendorInfoEXT *>( std::malloc( faultCounts.vendorInfoCount * sizeof( VULKAN_HPP_NAMESPACE::DeviceFaultVendorInfoEXT ) ) );
}
std::free( faultInfo.pVendorBinaryData );
if ( faultCounts.vendorBinarySize )
{
faultInfo.pVendorBinaryData = std::malloc( faultCounts.vendorBinarySize );
}
result = static_cast<VULKAN_HPP_NAMESPACE::Result>( ${dispatcher}vkGetDeviceFaultInfoEXT( m_device, reinterpret_cast<VkDeviceFaultCountsEXT *>( &faultCounts ), reinterpret_cast<VkDeviceFaultInfoEXT *>( &faultInfo ) ) );
}
} while ( result == VULKAN_HPP_NAMESPACE::Result::eIncomplete );)";

return replaceWithMap( callSequenceTemplate, { { "dispatcher", dispatcher } } );
}

// if at least one returnParam is a size value of a vector param (and no singular params), we need two calls
if ( singularParams.empty() &&
Expand Down Expand Up @@ -3843,28 +3813,6 @@ std::string VulkanHppGenerator::generateCommandResultMultiSuccessWithErrors1Retu
}
}
}
else if ( isStructureChainAnchor( commandData.params[returnParam].type.type ) )
{
std::map<size_t, VectorParamData> vectorParams = determineVectorParams( commandData.params );
if ( vectorParams.empty() )
{
#if 0
// needs to be verified ...
return generateCommandSetInclusive( name,
commandData,
initialSkipCount,
definition,
{ returnParam },
vectorParams,
false,
{ CommandFlavourFlagBits::enhanced, CommandFlavourFlagBits::chained },
raii,
false,
{ CommandFlavourFlagBits::enhanced, CommandFlavourFlagBits::chained } );
#endif
return "";
}
}
else if ( isHandleType( commandData.params[returnParam].type.type ) )
{
std::map<size_t, VectorParamData> vectorParams = determineVectorParams( commandData.params );
Expand Down Expand Up @@ -4023,28 +3971,10 @@ std::string VulkanHppGenerator::generateCommandResultMultiSuccessWithErrors2Retu
}
}
}
else if ( ( commandData.params[returnParams[0]].type.type != "void" ) && !isHandleType( commandData.params[returnParams[0]].type.type ) &&
!isStructureChainAnchor( commandData.params[returnParams[0]].type.type ) )
else if ( isStructureType( commandData.params[returnParams[0]].type.type ) )
{
if ( ( commandData.params[returnParams[1]].type.type != "void" ) && !isHandleType( commandData.params[returnParams[1]].type.type ) &&
!isStructureChainAnchor( commandData.params[returnParams[1]].type.type ) )
{
std::map<size_t, VectorParamData> vectorParams = determineVectorParams( commandData.params );
if ( vectorParams.empty() )
{
return generateCommandSetInclusive( name,
commandData,
initialSkipCount,
definition,
returnParams,
vectorParams,
false,
{ CommandFlavourFlagBits::enhanced },
raii,
false,
{ CommandFlavourFlagBits::enhanced } );
}
}
// can't generate an enhanced version for such a complex command! Just use the standard version
return generateCommandStandard( name, commandData, initialSkipCount, definition );
}
}

Expand Down Expand Up @@ -4092,11 +4022,9 @@ std::string VulkanHppGenerator::generateCommandResultMultiSuccessWithErrors3Retu
case 2:
if ( commandData.params[returnParams[0]].type.type == "uint32_t" )
{
if ( ( commandData.params[returnParams[1]].type.type != "void" ) && !isHandleType( commandData.params[returnParams[1]].type.type ) &&
!isStructureChainAnchor( commandData.params[returnParams[1]].type.type ) )
if ( isStructureType( commandData.params[returnParams[1]].type.type ) && !isStructureChainAnchor( commandData.params[returnParams[1]].type.type ) )
{
if ( ( commandData.params[returnParams[2]].type.type != "void" ) && !isHandleType( commandData.params[returnParams[2]].type.type ) &&
!isStructureChainAnchor( commandData.params[returnParams[2]].type.type ) )
if ( isStructureType( commandData.params[returnParams[2]].type.type ) && !isStructureChainAnchor( commandData.params[returnParams[2]].type.type ) )
{
if ( vectorParams.begin()->second.lenParam == std::next( vectorParams.begin() )->second.lenParam )
{
Expand Down Expand Up @@ -4197,8 +4125,7 @@ std::string VulkanHppGenerator::generateCommandResultSingleSuccessNoErrors(
std::map<size_t, VectorParamData> vectorParams = determineVectorParams( commandData.params );
if ( vectorParams.empty() )
{
if ( ( commandData.params[returnParams[0]].type.type != "void" ) && !isHandleType( commandData.params[returnParams[0]].type.type ) &&
!isStructureChainAnchor( commandData.params[returnParams[0]].type.type ) )
if ( isStructureType( commandData.params[returnParams[0]].type.type ) && !isStructureChainAnchor( commandData.params[returnParams[0]].type.type ) )
{
return generateCommandSetInclusive( name,
commandData,
Expand All @@ -4218,8 +4145,7 @@ std::string VulkanHppGenerator::generateCommandResultSingleSuccessNoErrors(
case 2:
if ( ( commandData.params[returnParams[0]].type.type == "size_t" ) || ( commandData.params[returnParams[0]].type.type == "uint32_t" ) )
{
if ( ( commandData.params[returnParams[1]].type.type != "void" ) && !isHandleType( commandData.params[returnParams[1]].type.type ) &&
!isStructureChainAnchor( commandData.params[returnParams[1]].type.type ) )
if ( isStructureType( commandData.params[returnParams[1]].type.type ) && !isStructureChainAnchor( commandData.params[returnParams[1]].type.type ) )
{
std::map<size_t, VectorParamData> vectorParams = determineVectorParams( commandData.params );
if ( vectorParams.size() == 1 )
Expand Down Expand Up @@ -4399,8 +4325,7 @@ std::string VulkanHppGenerator::generateCommandResultSingleSuccessWithErrors1Ret
{
if ( commandData.params[vectorParams.begin()->second.lenParam].type.type == "uint32_t" )
{
if ( ( commandData.params[vectorParams.begin()->first].type.type != "void" ) &&
!isHandleType( commandData.params[vectorParams.begin()->first].type.type ) &&
if ( isStructureType( commandData.params[vectorParams.begin()->first].type.type ) &&
!isStructureChainAnchor( commandData.params[vectorParams.begin()->first].type.type ) )
{
return generateCommandSetInclusive( name,
Expand Down Expand Up @@ -4519,8 +4444,7 @@ std::string VulkanHppGenerator::generateCommandResultSingleSuccessWithErrors2Ret
{
if ( commandData.params[vectorParams.begin()->second.lenParam].type.isValue() )
{
if ( ( commandData.params[vectorParams.begin()->first].type.type != "void" ) &&
!isHandleType( commandData.params[vectorParams.begin()->first].type.type ) &&
if ( isStructureType( commandData.params[vectorParams.begin()->first].type.type ) &&
!isStructureChainAnchor( commandData.params[vectorParams.begin()->first].type.type ) )
{
return generateCommandSetInclusive(
Expand Down Expand Up @@ -4553,10 +4477,9 @@ std::string VulkanHppGenerator::generateCommandResultSingleSuccessWithErrors3Ret
std::vector<size_t> const & returnParams,
bool raii ) const
{
if ( ( commandData.params[returnParams[0]].type.type != "void" ) && !isHandleType( commandData.params[returnParams[0]].type.type ) &&
!isStructureChainAnchor( commandData.params[returnParams[0]].type.type ) && commandData.params[returnParams[0]].lenParams.empty() &&
( commandData.params[returnParams[1]].type.type == "size_t" ) && commandData.params[returnParams[1]].lenParams.empty() &&
( commandData.params[returnParams[2]].type.type == "void" ) &&
if ( isStructureType( commandData.params[returnParams[0]].type.type ) && !isStructureChainAnchor( commandData.params[returnParams[0]].type.type ) &&
commandData.params[returnParams[0]].lenParams.empty() && ( commandData.params[returnParams[1]].type.type == "size_t" ) &&
commandData.params[returnParams[1]].lenParams.empty() && ( commandData.params[returnParams[2]].type.type == "void" ) &&
( commandData.params[returnParams[2]].lenExpression == commandData.params[returnParams[1]].name ) )
{
std::map<size_t, VectorParamData> vectorParams = determineVectorParams( commandData.params );
Expand Down Expand Up @@ -5009,11 +4932,9 @@ std::string VulkanHppGenerator::generateCommandVoid2Return( std::string const &
switch ( vectorParams.size() )
{
case 0:
if ( ( commandData.params[returnParams[0]].type.type != "void" ) && !isHandleType( commandData.params[returnParams[0]].type.type ) &&
!isStructureChainAnchor( commandData.params[returnParams[0]].type.type ) )
if ( isStructureType( commandData.params[returnParams[0]].type.type ) && !isStructureChainAnchor( commandData.params[returnParams[0]].type.type ) )
{
if ( ( commandData.params[returnParams[1]].type.type != "void" ) && !isHandleType( commandData.params[returnParams[1]].type.type ) &&
!isStructureChainAnchor( commandData.params[returnParams[1]].type.type ) )
if ( isStructureType( commandData.params[returnParams[1]].type.type ) && !isStructureChainAnchor( commandData.params[returnParams[1]].type.type ) )
{
return generateCommandSetInclusive( name,
commandData,
Expand Down Expand Up @@ -10290,8 +10211,7 @@ std::string VulkanHppGenerator::generateReturnStatement( std::string const & com
std::string returnStatement;
if ( commandData.returnType.starts_with( "Vk" ) )
{
if ( ( commandData.successCodes.size() == 1 ) || ( enumerating && ( commandData.successCodes.size() == 2 ) ) ||
( commandName == "vkGetDeviceFaultInfoEXT" ) )
if ( ( commandData.successCodes.size() == 1 ) || ( enumerating && ( commandData.successCodes.size() == 2 ) ) )
{
assert( commandData.successCodes[0] == "VK_SUCCESS" );
if ( raii || commandData.errorCodes.empty() )
Expand Down Expand Up @@ -13041,6 +12961,11 @@ bool VulkanHppGenerator::isStructureChainAnchor( std::string const & type ) cons
return false;
}

bool VulkanHppGenerator::isStructureType( std::string const & type ) const
{
return type.starts_with( "Vk" ) && ( findByNameOrAlias( m_structs, type ) != m_structs.end() );
}

bool VulkanHppGenerator::isSupported( std::set<std::string> const & requiredBy ) const
{
for ( auto const & r : requiredBy )
Expand Down
1 change: 1 addition & 0 deletions VulkanHppGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,7 @@ class VulkanHppGenerator
bool isParam( std::string const & name, std::vector<ParamData> const & params ) const;
bool isStructMember( std::string const & name, std::vector<MemberData> const & memberData ) const;
bool isStructureChainAnchor( std::string const & type ) const;
bool isStructureType( std::string const & type ) const;
bool isSupported( std::set<std::string> const & requiredBy ) const;
bool isSupportedExtension( std::string const & name ) const;
bool isSupportedFeature( std::string const & name ) const;
Expand Down
50 changes: 0 additions & 50 deletions vulkan/vulkan_funcs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22574,56 +22574,6 @@ namespace VULKAN_HPP_NAMESPACE
return static_cast<Result>( d.vkGetDeviceFaultInfoEXT(
m_device, reinterpret_cast<VkDeviceFaultCountsEXT *>( pFaultCounts ), reinterpret_cast<VkDeviceFaultInfoEXT *>( pFaultInfo ) ) );
}

#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch>
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE
typename ResultValueType<std::pair<VULKAN_HPP_NAMESPACE::DeviceFaultCountsEXT, VULKAN_HPP_NAMESPACE::DeviceFaultInfoEXT>>::type
Device::getFaultInfoEXT( Dispatch const & d ) const
{
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
# if ( VULKAN_HPP_DISPATCH_LOADER_DYNAMIC == 1 )
VULKAN_HPP_ASSERT( d.vkGetDeviceFaultInfoEXT && "Function <vkGetDeviceFaultInfoEXT> requires <VK_EXT_device_fault>" );
# endif

std::pair<VULKAN_HPP_NAMESPACE::DeviceFaultCountsEXT, VULKAN_HPP_NAMESPACE::DeviceFaultInfoEXT> data_;
VULKAN_HPP_NAMESPACE::DeviceFaultCountsEXT & faultCounts = data_.first;
VULKAN_HPP_NAMESPACE::DeviceFaultInfoEXT & faultInfo = data_.second;
VULKAN_HPP_NAMESPACE::Result result;
do
{
result =
static_cast<VULKAN_HPP_NAMESPACE::Result>( d.vkGetDeviceFaultInfoEXT( m_device, reinterpret_cast<VkDeviceFaultCountsEXT *>( &faultCounts ), nullptr ) );
if ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess )
{
std::free( faultInfo.pAddressInfos );
if ( faultCounts.addressInfoCount )
{
faultInfo.pAddressInfos = reinterpret_cast<VULKAN_HPP_NAMESPACE::DeviceFaultAddressInfoEXT *>(
std::malloc( faultCounts.addressInfoCount * sizeof( VULKAN_HPP_NAMESPACE::DeviceFaultAddressInfoEXT ) ) );
}
std::free( faultInfo.pVendorInfos );
if ( faultCounts.vendorInfoCount )
{
faultInfo.pVendorInfos = reinterpret_cast<VULKAN_HPP_NAMESPACE::DeviceFaultVendorInfoEXT *>(
std::malloc( faultCounts.vendorInfoCount * sizeof( VULKAN_HPP_NAMESPACE::DeviceFaultVendorInfoEXT ) ) );
}
std::free( faultInfo.pVendorBinaryData );
if ( faultCounts.vendorBinarySize )
{
faultInfo.pVendorBinaryData = std::malloc( faultCounts.vendorBinarySize );
}
result = static_cast<VULKAN_HPP_NAMESPACE::Result>( d.vkGetDeviceFaultInfoEXT(
m_device, reinterpret_cast<VkDeviceFaultCountsEXT *>( &faultCounts ), reinterpret_cast<VkDeviceFaultInfoEXT *>( &faultInfo ) ) );
}
} while ( result == VULKAN_HPP_NAMESPACE::Result::eIncomplete );
VULKAN_HPP_NAMESPACE::detail::resultCheck(
result, VULKAN_HPP_NAMESPACE_STRING "::Device::getFaultInfoEXT", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::eIncomplete } );

return VULKAN_HPP_NAMESPACE::detail::createResultValueType( result, std::move( data_ ) );
}
#endif /* VULKAN_HPP_DISABLE_ENHANCED_MODE */

#if defined( VK_USE_PLATFORM_WIN32_KHR )
//=== VK_NV_acquire_winrt_display ===

Expand Down
6 changes: 0 additions & 6 deletions vulkan/vulkan_handles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14457,12 +14457,6 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NODISCARD Result getFaultInfoEXT( VULKAN_HPP_NAMESPACE::DeviceFaultCountsEXT * pFaultCounts,
VULKAN_HPP_NAMESPACE::DeviceFaultInfoEXT * pFaultInfo,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD typename ResultValueType<std::pair<VULKAN_HPP_NAMESPACE::DeviceFaultCountsEXT, VULKAN_HPP_NAMESPACE::DeviceFaultInfoEXT>>::type
getFaultInfoEXT( Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
#endif /* VULKAN_HPP_DISABLE_ENHANCED_MODE */

#if defined( VK_USE_PLATFORM_FUCHSIA )
//=== VK_FUCHSIA_external_memory ===

Expand Down
Loading

0 comments on commit 98ea600

Please sign in to comment.