Search Unity

Question How does Unity select Vulkan descriptor sets and bindings?

Discussion in 'Shaders' started by Roldo, Aug 1, 2022.

  1. Roldo

    Roldo

    Joined:
    Oct 25, 2014
    Posts:
    41
    Hello!

    I have been learning how to use Vulkan recently and from what I understand, for best performance it is recommended to manually specify descriptor sets.

    What i have been confused about is how are descriptor sets and bindings specified in Unity's shader code.
    In GLSL, bindings and descriptor sets can be specified via attributes.
    layout(set=Y, binding=X) uniform sampler2D mySampler;


    HLSL to my knowledge, does not have such concepts, and different cross-compilers use different conventions. For example, microsoft's compiler uses
    [[vk::binding(X[, Y])]]
    or
    :register(xX, spaceY)
    attributes.

    Unity, to my knowledge, uses a custom HLSL cross-compiler for Vulkan.

    Is there a way to manually specify the descriptor sets and bindings for shaders that support Vulkan? And also, do descriptor sets actually matter in Unity? Are descriptor sets somehow exposed in the API (ex. for custom rendering pipelines)?