VulkanMemoryAllocator-Hpp icon indicating copy to clipboard operation
VulkanMemoryAllocator-Hpp copied to clipboard

destroy function overloads.

Open gssgh opened this issue 5 years ago • 4 comments

vulkan-hpp provides destroy function overloads. I'm not sure this makes the API better, but to be on par with the vulkan-hpp API I think they should be there.

gssgh avatar Nov 13 '19 17:11 gssgh

Can you elaborate on what you mean by "destroy function overloads"?

malte-v avatar Nov 13 '19 18:11 malte-v

If you look at the vulkan-hpp header file, for every destroy*() function (e.g, destroyImage()) there is a function named destroy() that takes as argument the object to destroy (e.g, destroy(vk::Image)), e.i, the destroy() function is overloaded.

The following code sniped shows the declaration of destroyBuffer() with its destroy() overload in vulkan.hpp:

    template<typename Dispatch = DispatchLoaderDefault>
    void destroyBuffer( Buffer buffer, const AllocationCallbacks* pAllocator, Dispatch const &d = Dispatch() ) const;
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
    template<typename Dispatch = DispatchLoaderDefault>
    void destroyBuffer( Buffer buffer, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/

    template<typename Dispatch = DispatchLoaderDefault>
    void destroy( Buffer buffer, const AllocationCallbacks* pAllocator, Dispatch const &d = Dispatch() ) const;
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
    template<typename Dispatch = DispatchLoaderDefault>
    void destroy( Buffer buffer, Optional<const AllocationCallbacks> allocator = nullptr, Dispatch const &d = Dispatch() ) const;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/

This overloads are also present as member functions of Device and Instance.

gssgh avatar Nov 13 '19 20:11 gssgh

I see... Personally I'm not a fan of this kind of function overloading, but for the sake of consistency I'll accept a PR if you'd like to have these functions in the bindings.

malte-v avatar Nov 13 '19 20:11 malte-v

I see... Personally I'm not a fan of this kind of function overloading, but for the sake of consistency I'll accept a PR if you'd like to have these functions in the bindings.

Function overloading on object destruction is used for Unique Handle <Type>

MikhailGorobets avatar Oct 27 '20 19:10 MikhailGorobets