From 8dcff01c8b7f0faf562a1f324d408869526995e4 Mon Sep 17 00:00:00 2001 From: Yevhenii Kolesnikov Date: Fri, 12 Jul 2019 14:53:59 +0300 Subject: [PATCH] meta: Add cleanup function for Bitmap MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Buffer object and temporary texture were never freed, causing memory leaks. Signed-off-by: Yevhenii Kolesnikov Reviewed-by: Tapani Pälli --- src/mesa/drivers/common/meta.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index c636cb923d8..41722a38b38 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -112,6 +112,8 @@ static void meta_drawpix_cleanup(struct gl_context *ctx, struct drawpix_state *drawpix); static void meta_drawtex_cleanup(struct gl_context *ctx, struct drawtex_state *drawtex); +static void meta_bitmap_cleanup(struct gl_context *ctx, + struct bitmap_state *bitmap); void _mesa_meta_framebuffer_texture_image(struct gl_context *ctx, @@ -432,6 +434,8 @@ _mesa_meta_free(struct gl_context *ctx) meta_decompress_cleanup(ctx, &ctx->Meta->Decompress); meta_drawpix_cleanup(ctx, &ctx->Meta->DrawPix); meta_drawtex_cleanup(ctx, &ctx->Meta->DrawTex); + meta_bitmap_cleanup(ctx, &ctx->Meta->Bitmap); + if (old_context) _mesa_make_current(old_context, old_context->WinSysDrawBuffer, old_context->WinSysReadBuffer); else @@ -1984,6 +1988,19 @@ meta_drawtex_cleanup(struct gl_context *ctx, struct drawtex_state *drawtex) } } +static void +meta_bitmap_cleanup(struct gl_context *ctx, struct bitmap_state *bitmap) +{ + if (bitmap->VAO != 0) { + _mesa_DeleteVertexArrays(1, &bitmap->VAO); + bitmap->VAO = 0; + + _mesa_reference_buffer_object(ctx, &bitmap->buf_obj, NULL); + + cleanup_temp_texture(ctx, &bitmap->Tex); + } +} + /** * When the glDrawPixels() image size is greater than the max rectangle * texture size we use this function to break the glDrawPixels() image -- 2.30.2