Correct usage of Allocator in functions returning a vector of UniqueObjects (#178)

This commit is contained in:
Andreas Süßenbach 2018-02-01 14:45:30 +01:00 committed by Markus Tavenrath
parent 4b77709e49
commit 75cb7d14f1
3 changed files with 185 additions and 144 deletions

View File

@ -541,7 +541,7 @@ const std::string createResultValueHeader = R"(
{ {
throwResultException( result, message ); throwResultException( result, message );
} }
return data; return std::move( data );
#endif #endif
} }
@ -2741,6 +2741,46 @@ void VulkanHppGenerator::sortDependencies()
m_dependencies.swap(sortedDependencies); m_dependencies.swap(sortedDependencies);
} }
void VulkanHppGenerator::writeArguments(std::ostream & os, CommandData const& commandData, bool firstCall, bool singular, size_t from, size_t to)
{
assert(from <= to);
// get the parameter indices of the counter for vector parameters
std::map<size_t, size_t> countIndices;
for (std::map<size_t, size_t>::const_iterator it = commandData.vectorParams.begin(); it != commandData.vectorParams.end(); ++it)
{
countIndices.insert(std::make_pair(it->second, it->first));
}
bool encounteredArgument = false;
for (size_t i = from; i < to; i++)
{
if (encounteredArgument)
{
os << ", ";
}
std::map<size_t, size_t>::const_iterator it = countIndices.find(i);
if (it != countIndices.end())
{
writeCallCountParameter(os, commandData, singular, it);
}
else if ((it = commandData.vectorParams.find(i)) != commandData.vectorParams.end())
{
writeCallVectorParameter(os, commandData, firstCall, singular, it);
}
else if (m_vkTypes.find(commandData.params[i].pureType) != m_vkTypes.end())
{
writeCallVulkanTypeParameter(os, commandData.params[i]);
}
else
{
writeCallPlainTypeParameter(os, commandData.params[i]);
}
encounteredArgument = true;
}
}
void VulkanHppGenerator::writeBitmaskToString(std::ostream & os, std::string const& bitmaskName, EnumData const &enumData) void VulkanHppGenerator::writeBitmaskToString(std::ostream & os, std::string const& bitmaskName, EnumData const &enumData)
{ {
// the helper functions to make strings out of flag values // the helper functions to make strings out of flag values
@ -2772,13 +2812,6 @@ void VulkanHppGenerator::writeBitmaskToString(std::ostream & os, std::string con
void VulkanHppGenerator::writeCall(std::ostream & os, CommandData const& commandData, bool firstCall, bool singular) void VulkanHppGenerator::writeCall(std::ostream & os, CommandData const& commandData, bool firstCall, bool singular)
{ {
// get the parameter indices of the counter for vector parameters
std::map<size_t, size_t> countIndices;
for (std::map<size_t, size_t>::const_iterator it = commandData.vectorParams.begin(); it != commandData.vectorParams.end(); ++it)
{
countIndices.insert(std::make_pair(it->second, it->first));
}
// the original function call // the original function call
os << "d.vk" << startUpperCase(commandData.fullName) << "( "; os << "d.vk" << startUpperCase(commandData.fullName) << "( ";
@ -2786,33 +2819,13 @@ void VulkanHppGenerator::writeCall(std::ostream & os, CommandData const& command
{ {
// if it's member of a class -> add the first parameter with "m_" as prefix // if it's member of a class -> add the first parameter with "m_" as prefix
os << "m_" << commandData.params[0].name; os << "m_" << commandData.params[0].name;
} if (1 < commandData.params.size())
for (size_t i = commandData.className.empty() ? 0 : 1; i < commandData.params.size(); i++)
{
if (0 < i)
{ {
os << ", "; os << ", ";
} }
}
std::map<size_t, size_t>::const_iterator it = countIndices.find(i); writeArguments(os, commandData, firstCall, singular, commandData.className.empty() ? 0 : 1, commandData.params.size());
if (it != countIndices.end())
{
writeCallCountParameter(os, commandData, singular, it);
}
else if ((it = commandData.vectorParams.find(i)) != commandData.vectorParams.end())
{
writeCallVectorParameter(os, commandData, firstCall, singular, it);
}
else if (m_vkTypes.find(commandData.params[i].pureType) != m_vkTypes.end())
{
writeCallVulkanTypeParameter(os, commandData.params[i]);
}
else
{
writeCallPlainTypeParameter(os, commandData.params[i]);
}
}
os << " )"; os << " )";
} }
@ -3204,7 +3217,7 @@ void VulkanHppGenerator::writeExceptionsForEnum(std::ostream & os, EnumData cons
void VulkanHppGenerator::writeFunction(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool definition, bool enhanced, bool singular, bool unique, bool isStructureChain) void VulkanHppGenerator::writeFunction(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool definition, bool enhanced, bool singular, bool unique, bool isStructureChain)
{ {
writeFunctionHeaderTemplate(os, indentation, commandData, enhanced, !definition, isStructureChain); writeFunctionHeaderTemplate(os, indentation, commandData, enhanced, unique, !definition, isStructureChain);
os << indentation << (definition ? "VULKAN_HPP_INLINE " : ""); os << indentation << (definition ? "VULKAN_HPP_INLINE " : "");
writeFunctionHeaderReturnType(os, indentation, commandData, enhanced, singular, unique, isStructureChain); writeFunctionHeaderReturnType(os, indentation, commandData, enhanced, singular, unique, isStructureChain);
@ -3233,6 +3246,48 @@ void VulkanHppGenerator::writeFunction(std::ostream & os, std::string const& ind
} }
void VulkanHppGenerator::writeFunctionBodyEnhanced(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool singular, bool unique, bool isStructureChain) void VulkanHppGenerator::writeFunctionBodyEnhanced(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool singular, bool unique, bool isStructureChain)
{
if (unique && !singular && (commandData.vectorParams.find(commandData.returnParam) != commandData.vectorParams.end())) // returns a vector of UniqueStuff
{
std::string const stringTemplate =
R"(${i} static_assert( sizeof( ${type} ) <= sizeof( Unique${type} ), "${type} is greater than Unique${type}!" );
${i} std::vector<Unique${type}, Allocator> ${typeVariable}s;
${i} ${typeVariable}s.reserve( ${vectorSize} );
${i} ${type}* buffer = reinterpret_cast<${type}*>( reinterpret_cast<char*>( ${typeVariable}s.data() ) + ${vectorSize} * ( sizeof( Unique${type} ) - sizeof( ${type} ) ) );
${i} Result result = static_cast<Result>(d.vk${command}( m_device, ${arguments}, reinterpret_cast<Vk${type}*>( buffer ) ) );
${i} ${type}Deleter deleter( *this, ${deleterArg} );
${i} for ( size_t i=0 ; i<${vectorSize} ; i++ )
${i} {
${i} ${typeVariable}s.push_back( Unique${type}( buffer[i], deleter ) );
${i} }
${i} return createResultValue( result, ${typeVariable}s, "VULKAN_HPP_NAMESPACE::${class}::${function}Unique" );
)";
std::string type = (commandData.returnParam != ~0) ? commandData.params[commandData.returnParam].pureType : "";
std::string typeVariable = startLowerCase(type);
std::ostringstream arguments;
writeArguments(arguments, commandData, true, singular, 1, commandData.params.size() - 1);
std::map<std::string, DeleterData>::const_iterator ddit = m_deleters.find(type);
assert(ddit != m_deleters.end());
bool isCreateFunction = (commandData.fullName.substr(0, 6) == "create");
os << replaceWithMap(stringTemplate, std::map<std::string, std::string>
{
{ "i", indentation },
{ "type", type },
{ "typeVariable", typeVariable },
{ "vectorSize", isCreateFunction ? "createInfos.size()" : "allocateInfo." + typeVariable + "Count" },
{ "command", startUpperCase(commandData.fullName) },
{ "arguments", arguments.str() },
{ "deleterArg", ddit->second.pool.empty() ? "allocator" : "allocateInfo." + startLowerCase(ddit->second.pool) },
{ "class", commandData.className },
{ "function", commandData.reducedName }
});
}
else
{ {
if (1 < commandData.vectorParams.size()) if (1 < commandData.vectorParams.size())
{ {
@ -3293,6 +3348,7 @@ void VulkanHppGenerator::writeFunctionBodyEnhanced(std::ostream & os, std::strin
os << indentation << " return " << returnName << ";" << std::endl; os << indentation << " return " << returnName << ";" << std::endl;
} }
} }
}
void VulkanHppGenerator::writeFunctionBodyEnhanced(std::ostream &os, std::string const& templateString, std::string const& indentation, CommandData const& commandData, bool singular) void VulkanHppGenerator::writeFunctionBodyEnhanced(std::ostream &os, std::string const& templateString, std::string const& indentation, CommandData const& commandData, bool singular)
{ {
@ -3539,33 +3595,12 @@ void VulkanHppGenerator::writeFunctionBodyEnhancedReturnResultValue(std::ostream
os << " );" << std::endl; os << " );" << std::endl;
} }
bool returnUniqueVector = unique && !singular && (commandData.vectorParams.find(commandData.returnParam) != commandData.vectorParams.end());
if (returnUniqueVector)
{
std::string const stringTemplate =
R"(${i} std::vector<Unique${type}> unique${returnVectorName}s;
${i} unique${returnVectorName}s.reserve( ${localName}s.size() );
${i} for ( auto const& ${localName} : ${localName}s )
${i} {
${i} unique${returnVectorName}s.push_back( Unique${type}( ${localName}, deleter ) );
${i} }
)";
os << replaceWithMap(stringTemplate, std::map<std::string, std::string>{
{ "i", indentation },
{ "type", type },
{ "returnVectorName", returnVectorName },
{ "localName", startLowerCase(returnVectorName) }
});
}
// if the return type is "Result" or there is at least one success code, create the Result/Value construct to return // if the return type is "Result" or there is at least one success code, create the Result/Value construct to return
os << indentation << " return createResultValue( result, "; os << indentation << " return createResultValue( result, ";
if (commandData.returnParam != ~0) if (commandData.returnParam != ~0)
{ {
// if there's a return parameter, list it in the Result/Value constructor // if there's a return parameter, list it in the Result/Value constructor
os << (returnUniqueVector ? "unique" + returnVectorName + "s" : returnName) << ", "; os << returnName << ", ";
} }
// now the function name (with full namespace) as a string // now the function name (with full namespace) as a string
@ -3582,7 +3617,7 @@ ${i} }
os << " }"; os << " }";
} }
if (unique && !returnUniqueVector) if (unique)
{ {
os << ", deleter"; os << ", deleter";
} }
@ -3934,7 +3969,7 @@ void VulkanHppGenerator::writeFunctionHeaderReturnType(std::ostream & os, std::s
os << replaceWithMap(templateString, { { "returnType", returnType } }); os << replaceWithMap(templateString, { { "returnType", returnType } });
} }
void VulkanHppGenerator::writeFunctionHeaderTemplate(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool enhanced, bool withDefault, bool isStructureChain) void VulkanHppGenerator::writeFunctionHeaderTemplate(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool enhanced, bool unique, bool withDefault, bool isStructureChain)
{ {
std::string dispatch = withDefault ? std::string("typename Dispatch = DispatchLoaderStatic") : std::string("typename Dispatch"); std::string dispatch = withDefault ? std::string("typename Dispatch = DispatchLoaderStatic") : std::string("typename Dispatch");
if (enhanced && isStructureChain) if (enhanced && isStructureChain)
@ -3955,7 +3990,7 @@ void VulkanHppGenerator::writeFunctionHeaderTemplate(std::ostream & os, std::str
if (withDefault) if (withDefault)
{ {
// for the default type get the type from the enhancedReturnType, which is of the form 'std::vector<Type,Allocator>' // for the default type get the type from the enhancedReturnType, which is of the form 'std::vector<Type,Allocator>'
os << " = std::allocator<" << commandData.enhancedReturnType.substr(12, commandData.enhancedReturnType.find(',') - 12) << ">"; os << " = std::allocator<" << (unique ? "Unique" : "") << commandData.enhancedReturnType.substr(12, commandData.enhancedReturnType.find(',') - 12) << ">";
} }
os << ", " << dispatch; os << ", " << dispatch;
os << "> " << std::endl; os << "> " << std::endl;

View File

@ -238,6 +238,7 @@ class VulkanHppGenerator
void readTypeStructMember(tinyxml2::XMLElement const* element, StructData & structData); void readTypeStructMember(tinyxml2::XMLElement const* element, StructData & structData);
void registerDeleter(CommandData const& commandData); void registerDeleter(CommandData const& commandData);
void setDefault(std::string const& name, std::map<std::string, std::string> & defaultValues, EnumData const& enumData); void setDefault(std::string const& name, std::map<std::string, std::string> & defaultValues, EnumData const& enumData);
void writeArguments(std::ostream & os, CommandData const& commandData, bool firstCall, bool singular, size_t from, size_t to);
void writeBitmaskToString(std::ostream & os, std::string const& flagsName, EnumData const &enumData); void writeBitmaskToString(std::ostream & os, std::string const& flagsName, EnumData const &enumData);
void writeCall(std::ostream & os, CommandData const& commandData, bool firstCall, bool singular); void writeCall(std::ostream & os, CommandData const& commandData, bool firstCall, bool singular);
void writeCallCountParameter(std::ostream & os, CommandData const& commandData, bool singular, std::map<size_t, size_t>::const_iterator it); void writeCallCountParameter(std::ostream & os, CommandData const& commandData, bool singular, std::map<size_t, size_t>::const_iterator it);
@ -266,7 +267,7 @@ class VulkanHppGenerator
void writeFunctionHeaderArgumentsEnhanced(std::ostream & os, CommandData const& commandData, bool singular, bool withDefaults); void writeFunctionHeaderArgumentsEnhanced(std::ostream & os, CommandData const& commandData, bool singular, bool withDefaults);
void writeFunctionHeaderArgumentsStandard(std::ostream & os, CommandData const& commandData, bool withDefaults); void writeFunctionHeaderArgumentsStandard(std::ostream & os, CommandData const& commandData, bool withDefaults);
void writeFunctionHeaderReturnType(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool enhanced, bool singular, bool unique, bool isStructureChain); void writeFunctionHeaderReturnType(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool enhanced, bool singular, bool unique, bool isStructureChain);
void writeFunctionHeaderTemplate(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool enhanced, bool withDefault, bool isStructureChain); void writeFunctionHeaderTemplate(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool enhanced, bool unique, bool withDefault, bool isStructureChain);
void writeStructConstructor(std::ostream & os, std::string const& name, StructData const& structData, std::map<std::string, std::string> const& defaultValues); void writeStructConstructor(std::ostream & os, std::string const& name, StructData const& structData, std::map<std::string, std::string> const& defaultValues);
void writeStructSetter(std::ostream & os, std::string const& structureName, MemberData const& memberData); void writeStructSetter(std::ostream & os, std::string const& structureName, MemberData const& memberData);
void writeStructureChainValidation(std::ostream & os, DependencyData const& dependencyData); void writeStructureChainValidation(std::ostream & os, DependencyData const& dependencyData);

View File

@ -924,7 +924,7 @@ namespace VULKAN_HPP_NAMESPACE
{ {
throwResultException( result, message ); throwResultException( result, message );
} }
return data; return std::move( data );
#endif #endif
} }
@ -28699,9 +28699,9 @@ public:
template <typename Allocator = std::allocator<Pipeline>, typename Dispatch = DispatchLoaderStatic> template <typename Allocator = std::allocator<Pipeline>, typename Dispatch = DispatchLoaderStatic>
ResultValueType<Pipeline>::type createGraphicsPipeline( PipelineCache pipelineCache, const GraphicsPipelineCreateInfo & createInfo, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const; ResultValueType<Pipeline>::type createGraphicsPipeline( PipelineCache pipelineCache, const GraphicsPipelineCreateInfo & createInfo, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const;
#ifndef VULKAN_HPP_NO_SMART_HANDLE #ifndef VULKAN_HPP_NO_SMART_HANDLE
template <typename Allocator = std::allocator<Pipeline>, typename Dispatch = DispatchLoaderStatic> template <typename Allocator = std::allocator<UniquePipeline>, typename Dispatch = DispatchLoaderStatic>
typename ResultValueType<std::vector<UniquePipeline,Allocator>>::type createGraphicsPipelinesUnique( PipelineCache pipelineCache, ArrayProxy<const GraphicsPipelineCreateInfo> createInfos, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const; typename ResultValueType<std::vector<UniquePipeline,Allocator>>::type createGraphicsPipelinesUnique( PipelineCache pipelineCache, ArrayProxy<const GraphicsPipelineCreateInfo> createInfos, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const;
template <typename Allocator = std::allocator<Pipeline>, typename Dispatch = DispatchLoaderStatic> template <typename Allocator = std::allocator<UniquePipeline>, typename Dispatch = DispatchLoaderStatic>
ResultValueType<UniquePipeline>::type createGraphicsPipelineUnique( PipelineCache pipelineCache, const GraphicsPipelineCreateInfo & createInfo, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const; ResultValueType<UniquePipeline>::type createGraphicsPipelineUnique( PipelineCache pipelineCache, const GraphicsPipelineCreateInfo & createInfo, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const;
#endif /*VULKAN_HPP_NO_SMART_HANDLE*/ #endif /*VULKAN_HPP_NO_SMART_HANDLE*/
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -28714,9 +28714,9 @@ public:
template <typename Allocator = std::allocator<Pipeline>, typename Dispatch = DispatchLoaderStatic> template <typename Allocator = std::allocator<Pipeline>, typename Dispatch = DispatchLoaderStatic>
ResultValueType<Pipeline>::type createComputePipeline( PipelineCache pipelineCache, const ComputePipelineCreateInfo & createInfo, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const; ResultValueType<Pipeline>::type createComputePipeline( PipelineCache pipelineCache, const ComputePipelineCreateInfo & createInfo, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const;
#ifndef VULKAN_HPP_NO_SMART_HANDLE #ifndef VULKAN_HPP_NO_SMART_HANDLE
template <typename Allocator = std::allocator<Pipeline>, typename Dispatch = DispatchLoaderStatic> template <typename Allocator = std::allocator<UniquePipeline>, typename Dispatch = DispatchLoaderStatic>
typename ResultValueType<std::vector<UniquePipeline,Allocator>>::type createComputePipelinesUnique( PipelineCache pipelineCache, ArrayProxy<const ComputePipelineCreateInfo> createInfos, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const; typename ResultValueType<std::vector<UniquePipeline,Allocator>>::type createComputePipelinesUnique( PipelineCache pipelineCache, ArrayProxy<const ComputePipelineCreateInfo> createInfos, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const;
template <typename Allocator = std::allocator<Pipeline>, typename Dispatch = DispatchLoaderStatic> template <typename Allocator = std::allocator<UniquePipeline>, typename Dispatch = DispatchLoaderStatic>
ResultValueType<UniquePipeline>::type createComputePipelineUnique( PipelineCache pipelineCache, const ComputePipelineCreateInfo & createInfo, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const; ResultValueType<UniquePipeline>::type createComputePipelineUnique( PipelineCache pipelineCache, const ComputePipelineCreateInfo & createInfo, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const;
#endif /*VULKAN_HPP_NO_SMART_HANDLE*/ #endif /*VULKAN_HPP_NO_SMART_HANDLE*/
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -28814,7 +28814,7 @@ public:
template <typename Allocator = std::allocator<DescriptorSet>, typename Dispatch = DispatchLoaderStatic> template <typename Allocator = std::allocator<DescriptorSet>, typename Dispatch = DispatchLoaderStatic>
typename ResultValueType<std::vector<DescriptorSet,Allocator>>::type allocateDescriptorSets( const DescriptorSetAllocateInfo & allocateInfo, Dispatch const &d = Dispatch() ) const; typename ResultValueType<std::vector<DescriptorSet,Allocator>>::type allocateDescriptorSets( const DescriptorSetAllocateInfo & allocateInfo, Dispatch const &d = Dispatch() ) const;
#ifndef VULKAN_HPP_NO_SMART_HANDLE #ifndef VULKAN_HPP_NO_SMART_HANDLE
template <typename Allocator = std::allocator<DescriptorSet>, typename Dispatch = DispatchLoaderStatic> template <typename Allocator = std::allocator<UniqueDescriptorSet>, typename Dispatch = DispatchLoaderStatic>
typename ResultValueType<std::vector<UniqueDescriptorSet,Allocator>>::type allocateDescriptorSetsUnique( const DescriptorSetAllocateInfo & allocateInfo, Dispatch const &d = Dispatch() ) const; typename ResultValueType<std::vector<UniqueDescriptorSet,Allocator>>::type allocateDescriptorSetsUnique( const DescriptorSetAllocateInfo & allocateInfo, Dispatch const &d = Dispatch() ) const;
#endif /*VULKAN_HPP_NO_SMART_HANDLE*/ #endif /*VULKAN_HPP_NO_SMART_HANDLE*/
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -28908,7 +28908,7 @@ public:
template <typename Allocator = std::allocator<CommandBuffer>, typename Dispatch = DispatchLoaderStatic> template <typename Allocator = std::allocator<CommandBuffer>, typename Dispatch = DispatchLoaderStatic>
typename ResultValueType<std::vector<CommandBuffer,Allocator>>::type allocateCommandBuffers( const CommandBufferAllocateInfo & allocateInfo, Dispatch const &d = Dispatch() ) const; typename ResultValueType<std::vector<CommandBuffer,Allocator>>::type allocateCommandBuffers( const CommandBufferAllocateInfo & allocateInfo, Dispatch const &d = Dispatch() ) const;
#ifndef VULKAN_HPP_NO_SMART_HANDLE #ifndef VULKAN_HPP_NO_SMART_HANDLE
template <typename Allocator = std::allocator<CommandBuffer>, typename Dispatch = DispatchLoaderStatic> template <typename Allocator = std::allocator<UniqueCommandBuffer>, typename Dispatch = DispatchLoaderStatic>
typename ResultValueType<std::vector<UniqueCommandBuffer,Allocator>>::type allocateCommandBuffersUnique( const CommandBufferAllocateInfo & allocateInfo, Dispatch const &d = Dispatch() ) const; typename ResultValueType<std::vector<UniqueCommandBuffer,Allocator>>::type allocateCommandBuffersUnique( const CommandBufferAllocateInfo & allocateInfo, Dispatch const &d = Dispatch() ) const;
#endif /*VULKAN_HPP_NO_SMART_HANDLE*/ #endif /*VULKAN_HPP_NO_SMART_HANDLE*/
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -28928,9 +28928,9 @@ public:
template <typename Allocator = std::allocator<SwapchainKHR>, typename Dispatch = DispatchLoaderStatic> template <typename Allocator = std::allocator<SwapchainKHR>, typename Dispatch = DispatchLoaderStatic>
ResultValueType<SwapchainKHR>::type createSharedSwapchainKHR( const SwapchainCreateInfoKHR & createInfo, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const; ResultValueType<SwapchainKHR>::type createSharedSwapchainKHR( const SwapchainCreateInfoKHR & createInfo, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const;
#ifndef VULKAN_HPP_NO_SMART_HANDLE #ifndef VULKAN_HPP_NO_SMART_HANDLE
template <typename Allocator = std::allocator<SwapchainKHR>, typename Dispatch = DispatchLoaderStatic> template <typename Allocator = std::allocator<UniqueSwapchainKHR>, typename Dispatch = DispatchLoaderStatic>
typename ResultValueType<std::vector<UniqueSwapchainKHR,Allocator>>::type createSharedSwapchainsKHRUnique( ArrayProxy<const SwapchainCreateInfoKHR> createInfos, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const; typename ResultValueType<std::vector<UniqueSwapchainKHR,Allocator>>::type createSharedSwapchainsKHRUnique( ArrayProxy<const SwapchainCreateInfoKHR> createInfos, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const;
template <typename Allocator = std::allocator<SwapchainKHR>, typename Dispatch = DispatchLoaderStatic> template <typename Allocator = std::allocator<UniqueSwapchainKHR>, typename Dispatch = DispatchLoaderStatic>
ResultValueType<UniqueSwapchainKHR>::type createSharedSwapchainKHRUnique( const SwapchainCreateInfoKHR & createInfo, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const; ResultValueType<UniqueSwapchainKHR>::type createSharedSwapchainKHRUnique( const SwapchainCreateInfoKHR & createInfo, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const;
#endif /*VULKAN_HPP_NO_SMART_HANDLE*/ #endif /*VULKAN_HPP_NO_SMART_HANDLE*/
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -30779,18 +30779,19 @@ public:
template <typename Allocator, typename Dispatch> template <typename Allocator, typename Dispatch>
VULKAN_HPP_INLINE typename ResultValueType<std::vector<UniquePipeline,Allocator>>::type Device::createGraphicsPipelinesUnique( PipelineCache pipelineCache, ArrayProxy<const GraphicsPipelineCreateInfo> createInfos, Optional<const AllocationCallbacks> allocator, Dispatch const &d ) const VULKAN_HPP_INLINE typename ResultValueType<std::vector<UniquePipeline,Allocator>>::type Device::createGraphicsPipelinesUnique( PipelineCache pipelineCache, ArrayProxy<const GraphicsPipelineCreateInfo> createInfos, Optional<const AllocationCallbacks> allocator, Dispatch const &d ) const
{ {
std::vector<Pipeline,Allocator> pipelines( createInfos.size() ); static_assert( sizeof( Pipeline ) <= sizeof( UniquePipeline ), "Pipeline is greater than UniquePipeline!" );
Result result = static_cast<Result>( d.vkCreateGraphicsPipelines( m_device, static_cast<VkPipelineCache>( pipelineCache ), createInfos.size() , reinterpret_cast<const VkGraphicsPipelineCreateInfo*>( createInfos.data() ), reinterpret_cast<const VkAllocationCallbacks*>( static_cast<const AllocationCallbacks*>( allocator ) ), reinterpret_cast<VkPipeline*>( pipelines.data() ) ) ); std::vector<UniquePipeline, Allocator> pipelines;
pipelines.reserve( createInfos.size() );
Pipeline* buffer = reinterpret_cast<Pipeline*>( reinterpret_cast<char*>( pipelines.data() ) + createInfos.size() * ( sizeof( UniquePipeline ) - sizeof( Pipeline ) ) );
Result result = static_cast<Result>(d.vkCreateGraphicsPipelines( m_device, static_cast<VkPipelineCache>( pipelineCache ), createInfos.size() , reinterpret_cast<const VkGraphicsPipelineCreateInfo*>( createInfos.data() ), reinterpret_cast<const VkAllocationCallbacks*>( static_cast<const AllocationCallbacks*>( allocator ) ), reinterpret_cast<VkPipeline*>( buffer ) ) );
PipelineDeleter deleter( *this, allocator ); PipelineDeleter deleter( *this, allocator );
std::vector<UniquePipeline> uniquePipelines; for ( size_t i=0 ; i<createInfos.size() ; i++ )
uniquePipelines.reserve( pipelines.size() );
for ( auto const& pipeline : pipelines )
{ {
uniquePipelines.push_back( UniquePipeline( pipeline, deleter ) ); pipelines.push_back( UniquePipeline( buffer[i], deleter ) );
} }
return createResultValue( result, uniquePipelines, "VULKAN_HPP_NAMESPACE::Device::createGraphicsPipelinesUnique" ); return createResultValue( result, pipelines, "VULKAN_HPP_NAMESPACE::Device::createGraphicsPipelinesUnique" );
} }
template <typename Allocator, typename Dispatch> template <typename Allocator, typename Dispatch>
VULKAN_HPP_INLINE ResultValueType<UniquePipeline>::type Device::createGraphicsPipelineUnique( PipelineCache pipelineCache, const GraphicsPipelineCreateInfo & createInfo, Optional<const AllocationCallbacks> allocator, Dispatch const &d ) const VULKAN_HPP_INLINE ResultValueType<UniquePipeline>::type Device::createGraphicsPipelineUnique( PipelineCache pipelineCache, const GraphicsPipelineCreateInfo & createInfo, Optional<const AllocationCallbacks> allocator, Dispatch const &d ) const
@ -30828,18 +30829,19 @@ public:
template <typename Allocator, typename Dispatch> template <typename Allocator, typename Dispatch>
VULKAN_HPP_INLINE typename ResultValueType<std::vector<UniquePipeline,Allocator>>::type Device::createComputePipelinesUnique( PipelineCache pipelineCache, ArrayProxy<const ComputePipelineCreateInfo> createInfos, Optional<const AllocationCallbacks> allocator, Dispatch const &d ) const VULKAN_HPP_INLINE typename ResultValueType<std::vector<UniquePipeline,Allocator>>::type Device::createComputePipelinesUnique( PipelineCache pipelineCache, ArrayProxy<const ComputePipelineCreateInfo> createInfos, Optional<const AllocationCallbacks> allocator, Dispatch const &d ) const
{ {
std::vector<Pipeline,Allocator> pipelines( createInfos.size() ); static_assert( sizeof( Pipeline ) <= sizeof( UniquePipeline ), "Pipeline is greater than UniquePipeline!" );
Result result = static_cast<Result>( d.vkCreateComputePipelines( m_device, static_cast<VkPipelineCache>( pipelineCache ), createInfos.size() , reinterpret_cast<const VkComputePipelineCreateInfo*>( createInfos.data() ), reinterpret_cast<const VkAllocationCallbacks*>( static_cast<const AllocationCallbacks*>( allocator ) ), reinterpret_cast<VkPipeline*>( pipelines.data() ) ) ); std::vector<UniquePipeline, Allocator> pipelines;
pipelines.reserve( createInfos.size() );
Pipeline* buffer = reinterpret_cast<Pipeline*>( reinterpret_cast<char*>( pipelines.data() ) + createInfos.size() * ( sizeof( UniquePipeline ) - sizeof( Pipeline ) ) );
Result result = static_cast<Result>(d.vkCreateComputePipelines( m_device, static_cast<VkPipelineCache>( pipelineCache ), createInfos.size() , reinterpret_cast<const VkComputePipelineCreateInfo*>( createInfos.data() ), reinterpret_cast<const VkAllocationCallbacks*>( static_cast<const AllocationCallbacks*>( allocator ) ), reinterpret_cast<VkPipeline*>( buffer ) ) );
PipelineDeleter deleter( *this, allocator ); PipelineDeleter deleter( *this, allocator );
std::vector<UniquePipeline> uniquePipelines; for ( size_t i=0 ; i<createInfos.size() ; i++ )
uniquePipelines.reserve( pipelines.size() );
for ( auto const& pipeline : pipelines )
{ {
uniquePipelines.push_back( UniquePipeline( pipeline, deleter ) ); pipelines.push_back( UniquePipeline( buffer[i], deleter ) );
} }
return createResultValue( result, uniquePipelines, "VULKAN_HPP_NAMESPACE::Device::createComputePipelinesUnique" ); return createResultValue( result, pipelines, "VULKAN_HPP_NAMESPACE::Device::createComputePipelinesUnique" );
} }
template <typename Allocator, typename Dispatch> template <typename Allocator, typename Dispatch>
VULKAN_HPP_INLINE ResultValueType<UniquePipeline>::type Device::createComputePipelineUnique( PipelineCache pipelineCache, const ComputePipelineCreateInfo & createInfo, Optional<const AllocationCallbacks> allocator, Dispatch const &d ) const VULKAN_HPP_INLINE ResultValueType<UniquePipeline>::type Device::createComputePipelineUnique( PipelineCache pipelineCache, const ComputePipelineCreateInfo & createInfo, Optional<const AllocationCallbacks> allocator, Dispatch const &d ) const
@ -31054,18 +31056,19 @@ public:
template <typename Allocator, typename Dispatch> template <typename Allocator, typename Dispatch>
VULKAN_HPP_INLINE typename ResultValueType<std::vector<UniqueDescriptorSet,Allocator>>::type Device::allocateDescriptorSetsUnique( const DescriptorSetAllocateInfo & allocateInfo, Dispatch const &d ) const VULKAN_HPP_INLINE typename ResultValueType<std::vector<UniqueDescriptorSet,Allocator>>::type Device::allocateDescriptorSetsUnique( const DescriptorSetAllocateInfo & allocateInfo, Dispatch const &d ) const
{ {
std::vector<DescriptorSet,Allocator> descriptorSets( allocateInfo.descriptorSetCount ); static_assert( sizeof( DescriptorSet ) <= sizeof( UniqueDescriptorSet ), "DescriptorSet is greater than UniqueDescriptorSet!" );
Result result = static_cast<Result>( d.vkAllocateDescriptorSets( m_device, reinterpret_cast<const VkDescriptorSetAllocateInfo*>( &allocateInfo ), reinterpret_cast<VkDescriptorSet*>( descriptorSets.data() ) ) ); std::vector<UniqueDescriptorSet, Allocator> descriptorSets;
descriptorSets.reserve( allocateInfo.descriptorSetCount );
DescriptorSet* buffer = reinterpret_cast<DescriptorSet*>( reinterpret_cast<char*>( descriptorSets.data() ) + allocateInfo.descriptorSetCount * ( sizeof( UniqueDescriptorSet ) - sizeof( DescriptorSet ) ) );
Result result = static_cast<Result>(d.vkAllocateDescriptorSets( m_device, reinterpret_cast<const VkDescriptorSetAllocateInfo*>( &allocateInfo ), reinterpret_cast<VkDescriptorSet*>( buffer ) ) );
DescriptorSetDeleter deleter( *this, allocateInfo.descriptorPool ); DescriptorSetDeleter deleter( *this, allocateInfo.descriptorPool );
std::vector<UniqueDescriptorSet> uniqueDescriptorSets; for ( size_t i=0 ; i<allocateInfo.descriptorSetCount ; i++ )
uniqueDescriptorSets.reserve( descriptorSets.size() );
for ( auto const& descriptorSet : descriptorSets )
{ {
uniqueDescriptorSets.push_back( UniqueDescriptorSet( descriptorSet, deleter ) ); descriptorSets.push_back( UniqueDescriptorSet( buffer[i], deleter ) );
} }
return createResultValue( result, uniqueDescriptorSets, "VULKAN_HPP_NAMESPACE::Device::allocateDescriptorSetsUnique" ); return createResultValue( result, descriptorSets, "VULKAN_HPP_NAMESPACE::Device::allocateDescriptorSetsUnique" );
} }
#endif /*VULKAN_HPP_NO_SMART_HANDLE*/ #endif /*VULKAN_HPP_NO_SMART_HANDLE*/
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -31261,18 +31264,19 @@ public:
template <typename Allocator, typename Dispatch> template <typename Allocator, typename Dispatch>
VULKAN_HPP_INLINE typename ResultValueType<std::vector<UniqueCommandBuffer,Allocator>>::type Device::allocateCommandBuffersUnique( const CommandBufferAllocateInfo & allocateInfo, Dispatch const &d ) const VULKAN_HPP_INLINE typename ResultValueType<std::vector<UniqueCommandBuffer,Allocator>>::type Device::allocateCommandBuffersUnique( const CommandBufferAllocateInfo & allocateInfo, Dispatch const &d ) const
{ {
std::vector<CommandBuffer,Allocator> commandBuffers( allocateInfo.commandBufferCount ); static_assert( sizeof( CommandBuffer ) <= sizeof( UniqueCommandBuffer ), "CommandBuffer is greater than UniqueCommandBuffer!" );
Result result = static_cast<Result>( d.vkAllocateCommandBuffers( m_device, reinterpret_cast<const VkCommandBufferAllocateInfo*>( &allocateInfo ), reinterpret_cast<VkCommandBuffer*>( commandBuffers.data() ) ) ); std::vector<UniqueCommandBuffer, Allocator> commandBuffers;
commandBuffers.reserve( allocateInfo.commandBufferCount );
CommandBuffer* buffer = reinterpret_cast<CommandBuffer*>( reinterpret_cast<char*>( commandBuffers.data() ) + allocateInfo.commandBufferCount * ( sizeof( UniqueCommandBuffer ) - sizeof( CommandBuffer ) ) );
Result result = static_cast<Result>(d.vkAllocateCommandBuffers( m_device, reinterpret_cast<const VkCommandBufferAllocateInfo*>( &allocateInfo ), reinterpret_cast<VkCommandBuffer*>( buffer ) ) );
CommandBufferDeleter deleter( *this, allocateInfo.commandPool ); CommandBufferDeleter deleter( *this, allocateInfo.commandPool );
std::vector<UniqueCommandBuffer> uniqueCommandBuffers; for ( size_t i=0 ; i<allocateInfo.commandBufferCount ; i++ )
uniqueCommandBuffers.reserve( commandBuffers.size() );
for ( auto const& commandBuffer : commandBuffers )
{ {
uniqueCommandBuffers.push_back( UniqueCommandBuffer( commandBuffer, deleter ) ); commandBuffers.push_back( UniqueCommandBuffer( buffer[i], deleter ) );
} }
return createResultValue( result, uniqueCommandBuffers, "VULKAN_HPP_NAMESPACE::Device::allocateCommandBuffersUnique" ); return createResultValue( result, commandBuffers, "VULKAN_HPP_NAMESPACE::Device::allocateCommandBuffersUnique" );
} }
#endif /*VULKAN_HPP_NO_SMART_HANDLE*/ #endif /*VULKAN_HPP_NO_SMART_HANDLE*/
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
@ -31314,18 +31318,19 @@ public:
template <typename Allocator, typename Dispatch> template <typename Allocator, typename Dispatch>
VULKAN_HPP_INLINE typename ResultValueType<std::vector<UniqueSwapchainKHR,Allocator>>::type Device::createSharedSwapchainsKHRUnique( ArrayProxy<const SwapchainCreateInfoKHR> createInfos, Optional<const AllocationCallbacks> allocator, Dispatch const &d ) const VULKAN_HPP_INLINE typename ResultValueType<std::vector<UniqueSwapchainKHR,Allocator>>::type Device::createSharedSwapchainsKHRUnique( ArrayProxy<const SwapchainCreateInfoKHR> createInfos, Optional<const AllocationCallbacks> allocator, Dispatch const &d ) const
{ {
std::vector<SwapchainKHR,Allocator> swapchains( createInfos.size() ); static_assert( sizeof( SwapchainKHR ) <= sizeof( UniqueSwapchainKHR ), "SwapchainKHR is greater than UniqueSwapchainKHR!" );
Result result = static_cast<Result>( d.vkCreateSharedSwapchainsKHR( m_device, createInfos.size() , reinterpret_cast<const VkSwapchainCreateInfoKHR*>( createInfos.data() ), reinterpret_cast<const VkAllocationCallbacks*>( static_cast<const AllocationCallbacks*>( allocator ) ), reinterpret_cast<VkSwapchainKHR*>( swapchains.data() ) ) ); std::vector<UniqueSwapchainKHR, Allocator> swapchainKHRs;
swapchainKHRs.reserve( createInfos.size() );
SwapchainKHR* buffer = reinterpret_cast<SwapchainKHR*>( reinterpret_cast<char*>( swapchainKHRs.data() ) + createInfos.size() * ( sizeof( UniqueSwapchainKHR ) - sizeof( SwapchainKHR ) ) );
Result result = static_cast<Result>(d.vkCreateSharedSwapchainsKHR( m_device, createInfos.size() , reinterpret_cast<const VkSwapchainCreateInfoKHR*>( createInfos.data() ), reinterpret_cast<const VkAllocationCallbacks*>( static_cast<const AllocationCallbacks*>( allocator ) ), reinterpret_cast<VkSwapchainKHR*>( buffer ) ) );
SwapchainKHRDeleter deleter( *this, allocator ); SwapchainKHRDeleter deleter( *this, allocator );
std::vector<UniqueSwapchainKHR> uniqueSwapchains; for ( size_t i=0 ; i<createInfos.size() ; i++ )
uniqueSwapchains.reserve( swapchains.size() );
for ( auto const& swapchain : swapchains )
{ {
uniqueSwapchains.push_back( UniqueSwapchainKHR( swapchain, deleter ) ); swapchainKHRs.push_back( UniqueSwapchainKHR( buffer[i], deleter ) );
} }
return createResultValue( result, uniqueSwapchains, "VULKAN_HPP_NAMESPACE::Device::createSharedSwapchainsKHRUnique" ); return createResultValue( result, swapchainKHRs, "VULKAN_HPP_NAMESPACE::Device::createSharedSwapchainsKHRUnique" );
} }
template <typename Allocator, typename Dispatch> template <typename Allocator, typename Dispatch>
VULKAN_HPP_INLINE ResultValueType<UniqueSwapchainKHR>::type Device::createSharedSwapchainKHRUnique( const SwapchainCreateInfoKHR & createInfo, Optional<const AllocationCallbacks> allocator, Dispatch const &d ) const VULKAN_HPP_INLINE ResultValueType<UniqueSwapchainKHR>::type Device::createSharedSwapchainKHRUnique( const SwapchainCreateInfoKHR & createInfo, Optional<const AllocationCallbacks> allocator, Dispatch const &d ) const