diff options
author | Timothy Arceri <[email protected]> | 2016-11-17 12:26:08 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2016-11-19 07:42:33 +1100 |
commit | 2b8f97d0ff0836b1d1c8753a81a8810df385b21d (patch) | |
tree | 1b26f511a4477c78ee2fab6a57116f7dc24af60a /src/mesa/state_tracker | |
parent | 9db5cc829f6bd7ba09f3bf0bf057b7162d05d037 (diff) |
st/mesa/i965: simplify gl_program references and stop leaking
In i965 we were calling _mesa_reference_program() after creating
gl_program and then later calling it again with NULL as a param
to get the refcount back down to 1. This changes things to not
use _mesa_reference_program() at all and just have gl_linked_shader
take ownership of gl_program since refcount starts at 1.
The st and ir_to_mesa linkers were worse as they were both getting
in a state were the refcount would never get to 0 and we would leak
the program.
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_nir.cpp | 3 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 9 |
2 files changed, 5 insertions, 7 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 36531ad3047..2d8cf81dcce 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -375,7 +375,8 @@ st_nir_get_mesa_program(struct gl_context *ctx, if (!prog) return NULL; - _mesa_reference_program(ctx, &shader->Program, prog); + /* Don't use _mesa_reference_program() just take ownership */ + shader->Program = prog; prog->Parameters = _mesa_new_parameter_list(); diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 7d67a598f0a..b47e1470e3f 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -6419,7 +6419,8 @@ get_mesa_program_tgsi(struct gl_context *ctx, if (!prog) return NULL; - _mesa_reference_program(ctx, &shader->Program, prog); + /* Don't use _mesa_reference_program() just take ownership */ + shader->Program = prog; prog->Parameters = _mesa_new_parameter_list(); v = new glsl_to_tgsi_visitor(); @@ -6541,6 +6542,7 @@ get_mesa_program_tgsi(struct gl_context *ctx, _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters); if (!shader_program->LinkStatus) { free_glsl_to_tgsi_visitor(v); + _mesa_reference_program(ctx, &shader->Program, NULL); return NULL; } @@ -6883,19 +6885,14 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]); if (linked_prog) { - _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program, - linked_prog); if (!ctx->Driver.ProgramStringNotify(ctx, _mesa_shader_stage_to_program(i), linked_prog)) { _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program, NULL); - _mesa_reference_program(ctx, &linked_prog, NULL); return GL_FALSE; } } - - _mesa_reference_program(ctx, &linked_prog, NULL); } return GL_TRUE; |