[SDL_GPU] What determines the set for uniforms?

While following the sdl_gpu_examples, I can’t figure out why the set for vertex uniforms needs to be 1 and for fragment samplers it needs to be 2. I didn’t define this anywhere when creating or binding the sampler so are these just standard descriptor sets SDL has defined?

example:
vertex shader

layout (set = 1, binding = 0) uniform Rect {
	vec2 position;
    vec2 scale;
} rect;

fragment shader

layout (set = 2, binding = 0) uniform sampler2D Sampler;

The Remarks section of the SDL_CreateGPUShader() function explain it:

Shader resource bindings must be authored to follow a particular order depending on the shader format.

For SPIR-V shaders, use the following resource sets:

For vertex shaders:

  • 0: Sampled textures, followed by storage textures, followed by storage buffers
  • 1: Uniform buffers

For fragment shaders:

  • 2: Sampled textures, followed by storage textures, followed by storage buffers
  • 3: Uniform buffers
1 Like

Oh I was reading the wiki but somehow missed that part. Thanks!