Mesa (glsl2): glsl2: Steal the live IR and free the rest of the junk.
Ian Romanick
idr at kemper.freedesktop.org
Wed Jun 30 20:56:40 UTC 2010
Module: Mesa
Branch: glsl2
Commit: 116f1d4f95d8eb0a82b272016590549632c865b3
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=116f1d4f95d8eb0a82b272016590549632c865b3
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Fri Jun 25 14:10:01 2010 -0700
glsl2: Steal the live IR and free the rest of the junk.
---
src/glsl/main.cpp | 11 +++++++++++
src/mesa/shader/ir_to_mesa.cpp | 11 +++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
index 1ed22e1..8b2eeaa 100644
--- a/src/glsl/main.cpp
+++ b/src/glsl/main.cpp
@@ -99,6 +99,12 @@ const struct option compiler_opts[] = {
{ NULL, 0, NULL, 0 }
};
+static void
+steal_memory(ir_instruction *ir, void *new_ctx)
+{
+ talloc_steal(new_ctx, ir);
+}
+
void
compile_shader(struct gl_shader *shader)
{
@@ -187,6 +193,11 @@ compile_shader(struct gl_shader *shader)
shader->InfoLog = state->info_log;
+ /* Retain any live IR, but trash the rest. */
+ foreach_list(node, shader->ir) {
+ visit_tree((ir_instruction *) node, steal_memory, shader);
+ }
+
talloc_free(state);
return;
diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp
index 75021a7..c3de3aa 100644
--- a/src/mesa/shader/ir_to_mesa.cpp
+++ b/src/mesa/shader/ir_to_mesa.cpp
@@ -1650,6 +1650,12 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader)
extern "C" {
+static void
+steal_memory(ir_instruction *ir, void *new_ctx)
+{
+ talloc_steal(new_ctx, ir);
+}
+
void
_mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
{
@@ -1712,6 +1718,11 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
shader->CompileStatus = !state->error;
shader->InfoLog = state->info_log;
+ /* Retain any live IR, but trash the rest. */
+ foreach_list(node, shader->ir) {
+ visit_tree((ir_instruction *) node, steal_memory, shader);
+ }
+
talloc_free(state);
}
More information about the mesa-commit
mailing list