[Mesa-dev] [PATCH] glsl: Avoid delaying output write when there is no output read

Ian Romanick idr at freedesktop.org
Thu Feb 23 09:19:06 PST 2012


On 02/23/2012 06:46 AM, Vincent Lejeune wrote:

Can you provide some analysis as to why this fixes the problem?  That 
information should be captured in the commit message.  As far as I can 
tell, this just prevents the LHS of the assignment from being visited, 
and it's not obvious how that solves the problem.  Also, what happens if 
the LHS involves an array access using an output as the index?  For example,

#version 130
out int i;
out vec4 v[4];

in int j;
uniform vec4 d;

void main()
{
     i = j;
     v[i] = d;
}

It seems like this will skip lowering the read of i in the LHS.

> This fix bug #46004

Please format this as

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=46004

> ---
>   src/glsl/lower_output_reads.cpp |    8 ++++++++
>   1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/src/glsl/lower_output_reads.cpp b/src/glsl/lower_output_reads.cpp
> index 415b541..119d45a 100644
> --- a/src/glsl/lower_output_reads.cpp
> +++ b/src/glsl/lower_output_reads.cpp
> @@ -52,6 +52,7 @@ public:
>      virtual ir_visitor_status visit(class ir_dereference_variable *);
>      virtual ir_visitor_status visit_leave(class ir_return *);
>      virtual ir_visitor_status visit_leave(class ir_function_signature *);
> +   virtual ir_visitor_status visit_enter(ir_assignment *ir);
>   };
>
>   output_read_remover::output_read_remover()
> @@ -68,6 +69,13 @@ output_read_remover::~output_read_remover()
>   }
>
>   ir_visitor_status
> +output_read_remover::visit_enter(ir_assignment *ir)
> +{
> +   ir->rhs->accept(this);
> +   return visit_continue_with_parent;
> +}
> +
> +ir_visitor_status
>   output_read_remover::visit(ir_dereference_variable *ir)
>   {
>      if (ir->var->mode != ir_var_out)



More information about the mesa-dev mailing list