[Mesa-dev] [PATCH 17/24] st/mesa: clean up trivial dereferences in update_textures

Marek Olšák maraeo at gmail.com
Mon Jun 12 18:18:48 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/mesa/state_tracker/st_atom_texture.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 6262307..9c0cb24 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -97,50 +97,50 @@ update_single_texture(struct st_context *st,
    return GL_TRUE;
 }
 
 
 
 static void
 update_textures(struct st_context *st,
                 enum pipe_shader_type shader_stage,
                 const struct gl_program *prog,
                 struct pipe_sampler_view **sampler_views,
-                unsigned *num_textures)
+                unsigned *out_num_textures)
 {
-   const GLuint old_max = *num_textures;
+   const GLuint old_max = *out_num_textures;
    GLbitfield samplers_used = prog->SamplersUsed;
    GLbitfield free_slots = ~prog->SamplersUsed;
    GLbitfield external_samplers_used = prog->ExternalSamplersUsed;
    GLuint unit;
 
    if (samplers_used == 0x0 && old_max == 0)
       return;
 
-   *num_textures = 0;
+   unsigned num_textures = 0;
 
    /* loop over sampler units (aka tex image units) */
    for (unit = 0; samplers_used || unit < old_max;
         unit++, samplers_used >>= 1) {
       struct pipe_sampler_view *sampler_view = NULL;
 
       if (samplers_used & 1) {
          /* prog->sh.data is NULL if it's ARB_fragment_program */
          unsigned glsl_version = prog->sh.data ? prog->sh.data->Version : 0;
          const GLuint texUnit = prog->SamplerUnits[unit];
          GLboolean retval;
 
          retval = update_single_texture(st, &sampler_view, texUnit,
                                         glsl_version);
          if (retval == GL_FALSE)
             continue;
 
-         *num_textures = unit + 1;
+         num_textures = unit + 1;
       }
 
       pipe_sampler_view_reference(&(sampler_views[unit]), sampler_view);
    }
 
    /* For any external samplers with multiplaner YUV, stuff the additional
     * sampler views we need at the end.
     *
     * Trying to cache the sampler view in the stObj looks painful, so just
     * re-create the sampler view for the extra planes each time.  Main use
@@ -176,27 +176,28 @@ update_textures(struct st_context *st,
          sampler_views[extra] =
                st->pipe->create_sampler_view(st->pipe, stObj->pt->next, &tmpl);
          extra = u_bit_scan(&free_slots);
          sampler_views[extra] =
                st->pipe->create_sampler_view(st->pipe, stObj->pt->next->next, &tmpl);
          break;
       default:
          break;
       }
 
-      *num_textures = MAX2(*num_textures, extra + 1);
+      num_textures = MAX2(num_textures, extra + 1);
    }
 
    cso_set_sampler_views(st->cso_context,
                          shader_stage,
-                         *num_textures,
+                         num_textures,
                          sampler_views);
+   *out_num_textures = num_textures;
 }
 
 
 
 void
 st_update_vertex_textures(struct st_context *st)
 {
    const struct gl_context *ctx = st->ctx;
 
    if (ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits > 0) {
-- 
2.7.4



More information about the mesa-dev mailing list