summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2011-02-08 08:05:14 -0700
committerBrian Paul <brianp@vmware.com>2011-02-08 08:10:22 -0700
commit5cbff0932e498f49b57cbb71037b93416bfe30e0 (patch)
treed503dc9264cb71279499bad207410c7dfd45eb08
parent1ee71bdc8a8471357cee6a1cf2fbaac6a70bb86c (diff)
st/mesa: free the temporary bitmap/drawpix shader code
Fixes a per-shader memory leak when drawing glBitmaps, glDrawPixels or glCopyPixels. NOTE: This is a candidate for the 7.9 and 7.10 branches.
-rw-r--r--src/mesa/state_tracker/st_program.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 7b32b46838..f6e4445849 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -413,7 +413,7 @@ st_translate_fragment_program(struct st_context *st,
#if FEATURE_drawpix
if (key->bitmap) {
/* glBitmap drawing */
- struct gl_fragment_program *fp;
+ struct gl_fragment_program *fp; /* we free this temp program below */
st_make_bitmap_fragment_program(st, &stfp->Base,
&fp, &variant->bitmap_sampler);
@@ -423,7 +423,7 @@ st_translate_fragment_program(struct st_context *st,
}
else if (key->drawpixels) {
/* glDrawPixels drawing */
- struct gl_fragment_program *fp;
+ struct gl_fragment_program *fp; /* we free this temp program below */
if (key->drawpixels_z || key->drawpixels_stencil) {
fp = st_make_drawpix_z_stencil_program(st, key->drawpixels_z,
@@ -630,6 +630,14 @@ st_translate_fragment_program(struct st_context *st,
debug_printf("\n");
}
+#if FEATURE_drawpix
+ if (key->bitmap || key->drawpixels) {
+ /* Free the temporary program made above */
+ struct gl_fragment_program *fp = &stfp->Base;
+ _mesa_reference_fragprog(st->ctx, &fp, NULL);
+ }
+#endif
+
return variant;
}