summaryrefslogtreecommitdiff
path: root/src/mesa/shader/prog_cache.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-05-07 08:55:33 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-05-07 08:55:33 -0600
commita56a59ce74b7f18f25a13992d2a2c1ae7cf973ce (patch)
tree77480d5ff607adcfa5c7688805c514e4ab5c51e3 /src/mesa/shader/prog_cache.c
parent10b7192747087ec25f97cdfcfc062654a2d8fe6d (diff)
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
Diffstat (limited to 'src/mesa/shader/prog_cache.c')
-rw-r--r--src/mesa/shader/prog_cache.c5
1 files changed, 3 insertions, 2 deletions
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)