glsl: set the explicit binding value for bindless samplers/images
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 11 May 2017 15:37:27 +0000 (17:37 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 14 Jun 2017 08:04:36 +0000 (10:04 +0200)
This handles a situation like:

layout (bindless_sampler, binding = 7) uniform sampler2D;

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/compiler/glsl/link_uniform_initializers.cpp

index bc3dcab7c352e7b95ac49981c402114c19fe7ba5..e7f9c9d8ac0ed51c5f9bb101eb8087d86b2628bd 100644 (file)
@@ -140,16 +140,39 @@ set_opaque_binding(void *mem_ctx, gl_shader_program *prog,
          if (storage->type->is_sampler()) {
             for (unsigned i = 0; i < elements; i++) {
                const unsigned index = storage->opaque[sh].index + i;
-               if (index >= ARRAY_SIZE(shader->Program->SamplerUnits))
-                  break;
-               shader->Program->SamplerUnits[index] = storage->storage[i].i;
+
+               if (var->data.bindless) {
+                  if (index >= shader->Program->sh.NumBindlessSamplers)
+                     break;
+                  shader->Program->sh.BindlessSamplers[index].unit =
+                     storage->storage[i].i;
+                  shader->Program->sh.BindlessSamplers[index].bound = true;
+                  shader->Program->sh.HasBoundBindlessSampler = true;
+               } else {
+                  if (index >= ARRAY_SIZE(shader->Program->SamplerUnits))
+                     break;
+                  shader->Program->SamplerUnits[index] =
+                     storage->storage[i].i;
+               }
             }
          } else if (storage->type->is_image()) {
             for (unsigned i = 0; i < elements; i++) {
                const unsigned index = storage->opaque[sh].index + i;
-               if (index >= ARRAY_SIZE(shader->Program->sh.ImageUnits))
-                  break;
-               shader->Program->sh.ImageUnits[index] = storage->storage[i].i;
+
+
+               if (var->data.bindless) {
+                  if (index >= shader->Program->sh.NumBindlessImages)
+                     break;
+                  shader->Program->sh.BindlessImages[index].unit =
+                     storage->storage[i].i;
+                  shader->Program->sh.BindlessImages[index].bound = true;
+                  shader->Program->sh.HasBoundBindlessImage = true;
+               } else {
+                  if (index >= ARRAY_SIZE(shader->Program->sh.ImageUnits))
+                     break;
+                  shader->Program->sh.ImageUnits[index] =
+                     storage->storage[i].i;
+               }
             }
          }
       }