[Mesa-dev] [PATCH] glsl: Don't copy propagate or tree graft precise/invariant values.

Jason Ekstrand jason at jlekstrand.net
Mon Apr 4 01:34:51 UTC 2016


On Sun, Apr 3, 2016 at 5:36 PM, Kenneth Graunke <kenneth at whitecape.org>
wrote:

> This is kind of a hack.  We currently track precise/invariant
> requirements by decorating ir_variables.  Propagating or grafting
> the RHS of an assignment to a precise/invariant value into some
> other expression tree can lose those decorations.
>

I don't think this is needed for "invariant".  The "invariant" qualifier
can only be applied to outputs and we propagate it to everything used by
that output so I don't think copy-prop or tree grafting can ever move an
invariant thing into a non-invariant one.  For "precise", this probably is
needed.

One other place we may need to be careful with "invariant" and "precise" is
channel expressions.  I'm not 100% sure how that pass works, but if it
creates new variables, we need to propagate the qualifiers to them.


> In the long run, it might be better to replace these ir_variable
> decorations with an "exact" decoration on ir_expression nodes,
> similar to what NIR does.
>
> In the short run, this is probably good enough.  It preserves
> enough information for glsl_to_nir to generate "exact" decorations,
> and NIR will then handle optimizing these expressions reasonably.
>
> Fixes ES31-CTS.gpu_shader5.precise_qualifier.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/compiler/glsl/opt_copy_propagation.cpp          | 4 +++-
>  src/compiler/glsl/opt_copy_propagation_elements.cpp | 4 ++++
>  src/compiler/glsl/opt_tree_grafting.cpp             | 3 +++
>  3 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/src/compiler/glsl/opt_copy_propagation.cpp
> b/src/compiler/glsl/opt_copy_propagation.cpp
> index 310708d..ea7fed8 100644
> --- a/src/compiler/glsl/opt_copy_propagation.cpp
> +++ b/src/compiler/glsl/opt_copy_propagation.cpp
> @@ -331,7 +331,9 @@ ir_copy_propagation_visitor::add_copy(ir_assignment
> *ir)
>          ir->condition = new(ralloc_parent(ir)) ir_constant(false);
>          this->progress = true;
>        } else if (lhs_var->data.mode != ir_var_shader_storage &&
> -                 lhs_var->data.mode != ir_var_shader_shared) {
> +                 lhs_var->data.mode != ir_var_shader_shared &&
> +                 lhs_var->data.precise == rhs_var->data.precise &&
> +                 lhs_var->data.invariant == rhs_var->data.invariant) {
>          entry = new(this->acp) acp_entry(lhs_var, rhs_var);
>          this->acp->push_tail(entry);
>        }
> diff --git a/src/compiler/glsl/opt_copy_propagation_elements.cpp
> b/src/compiler/glsl/opt_copy_propagation_elements.cpp
> index a679180..b1f995a 100644
> --- a/src/compiler/glsl/opt_copy_propagation_elements.cpp
> +++ b/src/compiler/glsl/opt_copy_propagation_elements.cpp
> @@ -493,6 +493,10 @@
> ir_copy_propagation_elements_visitor::add_copy(ir_assignment *ir)
>        }
>     }
>
> +   if (lhs->var->data.precise != rhs->var->data.precise ||
> +       lhs->var->data.invariant != rhs->var->data.invariant)
> +      return;
> +
>     entry = new(this->mem_ctx) acp_entry(lhs->var, rhs->var, write_mask,
>                                         swizzle);
>     this->acp->push_tail(entry);
> diff --git a/src/compiler/glsl/opt_tree_grafting.cpp
> b/src/compiler/glsl/opt_tree_grafting.cpp
> index 812f996..8913102 100644
> --- a/src/compiler/glsl/opt_tree_grafting.cpp
> +++ b/src/compiler/glsl/opt_tree_grafting.cpp
> @@ -368,6 +368,9 @@ tree_grafting_basic_block(ir_instruction *bb_first,
>            lhs_var->data.mode == ir_var_shader_shared)
>           continue;
>
> +      if (lhs_var->data.precise || lhs_var->data.invariant)
> +         continue;
> +
>        ir_variable_refcount_entry *entry =
> info->refs->get_variable_entry(lhs_var);
>
>        if (!entry->declaration ||
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160403/49e24408/attachment.html>


More information about the mesa-dev mailing list