summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/slang
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-05-16 09:56:59 -0600
committerBrian Paul <[email protected]>2008-05-16 15:16:06 -0600
commit8bdf5b6e6465ff734a798efb193ab16cd33df36e (patch)
treed34a8b6f74463270b70be556ce16d1fd7d914ad9 /src/mesa/shader/slang
parenta3e86d43e6c99af97c2931c883d552c9714006e8 (diff)
Fix a program refcounting error, don't share program parameter lists.
The refcounting bug was causing a memleak (unfreed programs). The old parameter list sharing is not needed since the change in how uniforms are handled.
Diffstat (limited to 'src/mesa/shader/slang')
-rw-r--r--src/mesa/shader/slang/slang_link.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 8213b7772c2..80cd4b6df62 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -406,20 +406,20 @@ _slang_link(GLcontext *ctx,
* Make copies of the vertex/fragment programs now since we'll be
* changing src/dst registers after merging the uniforms and varying vars.
*/
+ _mesa_reference_vertprog(ctx, &shProg->VertexProgram, NULL);
if (vertProg) {
- _mesa_reference_vertprog(ctx, &shProg->VertexProgram,
- vertex_program(_mesa_clone_program(ctx, &vertProg->Base)));
- }
- else {
- _mesa_reference_vertprog(ctx, &shProg->VertexProgram, NULL);
+ struct gl_vertex_program *linked_vprog =
+ vertex_program(_mesa_clone_program(ctx, &vertProg->Base));
+ shProg->VertexProgram = linked_vprog; /* refcount OK */
+ ASSERT(shProg->VertexProgram->Base.RefCount == 1);
}
+ _mesa_reference_fragprog(ctx, &shProg->FragmentProgram, NULL);
if (fragProg) {
- _mesa_reference_fragprog(ctx, &shProg->FragmentProgram,
- fragment_program(_mesa_clone_program(ctx, &fragProg->Base)));
- }
- else {
- _mesa_reference_fragprog(ctx, &shProg->FragmentProgram, NULL);
+ struct gl_fragment_program *linked_fprog =
+ fragment_program(_mesa_clone_program(ctx, &fragProg->Base));
+ shProg->FragmentProgram = linked_fprog; /* refcount OK */
+ ASSERT(shProg->FragmentProgram->Base.RefCount == 1);
}
/* link varying vars */
@@ -437,18 +437,6 @@ _slang_link(GLcontext *ctx,
/*_mesa_print_uniforms(shProg->Uniforms);*/
if (shProg->VertexProgram) {
- /* Rather than cloning the parameter list here, just share it.
- * We need to be careful _mesa_clear_shader_program_data() in
- * to avoid double-freeing.
- */
- shProg->VertexProgram->Base.Parameters = vertProg->Base.Parameters;
- }
- if (shProg->FragmentProgram) {
- /* see comment just above */
- shProg->FragmentProgram->Base.Parameters = fragProg->Base.Parameters;
- }
-
- if (shProg->VertexProgram) {
if (!_slang_resolve_attributes(shProg, &shProg->VertexProgram->Base)) {
/*goto cleanup;*/
_mesa_problem(ctx, "_slang_resolve_attributes() failed");