[Mesa-dev] [RFC PATCH 44/56] glsl: pass shader stage to lower_output_reads and handle tess control

Ilia Mirkin imirkin at alum.mit.edu
Sun Sep 21 09:16:27 PDT 2014


On Sat, Sep 20, 2014 at 9:41 PM, Chris Forbes <chrisf at ijw.co.nz> wrote:
> From: Ilia Mirkin <imirkin at alum.mit.edu>
>
> Tessellation control outputs can be read in directly without first
> having been written. Accessing these will require some special logic
> anyways, so just let them through.
>
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>  src/glsl/ir_optimization.h                 |  2 +-
>  src/glsl/lower_output_reads.cpp            | 13 +++++++++----
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp |  2 +-
>  3 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
> index 2ddbc1e..389aed1 100644
> --- a/src/glsl/ir_optimization.h
> +++ b/src/glsl/ir_optimization.h
> @@ -115,7 +115,7 @@ bool lower_variable_index_to_cond_assign(gl_shader_stage stage,
>      bool lower_temp, bool lower_uniform);
>  bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
>  bool lower_clip_distance(gl_shader *shader);
> -void lower_output_reads(exec_list *instructions);
> +void lower_output_reads(unsigned stage, exec_list *instructions);
>  bool lower_packing_builtins(exec_list *instructions, int op_mask);
>  void lower_ubo_reference(struct gl_shader *shader, exec_list *instructions);
>  void lower_packed_varyings(void *mem_ctx,
> diff --git a/src/glsl/lower_output_reads.cpp b/src/glsl/lower_output_reads.cpp
> index 1ee815d..b6e7ef3 100644
> --- a/src/glsl/lower_output_reads.cpp
> +++ b/src/glsl/lower_output_reads.cpp
> @@ -48,8 +48,10 @@ protected:
>     hash_table *replacements;
>
>     void *mem_ctx;
> +
> +   unsigned stage;
>  public:
> -   output_read_remover();
> +   output_read_remover(unsigned stage);
>     ~output_read_remover();
>     virtual ir_visitor_status visit(class ir_dereference_variable *);
>     virtual ir_visitor_status visit_leave(class ir_emit_vertex *);
> @@ -75,8 +77,9 @@ hash_table_var_hash(const void *key)
>     return hash_table_string_hash(var->name);
>  }
>
> -output_read_remover::output_read_remover()
> +output_read_remover::output_read_remover(unsigned stage)
>  {
> +   this->stage = stage;
>     mem_ctx = ralloc_context(NULL);
>     replacements =
>        hash_table_ctor(0, hash_table_var_hash, hash_table_pointer_compare);
> @@ -93,6 +96,8 @@ output_read_remover::visit(ir_dereference_variable *ir)
>  {
>     if (ir->var->data.mode != ir_var_shader_out)
>        return visit_continue;
> +   if (stage == MESA_SHADER_TESS_CTRL && !ir->var->data.patch)
> +      return visit_continue;

Actually we don't want to mess with patch outputs either, since after
barrier() they will need to be re-read in.

>
>     ir_variable *temp = (ir_variable *) hash_table_find(replacements, ir->var);
>
> @@ -166,8 +171,8 @@ output_read_remover::visit_leave(ir_function_signature *sig)
>  }
>
>  void
> -lower_output_reads(exec_list *instructions)
> +lower_output_reads(unsigned stage, exec_list *instructions)
>  {
> -   output_read_remover v;
> +   output_read_remover v(stage);
>     visit_list_elements(&v, instructions);
>  }
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index 65e0221..38aa567 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -5217,7 +5217,7 @@ get_mesa_program(struct gl_context *ctx,
>                                                prog->Parameters);
>
>     /* Remove reads from output registers. */
> -   lower_output_reads(shader->ir);
> +   lower_output_reads(shader->Stage, shader->ir);
>
>     /* Emit intermediate IR for main(). */
>     visit_exec_list(shader->ir, v);
> --
> 2.1.0
>


More information about the mesa-dev mailing list