glsl2: Flatten expression that appear as the parameters of ir_call as well.
authorEric Anholt <eric@anholt.net>
Tue, 13 Jul 2010 02:50:01 +0000 (19:50 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 13 Jul 2010 02:50:49 +0000 (19:50 -0700)
src/glsl/ir_expression_flattening.cpp

index 66268a679d9ff222f5cac9e8e7257ac0c8f52747..f18659342f5bcabed8207a8c3ab22749e2cdbaa5 100644 (file)
@@ -165,11 +165,18 @@ ir_expression_flattening_visitor::visit_leave(ir_swizzle *ir)
 ir_visitor_status
 ir_expression_flattening_visitor::visit_enter(ir_call *ir)
 {
-   /* FINISHME: Why not process the call parameters? (Same behavior as original
-    * FINISHME: code.)
-    */
-   (void) ir;
-   return visit_continue_with_parent;
+   /* Reminder: iterating ir_call iterates its parameters. */
+   foreach_iter(exec_list_iterator, iter, *ir) {
+      ir_rvalue *ir = (ir_rvalue *)iter.get();
+      ir_rvalue *new_ir = operand_to_temp(ir);
+
+      if (new_ir != ir) {
+        ir->insert_before(new_ir);
+        ir->remove();
+      }
+   }
+
+   return visit_continue;
 }