From ae0a4a1299f649ff550a0dfd59d60fc8b91df54f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 9 Sep 2016 02:04:00 +0200 Subject: [PATCH] glsl: remove interpolateAt* instructions for demoted inputs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This fixes 8 fs-interpolateat* piglit crashes on radeonsi, because it can't handle non-input operands in interpolateAt*. Reviewed-by: Nicolai Hähnle --- 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 8c436c2f440..e622b3e46bc 100644 --- a/src/compiler/glsl/link_varyings.cpp +++ b/src/compiler/glsl/link_varyings.cpp @@ -593,6 +593,11 @@ remove_unused_shader_inputs_and_outputs(bool is_separate_shader_object, */ 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; } } diff --git a/src/compiler/glsl/opt_algebraic.cpp b/src/compiler/glsl/opt_algebraic.cpp index f5858c83865..2829a782514 100644 --- a/src/compiler/glsl/opt_algebraic.cpp +++ b/src/compiler/glsl/opt_algebraic.cpp @@ -961,6 +961,16 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) 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; } -- 2.30.2