diff options
Diffstat (limited to 'src/mesa/shader/program.c')
-rw-r--r-- | src/mesa/shader/program.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 18bebd227ab..daec9252fff 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -47,7 +47,7 @@ /** - * Init context's program state + * Init context's vertex/fragment program state */ void _mesa_init_program(GLcontext *ctx) @@ -80,6 +80,32 @@ _mesa_init_program(GLcontext *ctx) /** + * Free a context's vertex/fragment program state + */ +void +_mesa_free_program_data(GLcontext *ctx) +{ +#if FEATURE_NV_vertex_program + if (ctx->VertexProgram.Current) { + ctx->VertexProgram.Current->Base.RefCount--; + if (ctx->VertexProgram.Current->Base.RefCount <= 0) + ctx->Driver.DeleteProgram(ctx, &(ctx->VertexProgram.Current->Base)); + } +#endif +#if FEATURE_NV_fragment_program + if (ctx->FragmentProgram.Current) { + ctx->FragmentProgram.Current->Base.RefCount--; + if (ctx->FragmentProgram.Current->Base.RefCount <= 0) + ctx->Driver.DeleteProgram(ctx, &(ctx->FragmentProgram.Current->Base)); + } +#endif + _mesa_free((void *) ctx->Program.ErrorString); +} + + + + +/** * Set the vertex/fragment program error state (position and error string). * This is generally called from within the parsers. */ @@ -222,15 +248,16 @@ _mesa_delete_program(GLcontext *ctx, struct program *prog) struct vertex_program *vprog = (struct vertex_program *) prog; if (vprog->Instructions) _mesa_free(vprog->Instructions); + if (vprog->Parameters) + _mesa_free_parameter_list(vprog->Parameters); } else if (prog->Target == GL_FRAGMENT_PROGRAM_NV || prog->Target == GL_FRAGMENT_PROGRAM_ARB) { struct fragment_program *fprog = (struct fragment_program *) prog; if (fprog->Instructions) _mesa_free(fprog->Instructions); - if (fprog->Parameters) { + if (fprog->Parameters) _mesa_free_parameter_list(fprog->Parameters); - } } _mesa_free(prog); } |