summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-08-18 12:02:35 -0700
committerEric Anholt <[email protected]>2010-08-18 14:16:07 -0700
commit5d0f430e8ed01db29d11d22e4b6c3760d8c39f8f (patch)
treeb36d56d5d4ad7638570b8dd0f5da3df1a0b3a266 /src/glsl
parent0b09e6410f1173c2f69b601e43c5b14d8ad97345 (diff)
mesa: Free old linked shaders when relinking new shaders.
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/linker.cpp15
-rw-r--r--src/glsl/main.cpp6
-rw-r--r--src/glsl/program.h2
3 files changed, 16 insertions, 7 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);