glsl2: Steal the live IR and free the rest of the junk.
This commit is contained in:

committed by
Ian Romanick

parent
ef5f194831
commit
116f1d4f95
@@ -99,6 +99,12 @@ const struct option compiler_opts[] = {
|
|||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
steal_memory(ir_instruction *ir, void *new_ctx)
|
||||||
|
{
|
||||||
|
talloc_steal(new_ctx, ir);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
compile_shader(struct gl_shader *shader)
|
compile_shader(struct gl_shader *shader)
|
||||||
{
|
{
|
||||||
@@ -187,6 +193,11 @@ compile_shader(struct gl_shader *shader)
|
|||||||
|
|
||||||
shader->InfoLog = state->info_log;
|
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);
|
talloc_free(state);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@@ -1650,6 +1650,12 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader)
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
static void
|
||||||
|
steal_memory(ir_instruction *ir, void *new_ctx)
|
||||||
|
{
|
||||||
|
talloc_steal(new_ctx, ir);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
|
_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->CompileStatus = !state->error;
|
||||||
shader->InfoLog = state->info_log;
|
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);
|
talloc_free(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user