<p dir="ltr"><br>
On Apr 12, 2016 2:08 PM, "Kenneth Graunke" <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>> wrote:<br>
><br>
> This is kind of a hack.  We currently track precise requirements<br>
> by decorating ir_variables.  Propagating or grafting the RHS of an<br>
> assignment to a precise value into some other expression tree can<br>
> lose those decorations.<br>
><br>
> In the long run, it might be better to replace these ir_variable<br>
> decorations with an "exact" decoration on ir_expression nodes,<br>
> similar to what NIR does.</p>
<p dir="ltr">I'm personally of the opinion that this patch is actually the right thing to do given the tree nature of GLSL IR.  Perhaps I'll be convinced otherwise some day.</p>
<p dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></p>
<p dir="ltr">> In the short run, this is probably good enough.  It preserves<br>
> enough information for glsl_to_nir to generate "exact" decorations,<br>
> and NIR will then handle optimizing these expressions reasonably.<br>
><br>
> Fixes ES31-CTS.gpu_shader5.precise_qualifier.<br>
><br>
> v2: Drop invariant handling, as it shouldn't be necessary (caught<br>
>     by Jason Ekstrand).<br>
><br>
> Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
> ---<br>
>  src/compiler/glsl/opt_copy_propagation.cpp          | 3 ++-<br>
>  src/compiler/glsl/opt_copy_propagation_elements.cpp | 3 +++<br>
>  src/compiler/glsl/opt_tree_grafting.cpp             | 3 +++<br>
>  3 files changed, 8 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/src/compiler/glsl/opt_copy_propagation.cpp b/src/compiler/glsl/opt_copy_propagation.cpp<br>
> index 310708d..ae62921 100644<br>
> --- a/src/compiler/glsl/opt_copy_propagation.cpp<br>
> +++ b/src/compiler/glsl/opt_copy_propagation.cpp<br>
> @@ -331,7 +331,8 @@ ir_copy_propagation_visitor::add_copy(ir_assignment *ir)<br>
>          ir->condition = new(ralloc_parent(ir)) ir_constant(false);<br>
>          this->progress = true;<br>
>        } else if (lhs_var->data.mode != ir_var_shader_storage &&<br>
> -                 lhs_var->data.mode != ir_var_shader_shared) {<br>
> +                 lhs_var->data.mode != ir_var_shader_shared &&<br>
> +                 lhs_var->data.precise == rhs_var->data.precise) {<br>
>          entry = new(this->acp) acp_entry(lhs_var, rhs_var);<br>
>          this->acp->push_tail(entry);<br>
>        }<br>
> diff --git a/src/compiler/glsl/opt_copy_propagation_elements.cpp b/src/compiler/glsl/opt_copy_propagation_elements.cpp<br>
> index a679180..e9e7c53 100644<br>
> --- a/src/compiler/glsl/opt_copy_propagation_elements.cpp<br>
> +++ b/src/compiler/glsl/opt_copy_propagation_elements.cpp<br>
> @@ -493,6 +493,9 @@ ir_copy_propagation_elements_visitor::add_copy(ir_assignment *ir)<br>
>        }<br>
>     }<br>
><br>
> +   if (lhs->var->data.precise != rhs->var->data.precise)<br>
> +      return;<br>
> +<br>
>     entry = new(this->mem_ctx) acp_entry(lhs->var, rhs->var, write_mask,<br>
>                                         swizzle);<br>
>     this->acp->push_tail(entry);<br>
> diff --git a/src/compiler/glsl/opt_tree_grafting.cpp b/src/compiler/glsl/opt_tree_grafting.cpp<br>
> index 812f996..a40e5f7 100644<br>
> --- a/src/compiler/glsl/opt_tree_grafting.cpp<br>
> +++ b/src/compiler/glsl/opt_tree_grafting.cpp<br>
> @@ -368,6 +368,9 @@ tree_grafting_basic_block(ir_instruction *bb_first,<br>
>            lhs_var->data.mode == ir_var_shader_shared)<br>
>           continue;<br>
><br>
> +      if (lhs_var->data.precise)<br>
> +         continue;<br>
> +<br>
>        ir_variable_refcount_entry *entry = info->refs->get_variable_entry(lhs_var);<br>
><br>
>        if (!entry->declaration ||<br>
> --<br>
> 2.8.0<br>
><br>
</p>