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

Jason Ekstrand jason at jlekstrand.net
Tue Apr 12 22:46:22 UTC 2016


On Apr 12, 2016 2:08 PM, "Kenneth Graunke" <kenneth at whitecape.org> wrote:
>
> This is kind of a hack.  We currently track precise requirements
> by decorating ir_variables.  Propagating or grafting the RHS of an
> assignment to a precise value into some other expression tree can
> lose those decorations.
>
> 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.

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.

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

> 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.
>
> v2: Drop invariant handling, as it shouldn't be necessary (caught
>     by Jason Ekstrand).
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/compiler/glsl/opt_copy_propagation.cpp          | 3 ++-
>  src/compiler/glsl/opt_copy_propagation_elements.cpp | 3 +++
>  src/compiler/glsl/opt_tree_grafting.cpp             | 3 +++
>  3 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/src/compiler/glsl/opt_copy_propagation.cpp
b/src/compiler/glsl/opt_copy_propagation.cpp
> index 310708d..ae62921 100644
> --- a/src/compiler/glsl/opt_copy_propagation.cpp
> +++ b/src/compiler/glsl/opt_copy_propagation.cpp
> @@ -331,7 +331,8 @@ 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) {
>          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..e9e7c53 100644
> --- a/src/compiler/glsl/opt_copy_propagation_elements.cpp
> +++ b/src/compiler/glsl/opt_copy_propagation_elements.cpp
> @@ -493,6 +493,9 @@
ir_copy_propagation_elements_visitor::add_copy(ir_assignment *ir)
>        }
>     }
>
> +   if (lhs->var->data.precise != rhs->var->data.precise)
> +      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..a40e5f7 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)
> +         continue;
> +
>        ir_variable_refcount_entry *entry =
info->refs->get_variable_entry(lhs_var);
>
>        if (!entry->declaration ||
> --
> 2.8.0
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160412/24ceae89/attachment-0001.html>


More information about the mesa-dev mailing list