summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-03-22 10:29:30 -0600
committerBrian <[email protected]>2008-03-22 10:29:30 -0600
commita35c1ca3ad4361fee30d21ef13d8d37ae91aee66 (patch)
tree43b21696c8f9c811d148e3a4c0b12f75201b2673 /src/mesa
parentf8acc3965e3fa9ec40ca63f3ddd0cb33966e8c95 (diff)
gallium: fix a few more shader-related mem leaks
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_atom_shader.c43
-rw-r--r--src/mesa/state_tracker/st_atom_shader.h6
-rw-r--r--src/mesa/state_tracker/st_cb_program.c28
-rw-r--r--src/mesa/state_tracker/st_program.c10
4 files changed, 45 insertions, 42 deletions
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index 07266884930..ec39026eb32 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -78,34 +78,6 @@ struct translated_vertex_program
/**
- * Free data hanging off the st vert prog.
- */
-void
-st_remove_vertex_program(struct st_context *st, struct st_vertex_program *stvp)
-{
- /* no-op, for now? */
-}
-
-
-/**
- * Free data hanging off the st frag prog.
- */
-void
-st_remove_fragment_program(struct st_context *st,
- struct st_fragment_program *stfp)
-{
- struct translated_vertex_program *xvp, *next;
-
- for (xvp = stfp->vertex_programs; xvp; xvp = next) {
- next = xvp->next;
- /* XXX free xvp->vs */
- free(xvp);
- }
-}
-
-
-
-/**
* Given a vertex program output attribute, return the corresponding
* fragment program input attribute.
* \return -1 for vertex outputs that have no corresponding fragment input
@@ -265,6 +237,21 @@ find_translated_vp(struct st_context *st,
}
+void
+st_free_translated_vertex_programs(struct st_context *st,
+ struct translated_vertex_program *xvp)
+{
+ struct translated_vertex_program *next;
+
+ while (xvp) {
+ next = xvp->next;
+ free(xvp);
+ xvp = next;
+ }
+}
+
+
+
static void
update_linkage( struct st_context *st )
{
diff --git a/src/mesa/state_tracker/st_atom_shader.h b/src/mesa/state_tracker/st_atom_shader.h
index f3124d87c01..8403bc66c92 100644
--- a/src/mesa/state_tracker/st_atom_shader.h
+++ b/src/mesa/state_tracker/st_atom_shader.h
@@ -31,10 +31,8 @@
extern void
-st_remove_vertex_program(struct st_context *, struct st_vertex_program *);
-
-extern void
-st_remove_fragment_program(struct st_context *, struct st_fragment_program *);
+st_free_translated_vertex_programs(struct st_context *st,
+ struct translated_vertex_program *xvp);
#endif /* ST_ATOM_SHADER_H */
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 7cf352d710b..a739fcd3362 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -132,25 +132,33 @@ static void st_delete_program( GLcontext *ctx,
case GL_VERTEX_PROGRAM_ARB:
{
struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
- st_remove_vertex_program(st, stvp);
+
if (stvp->driver_shader) {
pipe->delete_vs_state(pipe, stvp->driver_shader);
stvp->driver_shader = NULL;
}
+
+ if (stvp->state.tokens) {
+ FREE((void *) stvp->state.tokens);
+ stvp->state.tokens = NULL;
+ }
}
break;
case GL_FRAGMENT_PROGRAM_ARB:
{
- struct st_fragment_program *stfp
- = (struct st_fragment_program *) prog;
- st_remove_fragment_program(st, stfp);
+ struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
+
if (stfp->driver_shader) {
pipe->delete_fs_state(pipe, stfp->driver_shader);
stfp->driver_shader = NULL;
}
+
+ if (stfp->state.tokens) {
+ FREE((void *) stfp->state.tokens);
+ stfp->state.tokens = NULL;
+ }
- assert(!stfp->vertex_programs);
-
+ st_free_translated_vertex_programs(st, stfp->vertex_programs);
}
break;
default:
@@ -186,13 +194,13 @@ static void st_program_string_notify( GLcontext *ctx,
stfp->driver_shader = NULL;
}
- stfp->param_state = stfp->Base.Base.Parameters->StateFlags;
-
if (stfp->state.tokens) {
FREE((void *) stfp->state.tokens);
stfp->state.tokens = NULL;
}
+ stfp->param_state = stfp->Base.Base.Parameters->StateFlags;
+
if (st->fp == stfp)
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
}
@@ -211,13 +219,13 @@ static void st_program_string_notify( GLcontext *ctx,
stvp->draw_shader = NULL;
}
- stvp->param_state = stvp->Base.Base.Parameters->StateFlags;
-
if (stvp->state.tokens) {
FREE((void *) stvp->state.tokens);
stvp->state.tokens = NULL;
}
+ stvp->param_state = stvp->Base.Base.Parameters->StateFlags;
+
if (st->vp == stvp)
st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
}
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index d9d11ee0e84..101a6a48afd 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -260,6 +260,16 @@ st_translate_vertex_program(struct st_context *st,
outputMapping = defaultOutputMapping;
}
+ /* free old shader state, if any */
+ if (stvp->state.tokens) {
+ FREE((void *) stvp->state.tokens);
+ stvp->state.tokens = NULL;
+ }
+ if (stvp->driver_shader) {
+ pipe->delete_vs_state(pipe, stvp->driver_shader);
+ stvp->driver_shader = NULL;
+ }
+
/* XXX: fix static allocation of tokens:
*/
num_tokens = tgsi_translate_mesa_program( TGSI_PROCESSOR_VERTEX,