glsl2: Don't mark a variable as constant if it was used as an out param.
authorEric Anholt <eric@anholt.net>
Tue, 20 Jul 2010 21:21:43 +0000 (14:21 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 20 Jul 2010 22:59:04 +0000 (15:59 -0700)
src/glsl/ir_constant_variable.cpp

index ef5e1e418e54071010e2bd3dd917796b0437ef80..c5ccd52e5db3aaa001aa4379d752f696153fba8a 100644 (file)
@@ -47,6 +47,7 @@ struct assignment_entry {
 class ir_constant_variable_visitor : public ir_hierarchical_visitor {
 public:
    virtual ir_visitor_status visit_enter(ir_assignment *);
+   virtual ir_visitor_status visit_enter(ir_call *);
 
    exec_list list;
 };
@@ -107,6 +108,28 @@ ir_constant_variable_visitor::visit_enter(ir_assignment *ir)
    return visit_continue;
 }
 
+ir_visitor_status
+ir_constant_variable_visitor::visit_enter(ir_call *ir)
+{
+   exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator();
+   foreach_iter(exec_list_iterator, iter, *ir) {
+      ir_rvalue *param_rval = (ir_rvalue *)iter.get();
+      ir_variable *param = (ir_variable *)sig_iter.get();
+
+      if (param->mode == ir_var_out ||
+         param->mode == ir_var_inout) {
+        ir_variable *var = param_rval->variable_referenced();
+        struct assignment_entry *entry;
+
+        assert(var);
+        entry = get_assignment_entry(var, &this->list);
+        entry->assignment_count++;
+      }
+      sig_iter.next();
+   }
+   return visit_continue;
+}
+
 /**
  * Does a copy propagation pass on the code present in the instruction stream.
  */