mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Fix determination of StructureChainAllocater usage for returned parameters. (#1591)
This commit is contained in:
parent
0ab2f4a18a
commit
bc19e479f9
@ -2099,6 +2099,7 @@ std::string VulkanHppGenerator::generateArgumentListEnhanced( std::vector<ParamD
|
|||||||
std::set<size_t> const & skippedParams,
|
std::set<size_t> const & skippedParams,
|
||||||
std::set<size_t> const & singularParams,
|
std::set<size_t> const & singularParams,
|
||||||
std::set<size_t> const & templatedParams,
|
std::set<size_t> const & templatedParams,
|
||||||
|
std::vector<size_t> const & chainedReturnParams,
|
||||||
bool definition,
|
bool definition,
|
||||||
CommandFlavourFlags flavourFlags,
|
CommandFlavourFlags flavourFlags,
|
||||||
bool withDispatcher ) const
|
bool withDispatcher ) const
|
||||||
@ -2212,7 +2213,22 @@ std::string VulkanHppGenerator::generateArgumentListEnhanced( std::vector<ParamD
|
|||||||
}
|
}
|
||||||
if ( withAllocators )
|
if ( withAllocators )
|
||||||
{
|
{
|
||||||
|
bool useStructureChainAllocator = false;
|
||||||
if ( flavourFlags & CommandFlavourFlagBits::chained )
|
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 )
|
if ( encounteredArgument )
|
||||||
{
|
{
|
||||||
@ -3224,14 +3240,14 @@ std::string VulkanHppGenerator::generateCommandEnhanced( std::string const &
|
|||||||
std::string argumentTemplates = generateArgumentTemplates( commandData.params, returnParams, vectorParams, templatedParams, chainedReturnParams, false );
|
std::string argumentTemplates = generateArgumentTemplates( commandData.params, returnParams, vectorParams, templatedParams, chainedReturnParams, false );
|
||||||
auto [allocatorTemplates, uniqueHandleAllocatorTemplates] =
|
auto [allocatorTemplates, uniqueHandleAllocatorTemplates] =
|
||||||
generateAllocatorTemplates( returnParams, dataTypes, vectorParams, chainedReturnParams, flavourFlags, definition );
|
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 nodiscard = generateNoDiscard( !returnParams.empty(), 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
|
||||||
std::string returnType = generateReturnType( commandData, returnParams, vectorParams, flavourFlags, false, dataTypes );
|
std::string returnType = generateReturnType( commandData, returnParams, vectorParams, flavourFlags, false, dataTypes );
|
||||||
std::string className = initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "";
|
std::string className = initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "";
|
||||||
std::string classSeparator = commandData.handle.empty() ? "" : "::";
|
std::string classSeparator = commandData.handle.empty() ? "" : "::";
|
||||||
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, flavourFlags );
|
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, flavourFlags );
|
||||||
std::string argumentList = generateArgumentListEnhanced(
|
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 constString = commandData.handle.empty() ? "" : " const";
|
||||||
std::string noexceptString = generateNoExcept( commandData.errorCodes, returnParams, vectorParams, flavourFlags, vectorSizeCheck.first, false );
|
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 argumentTemplates = generateArgumentTemplates( commandData.params, returnParams, vectorParams, templatedParams, chainedReturnParams, true );
|
||||||
std::string argumentList = generateArgumentListEnhanced(
|
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 commandName = generateCommandName( name, commandData.params, initialSkipCount, flavourFlags );
|
||||||
std::string nodiscard = generateNoDiscard(
|
std::string nodiscard = generateNoDiscard(
|
||||||
!returnParams.empty() || ( ( commandData.returnType != "VkResult" ) && ( commandData.returnType != "void" ) ), 1 < commandData.successCodes.size(), false );
|
!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::string VulkanHppGenerator::generateTypenameCheck( std::vector<size_t> const & returnParams,
|
||||||
std::map<size_t, VectorParamData> const & vectorParams,
|
std::map<size_t, VectorParamData> const & vectorParams,
|
||||||
|
std::vector<size_t> const & chainedReturnParams,
|
||||||
bool definition,
|
bool definition,
|
||||||
std::vector<std::string> const & dataTypes,
|
std::vector<std::string> const & dataTypes,
|
||||||
CommandFlavourFlags flavourFlags ) const
|
CommandFlavourFlags flavourFlags ) const
|
||||||
@ -10502,7 +10519,10 @@ std::string VulkanHppGenerator::generateTypenameCheck( std::vector<size_t> const
|
|||||||
{
|
{
|
||||||
if ( vectorParams.find( returnParams[i] ) != vectorParams.end() )
|
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;
|
std::string extendedElementType = elementType;
|
||||||
if ( flavourFlags & CommandFlavourFlagBits::unique )
|
if ( flavourFlags & CommandFlavourFlagBits::unique )
|
||||||
{
|
{
|
||||||
|
@ -491,6 +491,7 @@ private:
|
|||||||
std::set<size_t> const & skippedParams,
|
std::set<size_t> const & skippedParams,
|
||||||
std::set<size_t> const & singularParams,
|
std::set<size_t> const & singularParams,
|
||||||
std::set<size_t> const & templatedParams,
|
std::set<size_t> const & templatedParams,
|
||||||
|
std::vector<size_t> const & chainedReturnParams,
|
||||||
bool definition,
|
bool definition,
|
||||||
CommandFlavourFlags flavourFlags,
|
CommandFlavourFlags flavourFlags,
|
||||||
bool withDispatcher ) const;
|
bool withDispatcher ) const;
|
||||||
@ -886,6 +887,7 @@ private:
|
|||||||
std::string generateThrowResultException() const;
|
std::string generateThrowResultException() const;
|
||||||
std::string generateTypenameCheck( std::vector<size_t> const & returnParams,
|
std::string generateTypenameCheck( std::vector<size_t> const & returnParams,
|
||||||
std::map<size_t, VectorParamData> const & vectorParams,
|
std::map<size_t, VectorParamData> const & vectorParams,
|
||||||
|
std::vector<size_t> const & chainedReturnParams,
|
||||||
bool definition,
|
bool definition,
|
||||||
std::vector<std::string> const & dataTypes,
|
std::vector<std::string> const & dataTypes,
|
||||||
CommandFlavourFlags flavourFlags ) const;
|
CommandFlavourFlags flavourFlags ) const;
|
||||||
|
@ -20,6 +20,7 @@ add_subdirectory( DispatchLoaderDynamic )
|
|||||||
add_subdirectory( DispatchLoaderDynamicSharedLibrary )
|
add_subdirectory( DispatchLoaderDynamicSharedLibrary )
|
||||||
add_subdirectory( DispatchLoaderDynamicSharedLibraryClient )
|
add_subdirectory( DispatchLoaderDynamicSharedLibraryClient )
|
||||||
add_subdirectory( DispatchLoaderStatic )
|
add_subdirectory( DispatchLoaderStatic )
|
||||||
|
add_subdirectory( EnableBetaExtensions )
|
||||||
add_subdirectory( ExtensionInspection )
|
add_subdirectory( ExtensionInspection )
|
||||||
add_subdirectory( Flags )
|
add_subdirectory( Flags )
|
||||||
add_subdirectory( FormatTraits )
|
add_subdirectory( FormatTraits )
|
||||||
|
17
tests/EnableBetaExtensions/CMakeLists.txt
Normal file
17
tests/EnableBetaExtensions/CMakeLists.txt
Normal 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()
|
24
tests/EnableBetaExtensions/EnableBetaExtensions.cpp
Normal file
24
tests/EnableBetaExtensions/EnableBetaExtensions.cpp
Normal 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;
|
||||||
|
}
|
@ -18684,11 +18684,11 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
typename Uint8_tAllocator,
|
typename Uint8_tAllocator,
|
||||||
typename Dispatch,
|
typename Dispatch,
|
||||||
typename B2,
|
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
|
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE
|
||||||
typename ResultValueType<std::pair<VULKAN_HPP_NAMESPACE::StructureChain<X, Y, Z...>, std::vector<uint8_t, Uint8_tAllocator>>>::type
|
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,
|
Device::getEncodedVideoSessionParametersKHR( const VULKAN_HPP_NAMESPACE::VideoEncodeSessionParametersGetInfoKHR & videoSessionParametersInfo,
|
||||||
StructureChainAllocator & structureChainAllocator,
|
Uint8_tAllocator & uint8_tAllocator,
|
||||||
Dispatch const & d ) const
|
Dispatch const & d ) const
|
||||||
{
|
{
|
||||||
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
|
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
|
||||||
|
@ -12200,11 +12200,11 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
typename... Z,
|
typename... Z,
|
||||||
typename Uint8_tAllocator = std::allocator<uint8_t>,
|
typename Uint8_tAllocator = std::allocator<uint8_t>,
|
||||||
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE,
|
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE,
|
||||||
typename B2 = StructureChainAllocator,
|
typename B2 = Uint8_tAllocator,
|
||||||
typename std::enable_if<std::is_same<typename B2::value_type, StructureChain>::value, int>::type = 0>
|
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
|
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,
|
getEncodedVideoSessionParametersKHR( const VULKAN_HPP_NAMESPACE::VideoEncodeSessionParametersGetInfoKHR & videoSessionParametersInfo,
|
||||||
StructureChainAllocator & structureChainAllocator,
|
Uint8_tAllocator & uint8_tAllocator,
|
||||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
|
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
|
||||||
# endif /* VULKAN_HPP_DISABLE_ENHANCED_MODE */
|
# endif /* VULKAN_HPP_DISABLE_ENHANCED_MODE */
|
||||||
#endif /*VK_ENABLE_BETA_EXTENSIONS*/
|
#endif /*VK_ENABLE_BETA_EXTENSIONS*/
|
||||||
|
Loading…
Reference in New Issue
Block a user