Mesa (master): glsl: Don' t constant-fold in a constant in place of a function outval.

Eric Anholt anholt at kemper.freedesktop.org
Sun Aug 22 18:35:18 PDT 2010


Module: Mesa
Branch: master
Commit: 428a3cd2d537a42c8a01765a5a53dca139e07443
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=428a3cd2d537a42c8a01765a5a53dca139e07443

Author: Eric Anholt <eric at anholt.net>
Date:   Sun Aug 22 18:26:42 2010 -0700

glsl: Don't constant-fold in a constant in place of a function outval.

---

 src/glsl/ir_constant_folding.cpp |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ir_constant_folding.cpp b/src/glsl/ir_constant_folding.cpp
index 90135b5..5d77093 100644
--- a/src/glsl/ir_constant_folding.cpp
+++ b/src/glsl/ir_constant_folding.cpp
@@ -49,6 +49,7 @@ public:
    }
 
    virtual ir_visitor_status visit_enter(ir_assignment *ir);
+   virtual ir_visitor_status visit_enter(ir_call *ir);
 
    virtual void handle_rvalue(ir_rvalue **rvalue);
 
@@ -100,6 +101,27 @@ ir_constant_folding_visitor::visit_enter(ir_assignment *ir)
    return visit_continue_with_parent;
 }
 
+ir_visitor_status
+ir_constant_folding_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 *sig_param = (ir_variable *)sig_iter.get();
+
+      if (sig_param->mode == ir_var_in) {
+	 ir_rvalue *new_param = param_rval;
+
+	 handle_rvalue(&new_param);
+	 if (new_param != param_rval) {
+	    param_rval->replace_with(new_param);
+	 }
+      }
+   }
+
+   return visit_continue_with_parent;
+}
+
 bool
 do_constant_folding(exec_list *instructions)
 {



More information about the mesa-commit mailing list