1
\$\begingroup\$

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?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ It isn't safe to assume that every resource will use a specific heap. A way to work around this is to wait for a heap to be used before allocating. \$\endgroup\$
    – gan_
    Commented Jan 7, 2019 at 14:20

1 Answer 1

2
\$\begingroup\$

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".

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .