diff options
Diffstat (limited to 'src/glsl')
-rw-r--r-- | src/glsl/ir.cpp | 15 | ||||
-rw-r--r-- | src/glsl/ir.h | 3 | ||||
-rw-r--r-- | src/glsl/main.cpp | 10 |
3 files changed, 19 insertions, 9 deletions
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 146ff17af3..a2732962f0 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -875,3 +875,18 @@ visit_exec_list(exec_list *list, ir_visitor *visitor) } } + +static void +steal_memory(ir_instruction *ir, void *new_ctx) +{ + talloc_steal(new_ctx, ir); +} + + +void +reparent_ir(exec_list *list, void *mem_ctx) +{ + foreach_list(node, list) { + visit_tree((ir_instruction *) node, steal_memory, mem_ctx); + } +} diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 9fd9850391..e4b0e9f082 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1315,4 +1315,7 @@ extern void _mesa_glsl_initialize_functions(exec_list *instructions, struct _mesa_glsl_parse_state *state); +extern void +reparent_ir(exec_list *list, void *mem_ctx); + #endif /* IR_H */ diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 6b1a01c704..cf9a515785 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -118,12 +118,6 @@ 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) { @@ -232,9 +226,7 @@ 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); - } + reparent_ir(shader->ir, shader); talloc_free(state); |