From 92bc17981b52c9d3f279adcc7164e5acf5d3ac26 Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Thu, 18 Jun 2020 11:00:22 +0200 Subject: [PATCH] Provide default arguments in ObjectFree constructor for allocationCallbacks and dispatcher. --- VulkanHppGenerator.cpp | 53 +++++++++++++---------- tests/DeviceFunctions/DeviceFunctions.cpp | 6 +++ vulkan/vulkan.hpp | 5 ++- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index c5bdde6..e64957c 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -7305,34 +7305,39 @@ int main( int argc, char ** argv ) template class ObjectFree { - public: - ObjectFree() - : m_owner() - , m_allocationCallbacks( nullptr ) - , m_dispatch( nullptr ) - {} + public: + ObjectFree() : m_owner(), m_allocationCallbacks( nullptr ), m_dispatch( nullptr ) {} - ObjectFree( OwnerType owner, Optional allocationCallbacks, Dispatch const &dispatch ) VULKAN_HPP_NOEXCEPT - : m_owner( owner ) - , m_allocationCallbacks( allocationCallbacks ) - , m_dispatch( &dispatch ) - {} + ObjectFree( OwnerType owner, + Optional allocationCallbacks = nullptr, + Dispatch const & dispatch = VULKAN_HPP_DEFAULT_DISPATCHER ) VULKAN_HPP_NOEXCEPT + : m_owner( owner ) + , m_allocationCallbacks( allocationCallbacks ) + , m_dispatch( &dispatch ) + {} - OwnerType getOwner() const VULKAN_HPP_NOEXCEPT { return m_owner; } - Optional getAllocator() const VULKAN_HPP_NOEXCEPT { return m_allocationCallbacks; } + OwnerType getOwner() const VULKAN_HPP_NOEXCEPT + { + return m_owner; + } - protected: - template - void destroy(T t) VULKAN_HPP_NOEXCEPT - { - VULKAN_HPP_ASSERT( m_owner && m_dispatch ); - m_owner.free( t, m_allocationCallbacks, *m_dispatch ); - } + Optional getAllocator() const VULKAN_HPP_NOEXCEPT + { + return m_allocationCallbacks; + } - private: - OwnerType m_owner; - Optional m_allocationCallbacks; - Dispatch const* m_dispatch; + protected: + template + void destroy( T t ) VULKAN_HPP_NOEXCEPT + { + VULKAN_HPP_ASSERT( m_owner && m_dispatch ); + m_owner.free( t, m_allocationCallbacks, *m_dispatch ); + } + + private: + OwnerType m_owner; + Optional m_allocationCallbacks; + Dispatch const * m_dispatch; }; )"; diff --git a/tests/DeviceFunctions/DeviceFunctions.cpp b/tests/DeviceFunctions/DeviceFunctions.cpp index e65a90a..fab8e7e 100644 --- a/tests/DeviceFunctions/DeviceFunctions.cpp +++ b/tests/DeviceFunctions/DeviceFunctions.cpp @@ -61,6 +61,12 @@ int main( int /*argc*/, char ** /*argv*/ ) std::vector>::allocator_type dynamicVectorAllocator; vk::UniqueHandle dynamicCommandBuffer = std::move( device->allocateCommandBuffersUnique( {}, dynamicVectorAllocator, vk::DispatchLoaderDynamic() ).front() ); + + vk::Buffer buffer = device->createBuffer( {} ); + vk::UniqueBuffer uniqueBuffer = vk::UniqueBuffer( buffer, *device ); + + vk::DeviceMemory deviceMemory = device->allocateMemory( {} ); + vk::UniqueDeviceMemory uniqueDeviceMemory = vk::UniqueDeviceMemory( deviceMemory, *device ); } catch ( vk::SystemError const & err ) { diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 771396f..975c1cd 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -4615,8 +4615,8 @@ namespace VULKAN_HPP_NAMESPACE ObjectFree() : m_owner(), m_allocationCallbacks( nullptr ), m_dispatch( nullptr ) {} ObjectFree( OwnerType owner, - Optional allocationCallbacks, - Dispatch const & dispatch ) VULKAN_HPP_NOEXCEPT + Optional allocationCallbacks = nullptr, + Dispatch const & dispatch = VULKAN_HPP_DEFAULT_DISPATCHER ) VULKAN_HPP_NOEXCEPT : m_owner( owner ) , m_allocationCallbacks( allocationCallbacks ) , m_dispatch( &dispatch ) @@ -4626,6 +4626,7 @@ namespace VULKAN_HPP_NAMESPACE { return m_owner; } + Optional getAllocator() const VULKAN_HPP_NOEXCEPT { return m_allocationCallbacks;