[Mesa-dev] [PATCH 1/2] glsl: Make a local variable to avoid restating this array lookup.

Pohjolainen, Topi topi.pohjolainen at intel.com
Mon Jun 3 00:55:59 PDT 2013


On Fri, May 31, 2013 at 12:37:36PM -0700, Eric Anholt wrote:
> ---
>  src/glsl/link_uniforms.cpp | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
> index ad63668..54d54cf 100644
> --- a/src/glsl/link_uniforms.cpp
> +++ b/src/glsl/link_uniforms.cpp
> @@ -640,7 +640,9 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
>      */
>     count_uniform_size uniform_size(prog->UniformHash);
>     for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
> -      if (prog->_LinkedShaders[i] == NULL)
> +      struct gl_shader *sh = prog->_LinkedShaders[i];
> +
> +      if (sh == NULL)
>  	 continue;
>  
>        /* Uniforms that lack an initializer in the shader code have an initial
> @@ -655,13 +657,13 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
>        memset(prog->_LinkedShaders[i]->SamplerUnits, 0,
>               sizeof(prog->_LinkedShaders[i]->SamplerUnits));

Use it here as well?

>  
> -      link_update_uniform_buffer_variables(prog->_LinkedShaders[i]);
> +      link_update_uniform_buffer_variables(sh);
>  
>        /* Reset various per-shader target counts.
>         */
>        uniform_size.start_shader();
>  
> -      foreach_list(node, prog->_LinkedShaders[i]->ir) {
> +      foreach_list(node, sh->ir) {
>  	 ir_variable *const var = ((ir_instruction *) node)->as_variable();
>  
>  	 if ((var == NULL) || (var->mode != ir_var_uniform))
> @@ -678,9 +680,8 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
>  	 uniform_size.process(var);
>        }
>  
> -      prog->_LinkedShaders[i]->num_samplers = uniform_size.num_shader_samplers;
> -      prog->_LinkedShaders[i]->num_uniform_components =
> -	 uniform_size.num_shader_uniform_components;
> +      sh->num_samplers = uniform_size.num_shader_samplers;
> +      sh->num_uniform_components = uniform_size.num_shader_uniform_components;
>     }
>  
>     const unsigned num_user_uniforms = uniform_size.num_active_uniforms;
> -- 
> 1.8.3.rc0
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list