From 407542705f360607ee9f4921c2f1c4a97ef0ab19 Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Tue, 31 Mar 2020 09:26:02 +0200 Subject: [PATCH] Change allocation of vectors of UniqueHandles to not rely on std::vector<>::data() returning a valid pointer after calling std::vector<>::reserve(). --- VulkanHppGenerator.cpp | 15 ++-- vulkan/vulkan.hpp | 182 +++++++++++++++++++---------------------- 2 files changed, 92 insertions(+), 105 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index f779b68..8dde742 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -1977,25 +1977,25 @@ ${i} return ${returnName}; void VulkanHppGenerator::appendFunctionBodyEnhancedVectorOfUniqueHandles(std::string & str, std::string const& indentation, std::string const& name, CommandData const& commandData, size_t returnParamIndex, size_t templateParamIndex, std::map const& vectorParamIndices, bool twoStep, bool singular, bool withAllocator) const { std::string const stringTemplate = - R"(${i} static_assert( sizeof( ${type} ) <= sizeof( UniqueHandle<${type}, Dispatch> ), "${type} is greater than UniqueHandle<${type}, Dispatch>!" ); -${i} std::vector, Allocator> ${typeVariable}s${allocator}; -${i} ${typeVariable}s.reserve( ${vectorSize} ); -${i} ${type}* buffer = reinterpret_cast<${type}*>( reinterpret_cast( ${typeVariable}s.data() ) + ${vectorSize} * ( sizeof( UniqueHandle<${type}, Dispatch> ) - sizeof( ${type} ) ) ); -${i} Result result = static_cast(d.vk${command}( m_device, ${arguments}, reinterpret_cast( buffer ) ) ); + R"(${i} std::vector, Allocator> ${uniqueTypeVariable}s${allocator}; +${i} std::vector<${type}> ${typeVariable}s( ${vectorSize} ); +${i} Result result = static_cast( d.vk${command}( m_device, ${arguments}, reinterpret_cast(${typeVariable}s.data()) ) ); ${i} if ( ${successChecks} ) ${i} { +${i} ${uniqueTypeVariable}s.reserve( ${vectorSize} ); ${i} ${Deleter}<${DeleterTemplate},Dispatch> deleter( *this, ${deleterArg}, d ); ${i} for ( size_t i=0 ; i<${vectorSize} ; i++ ) ${i} { -${i} ${typeVariable}s.push_back( UniqueHandle<${type}, Dispatch>( buffer[i], deleter ) ); +${i} ${uniqueTypeVariable}s.push_back( UniqueHandle<${type}, Dispatch>( ${typeVariable}s[i], deleter ) ); ${i} } ${i} } -${i} return createResultValue( result, ${typeVariable}s, VULKAN_HPP_NAMESPACE_STRING "::${class}::${commandName}Unique"${successCodes} ); +${i} return createResultValue( result, ${uniqueTypeVariable}s, VULKAN_HPP_NAMESPACE_STRING "::${class}::${commandName}Unique"${successCodes} ); )"; std::string type = (returnParamIndex != INVALID_INDEX) ? commandData.params[returnParamIndex].type.type : ""; std::string typeVariable = startLowerCase(stripPrefix(type, "Vk")); + std::string uniqueTypeVariable = "unique" + stripPrefix(type, "Vk"); std::string arguments; appendArguments(arguments, commandData, returnParamIndex, templateParamIndex, vectorParamIndices, twoStep, true, singular, 1, commandData.params.size() - 1); @@ -2037,6 +2037,7 @@ ${i} return createResultValue( result, ${typeVariable}s, VULKAN_HPP_NAMESPACE_S { "successCodes", successCodes }, { "type", stripPrefix(type, "Vk") }, { "typeVariable", typeVariable }, + { "uniqueTypeVariable", uniqueTypeVariable }, { "vectorSize", isCreateFunction ? "createInfos.size()" : "allocateInfo." + typeVariable + "Count" } }); } diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 316cd2a..1880e10 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -68841,40 +68841,38 @@ namespace VULKAN_HPP_NAMESPACE template VULKAN_HPP_INLINE typename ResultValueType,Allocator>>::type Device::allocateCommandBuffersUnique( const CommandBufferAllocateInfo & allocateInfo, Dispatch const &d ) const { - static_assert( sizeof( CommandBuffer ) <= sizeof( UniqueHandle ), "CommandBuffer is greater than UniqueHandle!" ); - std::vector, Allocator> commandBuffers; - commandBuffers.reserve( allocateInfo.commandBufferCount ); - CommandBuffer* buffer = reinterpret_cast( reinterpret_cast( commandBuffers.data() ) + allocateInfo.commandBufferCount * ( sizeof( UniqueHandle ) - sizeof( CommandBuffer ) ) ); - Result result = static_cast(d.vkAllocateCommandBuffers( m_device, reinterpret_cast( &allocateInfo ), reinterpret_cast( buffer ) ) ); + std::vector, Allocator> uniqueCommandBuffers; + std::vector commandBuffers( allocateInfo.commandBufferCount ); + Result result = static_cast( d.vkAllocateCommandBuffers( m_device, reinterpret_cast( &allocateInfo ), reinterpret_cast(commandBuffers.data()) ) ); if ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) { + uniqueCommandBuffers.reserve( allocateInfo.commandBufferCount ); PoolFree deleter( *this, allocateInfo.commandPool, d ); for ( size_t i=0 ; i( buffer[i], deleter ) ); + uniqueCommandBuffers.push_back( UniqueHandle( commandBuffers[i], deleter ) ); } } - return createResultValue( result, commandBuffers, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateCommandBuffersUnique" ); + return createResultValue( result, uniqueCommandBuffers, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateCommandBuffersUnique" ); } template VULKAN_HPP_INLINE typename ResultValueType,Allocator>>::type Device::allocateCommandBuffersUnique( const CommandBufferAllocateInfo & allocateInfo, Allocator const& vectorAllocator, Dispatch const &d ) const { - static_assert( sizeof( CommandBuffer ) <= sizeof( UniqueHandle ), "CommandBuffer is greater than UniqueHandle!" ); - std::vector, Allocator> commandBuffers( vectorAllocator ); - commandBuffers.reserve( allocateInfo.commandBufferCount ); - CommandBuffer* buffer = reinterpret_cast( reinterpret_cast( commandBuffers.data() ) + allocateInfo.commandBufferCount * ( sizeof( UniqueHandle ) - sizeof( CommandBuffer ) ) ); - Result result = static_cast(d.vkAllocateCommandBuffers( m_device, reinterpret_cast( &allocateInfo ), reinterpret_cast( buffer ) ) ); + std::vector, Allocator> uniqueCommandBuffers( vectorAllocator ); + std::vector commandBuffers( allocateInfo.commandBufferCount ); + Result result = static_cast( d.vkAllocateCommandBuffers( m_device, reinterpret_cast( &allocateInfo ), reinterpret_cast(commandBuffers.data()) ) ); if ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) { + uniqueCommandBuffers.reserve( allocateInfo.commandBufferCount ); PoolFree deleter( *this, allocateInfo.commandPool, d ); for ( size_t i=0 ; i( buffer[i], deleter ) ); + uniqueCommandBuffers.push_back( UniqueHandle( commandBuffers[i], deleter ) ); } } - return createResultValue( result, commandBuffers, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateCommandBuffersUnique" ); + return createResultValue( result, uniqueCommandBuffers, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateCommandBuffersUnique" ); } #endif /*VULKAN_HPP_NO_SMART_HANDLE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ @@ -68903,40 +68901,38 @@ namespace VULKAN_HPP_NAMESPACE template VULKAN_HPP_INLINE typename ResultValueType,Allocator>>::type Device::allocateDescriptorSetsUnique( const DescriptorSetAllocateInfo & allocateInfo, Dispatch const &d ) const { - static_assert( sizeof( DescriptorSet ) <= sizeof( UniqueHandle ), "DescriptorSet is greater than UniqueHandle!" ); - std::vector, Allocator> descriptorSets; - descriptorSets.reserve( allocateInfo.descriptorSetCount ); - DescriptorSet* buffer = reinterpret_cast( reinterpret_cast( descriptorSets.data() ) + allocateInfo.descriptorSetCount * ( sizeof( UniqueHandle ) - sizeof( DescriptorSet ) ) ); - Result result = static_cast(d.vkAllocateDescriptorSets( m_device, reinterpret_cast( &allocateInfo ), reinterpret_cast( buffer ) ) ); + std::vector, Allocator> uniqueDescriptorSets; + std::vector descriptorSets( allocateInfo.descriptorSetCount ); + Result result = static_cast( d.vkAllocateDescriptorSets( m_device, reinterpret_cast( &allocateInfo ), reinterpret_cast(descriptorSets.data()) ) ); if ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) { + uniqueDescriptorSets.reserve( allocateInfo.descriptorSetCount ); PoolFree deleter( *this, allocateInfo.descriptorPool, d ); for ( size_t i=0 ; i( buffer[i], deleter ) ); + uniqueDescriptorSets.push_back( UniqueHandle( descriptorSets[i], deleter ) ); } } - return createResultValue( result, descriptorSets, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateDescriptorSetsUnique" ); + return createResultValue( result, uniqueDescriptorSets, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateDescriptorSetsUnique" ); } template VULKAN_HPP_INLINE typename ResultValueType,Allocator>>::type Device::allocateDescriptorSetsUnique( const DescriptorSetAllocateInfo & allocateInfo, Allocator const& vectorAllocator, Dispatch const &d ) const { - static_assert( sizeof( DescriptorSet ) <= sizeof( UniqueHandle ), "DescriptorSet is greater than UniqueHandle!" ); - std::vector, Allocator> descriptorSets( vectorAllocator ); - descriptorSets.reserve( allocateInfo.descriptorSetCount ); - DescriptorSet* buffer = reinterpret_cast( reinterpret_cast( descriptorSets.data() ) + allocateInfo.descriptorSetCount * ( sizeof( UniqueHandle ) - sizeof( DescriptorSet ) ) ); - Result result = static_cast(d.vkAllocateDescriptorSets( m_device, reinterpret_cast( &allocateInfo ), reinterpret_cast( buffer ) ) ); + std::vector, Allocator> uniqueDescriptorSets( vectorAllocator ); + std::vector descriptorSets( allocateInfo.descriptorSetCount ); + Result result = static_cast( d.vkAllocateDescriptorSets( m_device, reinterpret_cast( &allocateInfo ), reinterpret_cast(descriptorSets.data()) ) ); if ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) { + uniqueDescriptorSets.reserve( allocateInfo.descriptorSetCount ); PoolFree deleter( *this, allocateInfo.descriptorPool, d ); for ( size_t i=0 ; i( buffer[i], deleter ) ); + uniqueDescriptorSets.push_back( UniqueHandle( descriptorSets[i], deleter ) ); } } - return createResultValue( result, descriptorSets, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateDescriptorSetsUnique" ); + return createResultValue( result, uniqueDescriptorSets, VULKAN_HPP_NAMESPACE_STRING "::Device::allocateDescriptorSetsUnique" ); } #endif /*VULKAN_HPP_NO_SMART_HANDLE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ @@ -69331,40 +69327,38 @@ namespace VULKAN_HPP_NAMESPACE template VULKAN_HPP_INLINE ResultValue,Allocator>> Device::createComputePipelinesUnique( VULKAN_HPP_NAMESPACE::PipelineCache pipelineCache, ArrayProxy createInfos, Optional allocator, Dispatch const &d ) const { - static_assert( sizeof( Pipeline ) <= sizeof( UniqueHandle ), "Pipeline is greater than UniqueHandle!" ); - std::vector, Allocator> pipelines; - pipelines.reserve( createInfos.size() ); - Pipeline* buffer = reinterpret_cast( reinterpret_cast( pipelines.data() ) + createInfos.size() * ( sizeof( UniqueHandle ) - sizeof( Pipeline ) ) ); - Result result = static_cast(d.vkCreateComputePipelines( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast( buffer ) ) ); + std::vector, Allocator> uniquePipelines; + std::vector pipelines( createInfos.size() ); + Result result = static_cast( d.vkCreateComputePipelines( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast(pipelines.data()) ) ); if ( ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) || ( result == VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT ) ) { + uniquePipelines.reserve( createInfos.size() ); ObjectDestroy deleter( *this, allocator, d ); for ( size_t i=0 ; i( buffer[i], deleter ) ); + uniquePipelines.push_back( UniqueHandle( pipelines[i], deleter ) ); } } - return createResultValue( result, pipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createComputePipelinesUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); + return createResultValue( result, uniquePipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createComputePipelinesUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); } template VULKAN_HPP_INLINE ResultValue,Allocator>> Device::createComputePipelinesUnique( VULKAN_HPP_NAMESPACE::PipelineCache pipelineCache, ArrayProxy createInfos, Optional allocator, Allocator const& vectorAllocator, Dispatch const &d ) const { - static_assert( sizeof( Pipeline ) <= sizeof( UniqueHandle ), "Pipeline is greater than UniqueHandle!" ); - std::vector, Allocator> pipelines( vectorAllocator ); - pipelines.reserve( createInfos.size() ); - Pipeline* buffer = reinterpret_cast( reinterpret_cast( pipelines.data() ) + createInfos.size() * ( sizeof( UniqueHandle ) - sizeof( Pipeline ) ) ); - Result result = static_cast(d.vkCreateComputePipelines( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast( buffer ) ) ); + std::vector, Allocator> uniquePipelines( vectorAllocator ); + std::vector pipelines( createInfos.size() ); + Result result = static_cast( d.vkCreateComputePipelines( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast(pipelines.data()) ) ); if ( ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) || ( result == VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT ) ) { + uniquePipelines.reserve( createInfos.size() ); ObjectDestroy deleter( *this, allocator, d ); for ( size_t i=0 ; i( buffer[i], deleter ) ); + uniquePipelines.push_back( UniqueHandle( pipelines[i], deleter ) ); } } - return createResultValue( result, pipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createComputePipelinesUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); + return createResultValue( result, uniquePipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createComputePipelinesUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); } template VULKAN_HPP_INLINE ResultValue> Device::createComputePipelineUnique( VULKAN_HPP_NAMESPACE::PipelineCache pipelineCache, const ComputePipelineCreateInfo & createInfo, Optional allocator, Dispatch const &d ) const @@ -69619,40 +69613,38 @@ namespace VULKAN_HPP_NAMESPACE template VULKAN_HPP_INLINE ResultValue,Allocator>> Device::createGraphicsPipelinesUnique( VULKAN_HPP_NAMESPACE::PipelineCache pipelineCache, ArrayProxy createInfos, Optional allocator, Dispatch const &d ) const { - static_assert( sizeof( Pipeline ) <= sizeof( UniqueHandle ), "Pipeline is greater than UniqueHandle!" ); - std::vector, Allocator> pipelines; - pipelines.reserve( createInfos.size() ); - Pipeline* buffer = reinterpret_cast( reinterpret_cast( pipelines.data() ) + createInfos.size() * ( sizeof( UniqueHandle ) - sizeof( Pipeline ) ) ); - Result result = static_cast(d.vkCreateGraphicsPipelines( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast( buffer ) ) ); + std::vector, Allocator> uniquePipelines; + std::vector pipelines( createInfos.size() ); + Result result = static_cast( d.vkCreateGraphicsPipelines( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast(pipelines.data()) ) ); if ( ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) || ( result == VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT ) ) { + uniquePipelines.reserve( createInfos.size() ); ObjectDestroy deleter( *this, allocator, d ); for ( size_t i=0 ; i( buffer[i], deleter ) ); + uniquePipelines.push_back( UniqueHandle( pipelines[i], deleter ) ); } } - return createResultValue( result, pipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createGraphicsPipelinesUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); + return createResultValue( result, uniquePipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createGraphicsPipelinesUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); } template VULKAN_HPP_INLINE ResultValue,Allocator>> Device::createGraphicsPipelinesUnique( VULKAN_HPP_NAMESPACE::PipelineCache pipelineCache, ArrayProxy createInfos, Optional allocator, Allocator const& vectorAllocator, Dispatch const &d ) const { - static_assert( sizeof( Pipeline ) <= sizeof( UniqueHandle ), "Pipeline is greater than UniqueHandle!" ); - std::vector, Allocator> pipelines( vectorAllocator ); - pipelines.reserve( createInfos.size() ); - Pipeline* buffer = reinterpret_cast( reinterpret_cast( pipelines.data() ) + createInfos.size() * ( sizeof( UniqueHandle ) - sizeof( Pipeline ) ) ); - Result result = static_cast(d.vkCreateGraphicsPipelines( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast( buffer ) ) ); + std::vector, Allocator> uniquePipelines( vectorAllocator ); + std::vector pipelines( createInfos.size() ); + Result result = static_cast( d.vkCreateGraphicsPipelines( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast(pipelines.data()) ) ); if ( ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) || ( result == VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT ) ) { + uniquePipelines.reserve( createInfos.size() ); ObjectDestroy deleter( *this, allocator, d ); for ( size_t i=0 ; i( buffer[i], deleter ) ); + uniquePipelines.push_back( UniqueHandle( pipelines[i], deleter ) ); } } - return createResultValue( result, pipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createGraphicsPipelinesUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); + return createResultValue( result, uniquePipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createGraphicsPipelinesUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); } template VULKAN_HPP_INLINE ResultValue> Device::createGraphicsPipelineUnique( VULKAN_HPP_NAMESPACE::PipelineCache pipelineCache, const GraphicsPipelineCreateInfo & createInfo, Optional allocator, Dispatch const &d ) const @@ -69854,40 +69846,38 @@ namespace VULKAN_HPP_NAMESPACE template VULKAN_HPP_INLINE ResultValue,Allocator>> Device::createRayTracingPipelinesKHRUnique( VULKAN_HPP_NAMESPACE::PipelineCache pipelineCache, ArrayProxy createInfos, Optional allocator, Dispatch const &d ) const { - static_assert( sizeof( Pipeline ) <= sizeof( UniqueHandle ), "Pipeline is greater than UniqueHandle!" ); - std::vector, Allocator> pipelines; - pipelines.reserve( createInfos.size() ); - Pipeline* buffer = reinterpret_cast( reinterpret_cast( pipelines.data() ) + createInfos.size() * ( sizeof( UniqueHandle ) - sizeof( Pipeline ) ) ); - Result result = static_cast(d.vkCreateRayTracingPipelinesKHR( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast( buffer ) ) ); + std::vector, Allocator> uniquePipelines; + std::vector pipelines( createInfos.size() ); + Result result = static_cast( d.vkCreateRayTracingPipelinesKHR( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast(pipelines.data()) ) ); if ( ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) || ( result == VULKAN_HPP_NAMESPACE::Result::eOperationDeferredKHR ) || ( result == VULKAN_HPP_NAMESPACE::Result::eOperationNotDeferredKHR ) || ( result == VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT ) ) { + uniquePipelines.reserve( createInfos.size() ); ObjectDestroy deleter( *this, allocator, d ); for ( size_t i=0 ; i( buffer[i], deleter ) ); + uniquePipelines.push_back( UniqueHandle( pipelines[i], deleter ) ); } } - return createResultValue( result, pipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createRayTracingPipelinesKHRUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::eOperationDeferredKHR, VULKAN_HPP_NAMESPACE::Result::eOperationNotDeferredKHR, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); + return createResultValue( result, uniquePipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createRayTracingPipelinesKHRUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::eOperationDeferredKHR, VULKAN_HPP_NAMESPACE::Result::eOperationNotDeferredKHR, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); } template VULKAN_HPP_INLINE ResultValue,Allocator>> Device::createRayTracingPipelinesKHRUnique( VULKAN_HPP_NAMESPACE::PipelineCache pipelineCache, ArrayProxy createInfos, Optional allocator, Allocator const& vectorAllocator, Dispatch const &d ) const { - static_assert( sizeof( Pipeline ) <= sizeof( UniqueHandle ), "Pipeline is greater than UniqueHandle!" ); - std::vector, Allocator> pipelines( vectorAllocator ); - pipelines.reserve( createInfos.size() ); - Pipeline* buffer = reinterpret_cast( reinterpret_cast( pipelines.data() ) + createInfos.size() * ( sizeof( UniqueHandle ) - sizeof( Pipeline ) ) ); - Result result = static_cast(d.vkCreateRayTracingPipelinesKHR( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast( buffer ) ) ); + std::vector, Allocator> uniquePipelines( vectorAllocator ); + std::vector pipelines( createInfos.size() ); + Result result = static_cast( d.vkCreateRayTracingPipelinesKHR( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast(pipelines.data()) ) ); if ( ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) || ( result == VULKAN_HPP_NAMESPACE::Result::eOperationDeferredKHR ) || ( result == VULKAN_HPP_NAMESPACE::Result::eOperationNotDeferredKHR ) || ( result == VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT ) ) { + uniquePipelines.reserve( createInfos.size() ); ObjectDestroy deleter( *this, allocator, d ); for ( size_t i=0 ; i( buffer[i], deleter ) ); + uniquePipelines.push_back( UniqueHandle( pipelines[i], deleter ) ); } } - return createResultValue( result, pipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createRayTracingPipelinesKHRUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::eOperationDeferredKHR, VULKAN_HPP_NAMESPACE::Result::eOperationNotDeferredKHR, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); + return createResultValue( result, uniquePipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createRayTracingPipelinesKHRUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::eOperationDeferredKHR, VULKAN_HPP_NAMESPACE::Result::eOperationNotDeferredKHR, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); } template VULKAN_HPP_INLINE ResultValue> Device::createRayTracingPipelineKHRUnique( VULKAN_HPP_NAMESPACE::PipelineCache pipelineCache, const RayTracingPipelineCreateInfoKHR & createInfo, Optional allocator, Dispatch const &d ) const @@ -69933,40 +69923,38 @@ namespace VULKAN_HPP_NAMESPACE template VULKAN_HPP_INLINE ResultValue,Allocator>> Device::createRayTracingPipelinesNVUnique( VULKAN_HPP_NAMESPACE::PipelineCache pipelineCache, ArrayProxy createInfos, Optional allocator, Dispatch const &d ) const { - static_assert( sizeof( Pipeline ) <= sizeof( UniqueHandle ), "Pipeline is greater than UniqueHandle!" ); - std::vector, Allocator> pipelines; - pipelines.reserve( createInfos.size() ); - Pipeline* buffer = reinterpret_cast( reinterpret_cast( pipelines.data() ) + createInfos.size() * ( sizeof( UniqueHandle ) - sizeof( Pipeline ) ) ); - Result result = static_cast(d.vkCreateRayTracingPipelinesNV( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast( buffer ) ) ); + std::vector, Allocator> uniquePipelines; + std::vector pipelines( createInfos.size() ); + Result result = static_cast( d.vkCreateRayTracingPipelinesNV( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast(pipelines.data()) ) ); if ( ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) || ( result == VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT ) ) { + uniquePipelines.reserve( createInfos.size() ); ObjectDestroy deleter( *this, allocator, d ); for ( size_t i=0 ; i( buffer[i], deleter ) ); + uniquePipelines.push_back( UniqueHandle( pipelines[i], deleter ) ); } } - return createResultValue( result, pipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createRayTracingPipelinesNVUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); + return createResultValue( result, uniquePipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createRayTracingPipelinesNVUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); } template VULKAN_HPP_INLINE ResultValue,Allocator>> Device::createRayTracingPipelinesNVUnique( VULKAN_HPP_NAMESPACE::PipelineCache pipelineCache, ArrayProxy createInfos, Optional allocator, Allocator const& vectorAllocator, Dispatch const &d ) const { - static_assert( sizeof( Pipeline ) <= sizeof( UniqueHandle ), "Pipeline is greater than UniqueHandle!" ); - std::vector, Allocator> pipelines( vectorAllocator ); - pipelines.reserve( createInfos.size() ); - Pipeline* buffer = reinterpret_cast( reinterpret_cast( pipelines.data() ) + createInfos.size() * ( sizeof( UniqueHandle ) - sizeof( Pipeline ) ) ); - Result result = static_cast(d.vkCreateRayTracingPipelinesNV( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast( buffer ) ) ); + std::vector, Allocator> uniquePipelines( vectorAllocator ); + std::vector pipelines( createInfos.size() ); + Result result = static_cast( d.vkCreateRayTracingPipelinesNV( m_device, static_cast( pipelineCache ), createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast(pipelines.data()) ) ); if ( ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) || ( result == VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT ) ) { + uniquePipelines.reserve( createInfos.size() ); ObjectDestroy deleter( *this, allocator, d ); for ( size_t i=0 ; i( buffer[i], deleter ) ); + uniquePipelines.push_back( UniqueHandle( pipelines[i], deleter ) ); } } - return createResultValue( result, pipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createRayTracingPipelinesNVUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); + return createResultValue( result, uniquePipelines, VULKAN_HPP_NAMESPACE_STRING "::Device::createRayTracingPipelinesNVUnique", { VULKAN_HPP_NAMESPACE::Result::eSuccess, VULKAN_HPP_NAMESPACE::Result::ePipelineCompileRequiredEXT } ); } template VULKAN_HPP_INLINE ResultValue> Device::createRayTracingPipelineNVUnique( VULKAN_HPP_NAMESPACE::PipelineCache pipelineCache, const RayTracingPipelineCreateInfoNV & createInfo, Optional allocator, Dispatch const &d ) const @@ -70219,40 +70207,38 @@ namespace VULKAN_HPP_NAMESPACE template VULKAN_HPP_INLINE typename ResultValueType,Allocator>>::type Device::createSharedSwapchainsKHRUnique( ArrayProxy createInfos, Optional allocator, Dispatch const &d ) const { - static_assert( sizeof( SwapchainKHR ) <= sizeof( UniqueHandle ), "SwapchainKHR is greater than UniqueHandle!" ); - std::vector, Allocator> swapchainKHRs; - swapchainKHRs.reserve( createInfos.size() ); - SwapchainKHR* buffer = reinterpret_cast( reinterpret_cast( swapchainKHRs.data() ) + createInfos.size() * ( sizeof( UniqueHandle ) - sizeof( SwapchainKHR ) ) ); - Result result = static_cast(d.vkCreateSharedSwapchainsKHR( m_device, createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast( buffer ) ) ); + std::vector, Allocator> uniqueSwapchainKHRs; + std::vector swapchainKHRs( createInfos.size() ); + Result result = static_cast( d.vkCreateSharedSwapchainsKHR( m_device, createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast(swapchainKHRs.data()) ) ); if ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) { + uniqueSwapchainKHRs.reserve( createInfos.size() ); ObjectDestroy deleter( *this, allocator, d ); for ( size_t i=0 ; i( buffer[i], deleter ) ); + uniqueSwapchainKHRs.push_back( UniqueHandle( swapchainKHRs[i], deleter ) ); } } - return createResultValue( result, swapchainKHRs, VULKAN_HPP_NAMESPACE_STRING "::Device::createSharedSwapchainsKHRUnique" ); + return createResultValue( result, uniqueSwapchainKHRs, VULKAN_HPP_NAMESPACE_STRING "::Device::createSharedSwapchainsKHRUnique" ); } template VULKAN_HPP_INLINE typename ResultValueType,Allocator>>::type Device::createSharedSwapchainsKHRUnique( ArrayProxy createInfos, Optional allocator, Allocator const& vectorAllocator, Dispatch const &d ) const { - static_assert( sizeof( SwapchainKHR ) <= sizeof( UniqueHandle ), "SwapchainKHR is greater than UniqueHandle!" ); - std::vector, Allocator> swapchainKHRs( vectorAllocator ); - swapchainKHRs.reserve( createInfos.size() ); - SwapchainKHR* buffer = reinterpret_cast( reinterpret_cast( swapchainKHRs.data() ) + createInfos.size() * ( sizeof( UniqueHandle ) - sizeof( SwapchainKHR ) ) ); - Result result = static_cast(d.vkCreateSharedSwapchainsKHR( m_device, createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast( buffer ) ) ); + std::vector, Allocator> uniqueSwapchainKHRs( vectorAllocator ); + std::vector swapchainKHRs( createInfos.size() ); + Result result = static_cast( d.vkCreateSharedSwapchainsKHR( m_device, createInfos.size() , reinterpret_cast( createInfos.data() ), reinterpret_cast( static_cast( allocator ) ), reinterpret_cast(swapchainKHRs.data()) ) ); if ( result == VULKAN_HPP_NAMESPACE::Result::eSuccess ) { + uniqueSwapchainKHRs.reserve( createInfos.size() ); ObjectDestroy deleter( *this, allocator, d ); for ( size_t i=0 ; i( buffer[i], deleter ) ); + uniqueSwapchainKHRs.push_back( UniqueHandle( swapchainKHRs[i], deleter ) ); } } - return createResultValue( result, swapchainKHRs, VULKAN_HPP_NAMESPACE_STRING "::Device::createSharedSwapchainsKHRUnique" ); + return createResultValue( result, uniqueSwapchainKHRs, VULKAN_HPP_NAMESPACE_STRING "::Device::createSharedSwapchainsKHRUnique" ); } template VULKAN_HPP_INLINE typename ResultValueType>::type Device::createSharedSwapchainKHRUnique( const SwapchainCreateInfoKHR & createInfo, Optional allocator, Dispatch const &d ) const