u/Slow-Juggernaut-9065

▲ 29 r/vulkan+1 crossposts

How do you handle resource management in bindless renderers?

Resource handling consists of two different parts: managing a CPU-side version like a VkBuffer, VkImage, etc., and managing a GPU-side version like a combination of set, binding, and array indices. From what I've read, it looks to me like a GPU-side handle is created when a CPU-side resource is created. And it makes sense to create them together, since there should be only one reference to such a resource Thus, a resource would look like this:

struct Resource {
    union {
        VkBuffer buffer;
        VkImage image;
        // ...
    };

    struct {
        int set;
        int binding;
        int index;
    } reference;
};

However, such a design would tightly couple resource management with descriptor set handling, because a resource manager would need to know where and how to bind a resource, and this doesn't look too good to me.

Considering all of the above, I have a few questions I can't answer myself:

  1. Does the resource manager need to know how to handle descriptors? If not, should the API user handle them himself, given that they should know where to bind the requested resources?
  2. If it is the resource manager's job to handle descriptors, doesn't that impose some predefined descriptor layout so that the manager knows where to bind them?
  3. If it does enforce some descriptor layout, how do you write shaders that need different input data?
reddit.com
u/Slow-Juggernaut-9065 — 9 days ago