diff options
author | Eric Anholt <[email protected]> | 2010-08-18 12:02:35 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2010-08-18 14:16:07 -0700 |
commit | 5d0f430e8ed01db29d11d22e4b6c3760d8c39f8f (patch) | |
tree | b36d56d5d4ad7638570b8dd0f5da3df1a0b3a266 /src | |
parent | 0b09e6410f1173c2f69b601e43c5b14d8ad97345 (diff) |
mesa: Free old linked shaders when relinking new shaders.
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/linker.cpp | 15 | ||||
-rw-r--r-- | src/glsl/main.cpp | 6 | ||||
-rw-r--r-- | src/glsl/program.h | 2 | ||||
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 2 |
4 files changed, 17 insertions, 8 deletions
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 4172e419105..b2565744462 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -674,7 +674,8 @@ get_main_function_signature(gl_shader *sh) * shader is returned. */ static struct gl_shader * -link_intrastage_shaders(struct gl_shader_program *prog, +link_intrastage_shaders(GLcontext *ctx, + struct gl_shader_program *prog, struct gl_shader **shader_list, unsigned num_shaders) { @@ -747,7 +748,7 @@ link_intrastage_shaders(struct gl_shader_program *prog, return NULL; } - gl_shader *const linked = _mesa_new_shader(NULL, 0, main->Type); + gl_shader *const linked = ctx->Driver.NewShader(NULL, 0, main->Type); linked->ir = new(linked) exec_list; clone_ir_list(linked, linked->ir, main->ir); @@ -1212,7 +1213,7 @@ assign_varying_locations(struct gl_shader_program *prog, void -link_shaders(struct gl_shader_program *prog) +link_shaders(GLcontext *ctx, struct gl_shader_program *prog) { prog->LinkStatus = false; prog->Validated = false; @@ -1270,12 +1271,16 @@ link_shaders(struct gl_shader_program *prog) prog->Version = max_version; + for (unsigned int i = 0; i < prog->_NumLinkedShaders; i++) { + ctx->Driver.DeleteShader(ctx, prog->_LinkedShaders[i]); + } + /* Link all shaders for a particular stage and validate the result. */ prog->_NumLinkedShaders = 0; if (num_vert_shaders > 0) { gl_shader *const sh = - link_intrastage_shaders(prog, vert_shader_list, num_vert_shaders); + link_intrastage_shaders(ctx, prog, vert_shader_list, num_vert_shaders); if (sh == NULL) goto done; @@ -1289,7 +1294,7 @@ link_shaders(struct gl_shader_program *prog) if (num_frag_shaders > 0) { gl_shader *const sh = - link_intrastage_shaders(prog, frag_shader_list, num_frag_shaders); + link_intrastage_shaders(ctx, prog, frag_shader_list, num_frag_shaders); if (sh == NULL) goto done; diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 24d6076d07b..cb9f8a52773 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -209,6 +209,10 @@ int main(int argc, char **argv) { int status = EXIT_SUCCESS; + GLcontext local_ctx; + GLcontext *ctx = &local_ctx; + + ctx->Driver.NewShader = _mesa_new_shader; int c; int idx = 0; @@ -265,7 +269,7 @@ main(int argc, char **argv) } if ((status == EXIT_SUCCESS) && do_link) { - link_shaders(whole_program); + link_shaders(ctx, whole_program); status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE; if (strlen(whole_program->InfoLog) > 0) diff --git a/src/glsl/program.h b/src/glsl/program.h index 0a49203d4b2..ea2c4ab0dda 100644 --- a/src/glsl/program.h +++ b/src/glsl/program.h @@ -30,4 +30,4 @@ extern "C" { } extern void -link_shaders(struct gl_shader_program *prog); +link_shaders(GLcontext *ctx, struct gl_shader_program *prog); diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 4f4994392dd..394370d46d4 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2740,7 +2740,7 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) _mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL); if (prog->LinkStatus) { - link_shaders(prog); + link_shaders(ctx, prog); /* We don't use the linker's uniforms list, and cook up our own at * generate time. |