VulkanMemoryAllocator-Hpp
VulkanMemoryAllocator-Hpp copied to clipboard
Destruction order of createBufferUnique() result pairs causes validation layer warning
Allocator::createBufferUnique() returns std::pair<vma::UniqueBuffer, vma::UniqueAllocation>.
When that pair is destroyed UniqueAllocation is destroyed first. That causes warnings from validation layer:
vkFreeMemory(): VK Object VkBuffer 0x27d60e0000000019[] still has a reference to mem obj VkDeviceMemory 0x95a125000000001a[].
We can safely ignore this, but it would be nice to keep validation layer clear of any warnings.
This also applies to all functions like createImageUnique etc.
The easiest solution would be to reverse order of fields in the returned pair but I'm not sure if that isn't too big of a change to the API.
For now I'm keeping class members in the form std::pair<vma::UniqueAllocation, vma::UniqueBuffer> and swapping the result of create...Unique() functions.