Mesa (glsl2): glsl2: Also steal the constant components of aggregate-typed ir_constants.

Eric Anholt anholt at kemper.freedesktop.org
Tue Jul 27 02:43:53 UTC 2010


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

Author: Eric Anholt <eric at anholt.net>
Date:   Mon Jul 26 19:26:53 2010 -0700

glsl2: Also steal the constant components of aggregate-typed ir_constants.

---

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

diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 2fd654e..6dccbd8 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -909,8 +909,26 @@ static void
 steal_memory(ir_instruction *ir, void *new_ctx)
 {
    ir_variable *var = ir->as_variable();
+   ir_constant *constant = ir->as_constant();
    if (var != NULL && var->constant_value != NULL)
       talloc_steal(ir, var->constant_value);
+
+   /* The components of aggregate constants are not visited by the normal
+    * visitor, so steal their values by hand.
+    */
+   if (constant != NULL) {
+      if (constant->type->is_record()) {
+	 foreach_iter(exec_list_iterator, iter, constant->components) {
+	    ir_constant *field = (ir_constant *)iter.get();
+	    steal_memory(field, ir);
+	 }
+      } else if (constant->type->is_array()) {
+	 for (unsigned int i = 0; i < constant->type->length; i++) {
+	    steal_memory(constant->array_elements[i], ir);
+	 }
+      }
+   }
+
    talloc_steal(new_ctx, ir);
 }
 




More information about the mesa-commit mailing list