Should images have dedicated allocations?

Hello people of the Vulkan forums!

So as most of you probably already know, the most efficient way to work with buffers and memory is to use a single buffer bound to a large allocation, and then suballocate from that big chunk of memory whenever you need it for something. I was just wondering if I should be doing the same thing for images.

When we allocate memory in Vulkan we must make a call to vkGetXMemoryRequirements to figure out the memory type index to provide when allocating memory. I imagine that this memory type index could differ between buffers and images, making sharing an allocation between them unsafe, though I could be wrong.

So should I be suballocating images and buffers from the same memory? Should I have two seperate pools for buffer/image memory? Or should I give each image its own dedicated allocation?

Any information you can give me would be very helpful, as there aren’t a lot of discussions going on about this topic.

You can do that as long as the memory satisfies the VkMemoryRequirements of the resource. When allocating buffers and images from the same device memory allocation you must also consider VkPhysicalDeviceLimits.bufferImageGranularity.
The VulkanMemoryAllocator library has code to handle this correctly for example.

In general: no. If nothing else than on some implementation/platforms VkPhysicalDeviceLimits. maxMemoryAllocationCount is 4096 so you would limit yourself to a total of 4k buffers and images. If your implementation supports VK_KHR_dedicated_allocation (or Vulkan 1.1) you can ask the implementation if it requires/recommends a dedicated allocation. AFAIK that is typically suggested for render targets or very large resources.