Descriptor Sets & Bindless Rendering

🔗 Descriptor Sets & Bindless Rendering in Vulkan

In traditional Vulkan pipelines, every texture, uniform buffer, and sampler is bound individually before each draw call using vkCmdBindDescriptorSets. This CPU binding overhead limits draw call counts.

Bindless Rendering (via VK_EXT_descriptor_indexing) eliminates per-draw binding by placing all scene textures and materials into an unbounded global array in GPU memory.


🏛️ Traditional Binding vs. Bindless

1. Traditional Binding (Per Draw):
   [ Draw Mesh 0 ] -> vkCmdBindDescriptorSets(Texture 0) -> vkCmdDraw
   [ Draw Mesh 1 ] -> vkCmdBindDescriptorSets(Texture 1) -> vkCmdDraw (CPU Bottleneck)

2. Bindless (Single Global Descriptor Array):
   [ Global Texture Array: 10,000 Textures in VRAM ]
   [ Draw Mesh 0 ] -> PushConstant(TextureID = 42)   -> vkCmdDraw
   [ Draw Mesh 1 ] -> PushConstant(TextureID = 812)  -> vkCmdDraw

⚡ 1. GLSL Bindless Shader Example

#version 460
#extension GL_EXT_nonuniform_qualifier : require

// Unbounded array of 2D samplers
layout(set = 0, binding = 0) uniform sampler2D u_Textures[];

layout(push_constant) uniform Push_Constants {
    mat4 model_matrix;
    uint texture_index; // Single index selects texture dynamically!
} pc;

layout(location = 0) in vec2 in_UV;
layout(location = 0) out vec4 out_Color;

void main() {
    out_Color = texture(u_Textures[nonuniformEXT(pc.texture_index)], in_UV);
}