I would like to allocate a bigger chunk of memory and then suballocate from it but I don't fully understand how memory requirements work, is there a chance that when I allocate a piece of device local memory there might be some buffer/texture that memory requirements of which will not include this heap? Or is it safe to assume that if it's a device local heap it will always be viable for device local resources?
1 Answer
Or is it safe to assume that if it's a device local heap it will always be viable for device local resources?
If it were safe to assume that, Vulkan wouldn't have APIs that specifically allow you to query which memory types support which resource objects.
Indeed, NVIDIA can get pretty fine-grained in its relations between memory types and resource objects. Many NVIDIA implementations of Vulkan have nearly a dozen separate memory types, some of which can only be used for very specific kinds of resource objects. Notice how that particular implementation has 2 device-local memory types; one of those is (I believe) reserved for render targets (color/depth/stencil attachments).
What you have to do is what the API suggests: build image and buffer objects representing your particular needs, use the vkGetBuffer/ImageMemoryRequirements
calls to query which types can be used with such buffers/images, and tailor your allocation accordingly. Do however keep section 11.6 handy when coding; the detailed list of which objects will return the same memory type bits is very important for deciding which images/buffers "represent your particular needs".