glsl2: Fix the dereferences_variable check in ir_tree_grafting.
authorEric Anholt <eric@anholt.net>
Thu, 5 Aug 2010 19:52:29 +0000 (12:52 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 5 Aug 2010 19:56:03 +0000 (12:56 -0700)
The HV doesn't descend into ir_variable, which is generally a good
thing (allowing one to distinguish between variable declarations and
refs), but here we never saw tree grafting opportunities killed
because we were looking for the ir_variable child of a dereference to
get visited.

Fixes:
glsl1-function call with inout params

src/glsl/ir_tree_grafting.cpp

index 1a742f412cb8f7f84ecf23044adfc48a00172ffd..e80db31cb3014bb1d559110c21ab1424535b92ff 100644 (file)
@@ -92,8 +92,9 @@ void
 dereferences_variable_callback(ir_instruction *ir, void *data)
 {
    struct find_deref_info *info = (struct find_deref_info *)data;
+   ir_dereference_variable *deref = ir->as_dereference_variable();
 
-   if (ir == info->var)
+   if (deref && deref->var == info->var)
       info->found = true;
 }
 
@@ -123,7 +124,7 @@ ir_tree_grafting_visitor::do_graft(ir_rvalue **rvalue)
 
    if (debug) {
       printf("GRAFTING:\n");
-      this->graft_assign->rhs->print();
+      this->graft_assign->print();
       printf("\n");
       printf("TO:\n");
       (*rvalue)->print();