diff options
author | Brian Paul <[email protected]> | 2008-05-07 08:55:33 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-05-07 08:55:33 -0600 |
commit | a56a59ce74b7f18f25a13992d2a2c1ae7cf973ce (patch) | |
tree | 77480d5ff607adcfa5c7688805c514e4ab5c51e3 /src/mesa/shader/prog_cache.c | |
parent | 10b7192747087ec25f97cdfcfc062654a2d8fe6d (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.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/mesa/shader/prog_cache.c b/src/mesa/shader/prog_cache.c index dd0241ef24e..36a25377c55 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) |