Fix determination of StructureChainAllocater usage for returned parameters. (#1591)

This commit is contained in:
Andreas Süßenbach 2023-06-13 14:24:10 +02:00 committed by GitHub
parent 0ab2f4a18a
commit bc19e479f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 76 additions and 12 deletions

View File

@ -2099,6 +2099,7 @@ std::string VulkanHppGenerator::generateArgumentListEnhanced( std::vector<ParamD
std::set<size_t> const & skippedParams,
std::set<size_t> const & singularParams,
std::set<size_t> const & templatedParams,
std::vector<size_t> const & chainedReturnParams,
bool definition,
CommandFlavourFlags flavourFlags,
bool withDispatcher ) const
@ -2212,7 +2213,22 @@ std::string VulkanHppGenerator::generateArgumentListEnhanced( std::vector<ParamD
}
if ( withAllocators )
{
bool useStructureChainAllocator = false;
if ( flavourFlags & CommandFlavourFlagBits::chained )
{
// use StructureChainAllocator only, if a vector param is a chained return param
auto it = std::find_if(
chainedReturnParams.begin(), chainedReturnParams.end(), [&vectorParams]( size_t crp ) { return vectorParams.find( crp ) != vectorParams.end(); } );
if ( it != chainedReturnParams.end() )
{
// assert that there's no other chained vector param !
assert( std::find_if( std::next( it ),
chainedReturnParams.end(),
[&vectorParams]( size_t crp ) { return vectorParams.find( crp ) != vectorParams.end(); } ) == chainedReturnParams.end() );
useStructureChainAllocator = true;
}
}
if ( useStructureChainAllocator )
{
if ( encounteredArgument )
{
@ -3224,14 +3240,14 @@ std::string VulkanHppGenerator::generateCommandEnhanced( std::string const &
std::string argumentTemplates = generateArgumentTemplates( commandData.params, returnParams, vectorParams, templatedParams, chainedReturnParams, false );
auto [allocatorTemplates, uniqueHandleAllocatorTemplates] =
generateAllocatorTemplates( returnParams, dataTypes, vectorParams, chainedReturnParams, flavourFlags, definition );
std::string typenameCheck = generateTypenameCheck( returnParams, vectorParams, definition, dataTypes, flavourFlags );
std::string typenameCheck = generateTypenameCheck( returnParams, vectorParams, chainedReturnParams, definition, dataTypes, flavourFlags );
std::string nodiscard = generateNoDiscard( !returnParams.empty(), 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
std::string returnType = generateReturnType( commandData, returnParams, vectorParams, flavourFlags, false, dataTypes );
std::string className = initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "";
std::string classSeparator = commandData.handle.empty() ? "" : "::";
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, flavourFlags );
std::string argumentList = generateArgumentListEnhanced(
commandData.params, returnParams, vectorParams, skippedParams, singularParams, templatedParams, definition, flavourFlags, true );
commandData.params, returnParams, vectorParams, skippedParams, singularParams, templatedParams, chainedReturnParams, definition, flavourFlags, true );
std::string constString = commandData.handle.empty() ? "" : " const";
std::string noexceptString = generateNoExcept( commandData.errorCodes, returnParams, vectorParams, flavourFlags, vectorSizeCheck.first, false );
@ -7327,7 +7343,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandEnhanced( std::string c
std::string argumentTemplates = generateArgumentTemplates( commandData.params, returnParams, vectorParams, templatedParams, chainedReturnParams, true );
std::string argumentList = generateArgumentListEnhanced(
commandData.params, returnParams, vectorParams, skippedParams, singularParams, templatedParams, definition, flavourFlags, false );
commandData.params, returnParams, vectorParams, skippedParams, singularParams, templatedParams, chainedReturnParams, definition, flavourFlags, false );
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, flavourFlags );
std::string nodiscard = generateNoDiscard(
!returnParams.empty() || ( ( commandData.returnType != "VkResult" ) && ( commandData.returnType != "void" ) ), 1 < commandData.successCodes.size(), false );
@ -10491,6 +10507,7 @@ ${cases}
std::string VulkanHppGenerator::generateTypenameCheck( std::vector<size_t> const & returnParams,
std::map<size_t, VectorParamData> const & vectorParams,
std::vector<size_t> const & chainedReturnParams,
bool definition,
std::vector<std::string> const & dataTypes,
CommandFlavourFlags flavourFlags ) const
@ -10502,7 +10519,10 @@ std::string VulkanHppGenerator::generateTypenameCheck( std::vector<size_t> const
{
if ( vectorParams.find( returnParams[i] ) != vectorParams.end() )
{
std::string elementType = ( flavourFlags & CommandFlavourFlagBits::chained ) ? "StructureChain" : stripPrefix( dataTypes[i], "VULKAN_HPP_NAMESPACE::" );
std::string elementType = ( ( flavourFlags & CommandFlavourFlagBits::chained ) &&
( std::find( chainedReturnParams.begin(), chainedReturnParams.end(), returnParams[i] ) != chainedReturnParams.end() ) )
? "StructureChain"
: stripPrefix( dataTypes[i], "VULKAN_HPP_NAMESPACE::" );
std::string extendedElementType = elementType;
if ( flavourFlags & CommandFlavourFlagBits::unique )
{
@ -11973,7 +11993,7 @@ void VulkanHppGenerator::readExtension( tinyxml2::XMLElement const * element )
{ "(VK_KHR_get_physical_device_properties2,VK_VERSION_1_1)+(VK_KHR_dynamic_rendering,VK_VERSION_1_3)",
"VK_KHR_get_physical_device_properties2+VK_KHR_dynamic_rendering,VK_VERSION_1_1+VK_KHR_dynamic_rendering,VK_VERSION_1_3" }
};
auto canonicalIt = complexToCanonicalDepends.find( attribute.second );
auto canonicalIt = complexToCanonicalDepends.find( attribute.second );
std::string depends;
if ( canonicalIt == complexToCanonicalDepends.end() )
{

View File

@ -491,6 +491,7 @@ private:
std::set<size_t> const & skippedParams,
std::set<size_t> const & singularParams,
std::set<size_t> const & templatedParams,
std::vector<size_t> const & chainedReturnParams,
bool definition,
CommandFlavourFlags flavourFlags,
bool withDispatcher ) const;
@ -886,6 +887,7 @@ private:
std::string generateThrowResultException() const;
std::string generateTypenameCheck( std::vector<size_t> const & returnParams,
std::map<size_t, VectorParamData> const & vectorParams,
std::vector<size_t> const & chainedReturnParams,
bool definition,
std::vector<std::string> const & dataTypes,
CommandFlavourFlags flavourFlags ) const;

View File

@ -20,6 +20,7 @@ add_subdirectory( DispatchLoaderDynamic )
add_subdirectory( DispatchLoaderDynamicSharedLibrary )
add_subdirectory( DispatchLoaderDynamicSharedLibraryClient )
add_subdirectory( DispatchLoaderStatic )
add_subdirectory( EnableBetaExtensions )
add_subdirectory( ExtensionInspection )
add_subdirectory( Flags )
add_subdirectory( FormatTraits )

View File

@ -0,0 +1,17 @@
# Copyright(c) 2023, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if( NOT VULKAN_HPP_TESTS_BUILD_ONLY_DYNAMIC )
vulkan_hpp__setup_test( NAME EnableBetaExtensions )
endif()

View File

@ -0,0 +1,24 @@
// Copyright(c) 2023, NVIDIA CORPORATION. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// VulkanHpp Tests : EnableBetaExtensions
// Compile test with VK_ENABLE_BETA_EXTENSIONS defined
#define VK_ENABLE_BETA_EXTENSIONS
#include <vulkan/vulkan.hpp>
int main(int /*argc*/, char** /*argv*/)
{
return 0;
}

View File

@ -18684,11 +18684,11 @@ namespace VULKAN_HPP_NAMESPACE
typename Uint8_tAllocator,
typename Dispatch,
typename B2,
typename std::enable_if<std::is_same<typename B2::value_type, StructureChain>::value, int>::type>
typename std::enable_if<std::is_same<typename B2::value_type, uint8_t>::value, int>::type>
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE
typename ResultValueType<std::pair<VULKAN_HPP_NAMESPACE::StructureChain<X, Y, Z...>, std::vector<uint8_t, Uint8_tAllocator>>>::type
Device::getEncodedVideoSessionParametersKHR( const VULKAN_HPP_NAMESPACE::VideoEncodeSessionParametersGetInfoKHR & videoSessionParametersInfo,
StructureChainAllocator & structureChainAllocator,
Uint8_tAllocator & uint8_tAllocator,
Dispatch const & d ) const
{
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );

View File

@ -12198,13 +12198,13 @@ namespace VULKAN_HPP_NAMESPACE
template <typename X,
typename Y,
typename... Z,
typename Uint8_tAllocator = std::allocator<uint8_t>,
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE,
typename B2 = StructureChainAllocator,
typename std::enable_if<std::is_same<typename B2::value_type, StructureChain>::value, int>::type = 0>
typename Uint8_tAllocator = std::allocator<uint8_t>,
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE,
typename B2 = Uint8_tAllocator,
typename std::enable_if<std::is_same<typename B2::value_type, uint8_t>::value, int>::type = 0>
VULKAN_HPP_NODISCARD typename ResultValueType<std::pair<VULKAN_HPP_NAMESPACE::StructureChain<X, Y, Z...>, std::vector<uint8_t, Uint8_tAllocator>>>::type
getEncodedVideoSessionParametersKHR( const VULKAN_HPP_NAMESPACE::VideoEncodeSessionParametersGetInfoKHR & videoSessionParametersInfo,
StructureChainAllocator & structureChainAllocator,
Uint8_tAllocator & uint8_tAllocator,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
# endif /* VULKAN_HPP_DISABLE_ENHANCED_MODE */
#endif /*VK_ENABLE_BETA_EXTENSIONS*/