-/**
- * 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.
}
+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 )
{
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:
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;
}
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;
}
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,