mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 17:58:26 +02:00
glsl2: Implement utility routine to talloc reparent an IR tree
This commit is contained in:
parent
2462a536ea
commit
60e2d06d1c
4 changed files with 20 additions and 18 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -2146,12 +2146,6 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program,
|
|||
|
||||
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)
|
||||
{
|
||||
|
|
@ -2215,9 +2209,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
|
|||
shader->Version = state->language_version;
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue