Mesa (glsl2): glsl2: Add declarations for temporaries to instruction stream

Ian Romanick idr at kemper.freedesktop.org
Mon Jul 12 22:04:14 UTC 2010


Module: Mesa
Branch: glsl2
Commit: 0b9ae3befb0bf80e000b159fd44c961a144f9c36
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b9ae3befb0bf80e000b159fd44c961a144f9c36

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Mon Jul 12 14:22:05 2010 -0700

glsl2: Add declarations for temporaries to instruction stream

Temporary variables added for &&, ||, and ?: were not being added to
the instruction stream.  This resulted in either test failures or
Valgrind being angry after the original IR tree was destroyed by
talloc_free.  The talloc_free caused the ir_variables to be destroyed
even though they were still referenced.

---

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

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index e03bb63..a9ab17f 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -821,6 +821,7 @@ ast_expression::hir(exec_list *instructions,
 
 	 ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type,
 						       "and_tmp");
+	 instructions->push_tail(tmp);
 
 	 ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp);
 	 ir_assignment *const then_assign =
@@ -873,6 +874,7 @@ ast_expression::hir(exec_list *instructions,
 
 	 ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type,
 						       "or_tmp");
+	 instructions->push_tail(tmp);
 
 	 op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state);
 
@@ -1048,6 +1050,7 @@ ast_expression::hir(exec_list *instructions,
 	 result = (cond_val->value.b[0]) ? then_val : else_val;
       } else {
 	 ir_variable *const tmp = new(ctx) ir_variable(type, "conditional_tmp");
+	 instructions->push_tail(tmp);
 
 	 ir_if *const stmt = new(ctx) ir_if(op[0]);
 	 instructions->push_tail(stmt);




More information about the mesa-commit mailing list