diff options
author | Brian Paul <[email protected]> | 2008-05-14 12:19:22 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-05-14 12:19:22 -0600 |
commit | d791386b09682dbccc68cc3803b6d71a0362124e (patch) | |
tree | db7a63cf5e823cadfe97f9c3ed0a9ee76a5b0874 /src/mesa/shader | |
parent | 19f15277d1871b62902031f9fa9aabf2f1bc7c40 (diff) |
fix some additional program refcounting bugs
cherry-picked from master
Diffstat (limited to 'src/mesa/shader')
-rw-r--r-- | src/mesa/shader/program.c | 5 | ||||
-rw-r--r-- | src/mesa/shader/shader_api.c | 6 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_emit.c | 4 |
3 files changed, 6 insertions, 9 deletions
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 9a23c5d7d31..e06ab5aa237 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -116,8 +116,6 @@ _mesa_free_program_data(GLcontext *ctx) } - - /** * Set the vertex/fragment program error state (position and error string). * This is generally called from within the parsers. @@ -272,6 +270,7 @@ _mesa_delete_program(GLcontext *ctx, struct gl_program *prog) { (void) ctx; ASSERT(prog); + ASSERT(prog->RefCount==0); if (prog == &_mesa_DummyProgram) return; @@ -391,7 +390,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 f12fa28d97b..2b3dbff7a08 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -243,10 +243,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 382b13ff056..964274eba84 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; @@ -1787,7 +1787,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 */ |