Reviewed-by: Timothy Arceri <tarc...@itsqueeze.com>

On 13/06/17 04:18, Marek Olšák wrote:
From: Marek Olšák <marek.ol...@amd.com>

---
  src/mesa/state_tracker/st_atom_sampler.c | 24 ++++++++----------------
  1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_sampler.c 
b/src/mesa/state_tracker/st_atom_sampler.c
index 52ff9b6..9e5d940 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -253,52 +253,43 @@ convert_sampler_from_unit(const struct st_context *st,
/**
   * Update the gallium driver's sampler state for fragment, vertex or
   * geometry shader stage.
   */
  static void
  update_shader_samplers(struct st_context *st,
                         enum pipe_shader_type shader_stage,
                         const struct gl_program *prog,
                         struct pipe_sampler_state *samplers,
-                       unsigned *num_samplers)
+                       unsigned *out_num_samplers)
  {
     GLbitfield samplers_used = prog->SamplersUsed;
     GLbitfield free_slots = ~prog->SamplersUsed;
     GLbitfield external_samplers_used = prog->ExternalSamplersUsed;
-   GLuint unit;
-   const GLuint old_max = *num_samplers;
+   unsigned unit, num_samplers;
     const struct pipe_sampler_state *states[PIPE_MAX_SAMPLERS];
if (samplers_used == 0x0)
        return;
- *num_samplers = 0;
+   num_samplers = util_last_bit(samplers_used);
/* loop over sampler units (aka tex image units) */
     for (unit = 0; samplers_used; unit++, samplers_used >>= 1) {
        struct pipe_sampler_state *sampler = samplers + unit;
if (samplers_used & 1) {
-         const GLuint texUnit = prog->SamplerUnits[unit];
-
-         convert_sampler_from_unit(st, sampler, texUnit);
+         convert_sampler_from_unit(st, sampler, prog->SamplerUnits[unit]);
           states[unit] = sampler;
-         *num_samplers = unit + 1;
-      }
-      else if (samplers_used != 0 || unit < old_max) {
+      } else {
           states[unit] = NULL;
        }
-      else {
-         /* if we've reset all the old samplers and we have no more new ones */
-         break;
-      }
     }
/* For any external samplers with multiplaner YUV, stuff the additional
      * sampler states we need at the end.
      *
      * Just re-use the existing sampler-state from the primary slot.
      */
     while (unlikely(external_samplers_used)) {
        GLuint unit = u_bit_scan(&external_samplers_used);
        GLuint extra = 0;
@@ -319,24 +310,25 @@ update_shader_samplers(struct st_context *st,
           /* we need two additional samplers: */
           extra = u_bit_scan(&free_slots);
           states[extra] = sampler;
           extra = u_bit_scan(&free_slots);
           states[extra] = sampler;
           break;
        default:
           break;
        }
- *num_samplers = MAX2(*num_samplers, extra + 1);
+      num_samplers = MAX2(num_samplers, extra + 1);
     }
- cso_set_samplers(st->cso_context, shader_stage, *num_samplers, states);
+   cso_set_samplers(st->cso_context, shader_stage, num_samplers, states);
+   *out_num_samplers = num_samplers;
  }
void
  st_update_vertex_samplers(struct st_context *st)
  {
     const struct gl_context *ctx = st->ctx;
update_shader_samplers(st,
                            PIPE_SHADER_VERTEX,

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to