mesa: update textures for bindless samplers bound to texture units
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 11 May 2017 15:29:53 +0000 (17:29 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 14 Jun 2017 08:04:36 +0000 (10:04 +0200)
This is analogous to the existing SamplerUnits and SamplerTargets,
but it loops over bindless samplers bound to texture units.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/mesa/main/texstate.c
src/mesa/main/uniforms.c

index 59b964816630e11a710fa70799fe52b0dac08a23..b3411a87ef9fb70d7c28dac77104075d878e40ac 100644 (file)
@@ -704,6 +704,7 @@ update_program_texture_state(struct gl_context *ctx, struct gl_program **prog,
 
    for (i = 0; i < MESA_SHADER_STAGES; i++) {
       GLbitfield mask;
+      GLuint s;
 
       if (!prog[i])
          continue;
@@ -711,12 +712,27 @@ update_program_texture_state(struct gl_context *ctx, struct gl_program **prog,
       mask = prog[i]->SamplersUsed;
 
       while (mask) {
-         const int s = u_bit_scan(&mask);
+         s = u_bit_scan(&mask);
 
          update_single_program_texture_state(ctx, prog[i],
                                              prog[i]->SamplerUnits[s],
                                              enabled_texture_units);
       }
+
+      if (unlikely(prog[i]->sh.HasBoundBindlessSampler)) {
+         /* Loop over bindless samplers bound to texture units.
+          */
+         for (s = 0; s < prog[i]->sh.NumBindlessSamplers; s++) {
+            struct gl_bindless_sampler *sampler =
+               &prog[i]->sh.BindlessSamplers[s];
+
+            if (!sampler->bound)
+               continue;
+
+            update_single_program_texture_state(ctx, prog[i], sampler->unit,
+                                                enabled_texture_units);
+         }
+      }
    }
 
    if (prog[MESA_SHADER_FRAGMENT]) {
index 6706f794d7e758252f5d480844d2867d85bbd99b..91c3bf66f8d88883bed9bfe52248cf8e9c2c050f 100644 (file)
@@ -105,18 +105,33 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
    gl_shader_stage prog_stage =
       _mesa_program_enum_to_shader_stage(prog->Target);
    struct gl_linked_shader *shader = shProg->_LinkedShaders[prog_stage];
+   GLuint s;
 
    assert(shader);
 
    memset(prog->TexturesUsed, 0, sizeof(prog->TexturesUsed));
 
    while (mask) {
-      const int s = u_bit_scan(&mask);
+      s = u_bit_scan(&mask);
 
       update_single_shader_texture_used(shProg, prog,
                                         prog->SamplerUnits[s],
                                         prog->sh.SamplerTargets[s]);
    }
+
+   if (unlikely(prog->sh.HasBoundBindlessSampler)) {
+      /* Loop over bindless samplers bound to texture units.
+       */
+      for (s = 0; s < prog->sh.NumBindlessSamplers; s++) {
+         struct gl_bindless_sampler *sampler = &prog->sh.BindlessSamplers[s];
+
+         if (!sampler->bound)
+            continue;
+
+         update_single_shader_texture_used(shProg, prog, sampler->unit,
+                                           sampler->target);
+      }
+   }
 }
 
 /**