[Mesa-dev] [PATCH] glsl: remove interpolateAt* instructions for demoted inputs
Connor Abbott
cwabbott0 at gmail.com
Mon Sep 12 14:05:33 UTC 2016
Since demoted inputs become global variables, wouldn't it be more
efficient to simply turn it into a straight assignment? Then the
backend wouldn't have to initialize it to a constant (since it would
be undefined).
On Fri, Sep 9, 2016 at 10:06 AM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> This fixes 8 fs-interpolateat* piglit crashes on radeonsi, because it can't
> handle non-input operands in interpolateAt*.
> ---
> src/compiler/glsl/link_varyings.cpp | 5 +++++
> src/compiler/glsl/opt_algebraic.cpp | 10 ++++++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
> index 1fad310..85ca044 100644
> --- a/src/compiler/glsl/link_varyings.cpp
> +++ b/src/compiler/glsl/link_varyings.cpp
> @@ -586,20 +586,25 @@ remove_unused_shader_inputs_and_outputs(bool is_separate_shader_object,
>
> if (var == NULL || var->data.mode != int(mode))
> continue;
>
> /* A shader 'in' or 'out' variable is only really an input or output if
> * its value is used by other shader stages. This will cause the
> * variable to have a location assigned.
> */
> if (var->data.is_unmatched_generic_inout && !var->data.is_xfb_only) {
> assert(var->data.mode != ir_var_temporary);
> +
> + /* Assign zeros to demoted inputs to allow more optimizations. */
> + if (var->data.mode == ir_var_shader_in && !var->constant_value)
> + var->constant_value = ir_constant::zero(var, var->type);
> +
> var->data.mode = ir_var_auto;
> }
> }
>
> /* Eliminate code that is now dead due to unused inputs/outputs being
> * demoted.
> */
> while (do_dead_code(sh->ir, false))
> ;
>
> diff --git a/src/compiler/glsl/opt_algebraic.cpp b/src/compiler/glsl/opt_algebraic.cpp
> index f5858c8..2829a78 100644
> --- a/src/compiler/glsl/opt_algebraic.cpp
> +++ b/src/compiler/glsl/opt_algebraic.cpp
> @@ -954,20 +954,30 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
> }
> break;
>
> case ir_triop_csel:
> if (is_vec_one(op_const[0]))
> return ir->operands[1];
> if (is_vec_zero(op_const[0]))
> return ir->operands[2];
> break;
>
> + /* Remove interpolateAt* instructions for demoted inputs. They are
> + * assigned a constant expression to facilitate this.
> + */
> + case ir_unop_interpolate_at_centroid:
> + case ir_binop_interpolate_at_offset:
> + case ir_binop_interpolate_at_sample:
> + if (op_const[0])
> + return ir->operands[0];
> + break;
> +
> default:
> break;
> }
>
> return ir;
> }
>
> void
> ir_algebraic_visitor::handle_rvalue(ir_rvalue **rvalue)
> {
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list