summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-05-14 12:10:45 -0600
committerBrian Paul <[email protected]>2008-05-14 12:11:17 -0600
commit57e222d6e5ef5744491d093475e1136aedf81810 (patch)
tree1c6af771d12b6be91a20649ecb46b4bea8b4d319 /src/mesa/shader
parent4b7d301c94d33394550322768a9d2232087b2d64 (diff)
fix some additional program refcounting bugs
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/program.c25
-rw-r--r--src/mesa/shader/shader_api.c6
-rw-r--r--src/mesa/shader/slang/slang_emit.c4
3 files changed, 13 insertions, 22 deletions
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index ce64519448e..bde04b9c29e 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -120,25 +120,17 @@ void
_mesa_update_default_objects_program(GLcontext *ctx)
{
#if FEATURE_NV_vertex_program || FEATURE_ARB_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));
- }
- ctx->VertexProgram.Current = (struct gl_vertex_program *) ctx->Shared->DefaultVertexProgram;
+ _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
+ (struct gl_vertex_program *)
+ ctx->Shared->DefaultVertexProgram);
assert(ctx->VertexProgram.Current);
- ctx->VertexProgram.Current->Base.RefCount++;
#endif
#if FEATURE_NV_fragment_program || FEATURE_ARB_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));
- }
- ctx->FragmentProgram.Current = (struct gl_fragment_program *) ctx->Shared->DefaultFragmentProgram;
+ _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current,
+ (struct gl_fragment_program *)
+ ctx->Shared->DefaultFragmentProgram);
assert(ctx->FragmentProgram.Current);
- ctx->FragmentProgram.Current->Base.RefCount++;
#endif
/* XXX probably move this stuff */
@@ -303,7 +295,8 @@ void
_mesa_delete_program(GLcontext *ctx, struct gl_program *prog)
{
(void) ctx;
- ASSERT(prog); assert(prog->RefCount==0);
+ ASSERT(prog);
+ ASSERT(prog->RefCount==0);
if (prog == &_mesa_DummyProgram)
return;
@@ -432,7 +425,7 @@ _mesa_clone_program(GLcontext *ctx, const struct gl_program *prog)
clone->Format = prog->Format;
clone->Instructions = _mesa_alloc_instructions(prog->NumInstructions);
if (!clone->Instructions) {
- ctx->Driver.DeleteProgram(ctx, clone);
+ _mesa_reference_program(ctx, &clone, NULL);
return NULL;
}
_mesa_copy_instructions(clone->Instructions, prog->Instructions,
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index c319cef10a5..65a8c6cc54a 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -246,10 +246,8 @@ _mesa_free_shader(GLcontext *ctx, struct gl_shader *sh)
_mesa_free((void *) sh->Source);
if (sh->InfoLog)
_mesa_free(sh->InfoLog);
- for (i = 0; i < sh->NumPrograms; i++) {
- assert(sh->Programs[i]);
- ctx->Driver.DeleteProgram(ctx, sh->Programs[i]);
- }
+ for (i = 0; i < sh->NumPrograms; i++)
+ _mesa_reference_program(ctx, &sh->Programs[i], NULL);
if (sh->Programs)
_mesa_free(sh->Programs);
_mesa_free(sh);
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index 9c307c6275b..d6ec3c5761b 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -79,7 +79,7 @@ new_subroutine(slang_emit_info *emitInfo, GLuint *id)
_mesa_realloc(emitInfo->Subroutines,
n * sizeof(struct gl_program),
(n + 1) * sizeof(struct gl_program));
- emitInfo->Subroutines[n] = _mesa_new_program(ctx, emitInfo->prog->Target, 0);
+ emitInfo->Subroutines[n] = ctx->Driver.NewProgram(ctx, emitInfo->prog->Target, 0);
emitInfo->Subroutines[n]->Parameters = emitInfo->prog->Parameters;
emitInfo->NumSubroutines++;
*id = n;
@@ -1793,7 +1793,7 @@ _slang_resolve_subroutines(slang_emit_info *emitInfo)
sub->NumInstructions);
/* delete subroutine code */
sub->Parameters = NULL; /* prevent double-free */
- _mesa_delete_program(ctx, sub);
+ _mesa_reference_program(ctx, &emitInfo->Subroutines[i], NULL);
}
/* free subroutine list */