[Mesa-dev] [PATCH 1/3] glsl/lower_output_reads: fix geometry shader output handling with conditional emit

Edward O'Callaghan funfunctor at folklore1984.net
Fri Nov 18 00:24:59 UTC 2016


Patches 1 & 3 are,
Reviewed-by: Edward O'Callaghan <funfunctor at folklore1984.net>
and patch 2 is,
Acked-by: Edward O'Callaghan <funfunctor at folklore1984.net>

On 11/18/2016 09:00 AM, Nicolai Hähnle wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
> 
> Consider a geometry shader that contains code like this:
> 
>    some_out = expr;
> 
>    if (cond) {
>       ...
>       EmitVertex();
>    } else {
>       ...
>       EmitVertex();
>    }
> 
> Both branches should see the correct value of some_out.
> 
> Since this is a rather subtle and rare case, I'm submitting a piglit test
> for this as well.
> 
> GLSL says that the values of output variables are undefined after
> EmitVertex(). With this change, the values will now be defined and
> unmodified. This may reduce optimization opportunities in the probably
> quite rare case where subsequent compiler passes cannot prove that the
> value of the output variable is overwritten.
> 
> Cc: 13.0 <mesa-stable at lists.freedesktop.org>
> ---
>  src/compiler/glsl/lower_output_reads.cpp | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/src/compiler/glsl/lower_output_reads.cpp b/src/compiler/glsl/lower_output_reads.cpp
> index 732f4d3..8a375ac 100644
> --- a/src/compiler/glsl/lower_output_reads.cpp
> +++ b/src/compiler/glsl/lower_output_reads.cpp
> @@ -150,21 +150,20 @@ ir_visitor_status
>  output_read_remover::visit_leave(ir_return *ir)
>  {
>     hash_table_call_foreach(replacements, emit_return_copy, ir);
>     return visit_continue;
>  }
>  
>  ir_visitor_status
>  output_read_remover::visit_leave(ir_emit_vertex *ir)
>  {
>     hash_table_call_foreach(replacements, emit_return_copy, ir);
> -   _mesa_hash_table_clear(replacements, NULL);
>     return visit_continue;
>  }
>  
>  ir_visitor_status
>  output_read_remover::visit_leave(ir_function_signature *sig)
>  {
>     if (strcmp(sig->function_name(), "main") != 0)
>        return visit_continue;
>  
>     hash_table_call_foreach(replacements, emit_main_copy, sig);
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161118/cb5e72b1/attachment.sig>


More information about the mesa-dev mailing list