From a56a59ce74b7f18f25a13992d2a2c1ae7cf973ce Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 7 May 2008 08:55:33 -0600 Subject: gallium: implement full reference counting for vertex/fragment programs Use _mesa_reference_vert/fragprog() wherever we assign program pointers. Fixes a memory corruption bug found with glean/api2 test. Another memory bug involving shaders yet to be fixed... Picked from gallium-0.1 --- src/mesa/shader/prog_cache.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/mesa/shader/prog_cache.c') diff --git a/src/mesa/shader/prog_cache.c b/src/mesa/shader/prog_cache.c index dd0241ef24..36a25377c5 100644 --- a/src/mesa/shader/prog_cache.c +++ b/src/mesa/shader/prog_cache.c @@ -30,6 +30,7 @@ #include "main/mtypes.h" #include "main/imports.h" #include "shader/prog_cache.h" +#include "shader/program.h" struct cache_item @@ -109,7 +110,7 @@ clear_cache(GLcontext *ctx, struct gl_program_cache *cache) for (c = cache->items[i]; c; c = next) { next = c->next; _mesa_free(c->key); - ctx->Driver.DeleteProgram(ctx, c->program); + _mesa_reference_program(ctx, &c->program, NULL); _mesa_free(c); } cache->items[i] = NULL; @@ -177,7 +178,7 @@ _mesa_program_cache_insert(GLcontext *ctx, c->key = _mesa_malloc(keysize); memcpy(c->key, key, keysize); - c->program = program; + c->program = program; /* no refcount change */ if (cache->n_items > cache->size * 1.5) { if (cache->size < 1000) -- cgit v1.2.3