[Mesa-dev] [PATCH 1/5] glsl/ir: add param index to variable.

Timothy Arceri timothy.arceri at collabora.com
Tue Feb 9 00:02:06 UTC 2016


On Mon, 2016-02-08 at 13:45 +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> We have a requirement to store the index into the mesa parameterlist
> for uniforms. Up until now we've overwritten var->data.location with
> this info. However this then stops us accessing UniformStorage,
> which is needed to do proper dereferencing.
> 
> Add a new variable to ir_variable to store this value in, and change
> the two uses to use it correctly.
> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>

Not ideal that we need to do this, but shouldn't be so bad once we
finally start to drop the IR when not needed.

Reviewed-by: Timothy Arceri <timothy.arceri at collabora.com>

> ---
>  src/compiler/glsl/ir.h                     | 8 ++++++++
>  src/mesa/program/ir_to_mesa.cpp            | 5 ++---
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 +-
>  3 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
> index 09e21b2..bf9b7ca 100644
> --- a/src/compiler/glsl/ir.h
> +++ b/src/compiler/glsl/ir.h
> @@ -864,6 +864,14 @@ public:
>        int location;
>  
>        /**
> +       * for glsl->tgsi/mesa IR we need to store the index into the
> +       * parameters for uniforms, initially the code overloaded
> location
> +       * but this causes problems with indirect samplers and AoA.
> +       * This is assigned in
> _mesa_generate_parameters_list_for_uniforms.
> +       */
> +      int param_index;
> +
> +      /**
>         * Vertex stream output identifier.
>         */
>        unsigned stream;
> diff --git a/src/mesa/program/ir_to_mesa.cpp
> b/src/mesa/program/ir_to_mesa.cpp
> index 768d921..68cc4a5 100644
> --- a/src/mesa/program/ir_to_mesa.cpp
> +++ b/src/mesa/program/ir_to_mesa.cpp
> @@ -1389,7 +1389,7 @@
> ir_to_mesa_visitor::visit(ir_dereference_variable *ir)
>        switch (var->data.mode) {
>        case ir_var_uniform:
>  	 entry = new(mem_ctx) variable_storage(var, PROGRAM_UNIFORM,
> -					       var->data.location);
> +					       var-
> >data.param_index);
>  	 this->variables.push_tail(entry);
>  	 break;
>        case ir_var_shader_in:
> @@ -2268,8 +2268,7 @@ public:
>     {
>        this->idx = -1;
>        this->program_resource_visitor::process(var);
> -
> -      var->data.location = this->idx;
> +      var->data.param_index = this->idx;
>     }
>  
>  private:
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index b8182de..4b5f2a3 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -2350,7 +2350,7 @@
> glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
>        switch (var->data.mode) {
>        case ir_var_uniform:
>           entry = new(mem_ctx) variable_storage(var, PROGRAM_UNIFORM,
> -                                               var->data.location);
> +                                               var-
> >data.param_index);
>           this->variables.push_tail(entry);
>           break;
>        case ir_var_shader_in:


More information about the mesa-dev mailing list