glsl: remove interpolateAt* instructions for demoted inputs
authorMarek Olšák <marek.olsak@amd.com>
Fri, 9 Sep 2016 00:04:00 +0000 (02:04 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 16 Sep 2016 20:35:08 +0000 (22:35 +0200)
This fixes 8 fs-interpolateat* piglit crashes on radeonsi, because it can't
handle non-input operands in interpolateAt*.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/compiler/glsl/link_varyings.cpp
src/compiler/glsl/opt_algebraic.cpp

index 8c436c2f4401ffd237c63c897872c67300a6a8f0..e622b3e46bc8e06629b599ecd99a3c4d8b6aba09 100644 (file)
@@ -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;
       }
    }
index f5858c838654c508ec3335b24ecf0636d0ac5f9a..2829a78251427afa9f0c775bd0d1081066cac1ef 100644 (file)
@@ -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;
    }