From 93a9d2f18de8517af92eba787a4eee34765481ab Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Thu, 13 Nov 2008 20:04:50 +0100 Subject: [PATCH] r300: release bo from pixmap --- src/mesa/drivers/dri/r300/r300_context.h | 1 + src/mesa/drivers/dri/r300/r300_tex.c | 4 ++++ src/mesa/drivers/dri/r300/r300_texstate.c | 25 +++++++++++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index aec03a81e04..30229ed4fbc 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -139,6 +139,7 @@ struct _r300_texture_image { * by base.Data. */ struct _r300_mipmap_tree *mt; + struct radeon_bo *bo; int mtlevel; /** if mt != 0, this is the image's level in the mipmap tree */ int mtface; /** if mt != 0, this is the image's face in the mipmap tree */ diff --git a/src/mesa/drivers/dri/r300/r300_tex.c b/src/mesa/drivers/dri/r300/r300_tex.c index fa96cdf3774..9ceac70f5e3 100644 --- a/src/mesa/drivers/dri/r300/r300_tex.c +++ b/src/mesa/drivers/dri/r300/r300_tex.c @@ -429,6 +429,10 @@ static void r300FreeTexImageData(GLcontext *ctx, struct gl_texture_image *timage } else { _mesa_free_texture_image_data(ctx, timage); } + if (image->bo) { + radeon_bo_unref(image->bo); + image->bo = NULL; + } } diff --git a/src/mesa/drivers/dri/r300/r300_texstate.c b/src/mesa/drivers/dri/r300/r300_texstate.c index 9153646aa73..bb2f0937c13 100644 --- a/src/mesa/drivers/dri/r300/r300_texstate.c +++ b/src/mesa/drivers/dri/r300/r300_texstate.c @@ -465,6 +465,7 @@ void r300SetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv) struct gl_texture_object *texObj; struct gl_texture_image *texImage; struct radeon_renderbuffer *rb; + r300_texture_image *rImage; radeonContextPtr radeon; r300ContextPtr rmesa; GLframebuffer *fb; @@ -478,6 +479,11 @@ void r300SetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv) texUnit = &radeon->glCtx->Texture.Unit[radeon->glCtx->Texture.CurrentUnit]; texObj = _mesa_select_tex_object(radeon->glCtx, texUnit, target); texImage = _mesa_get_tex_image(radeon->glCtx, texObj, target, 0); + rImage = get_r300_texture_image(texImage); + t = r300_tex_obj(texObj); + if (t == NULL) { + return; + } radeon_update_renderbuffers(pDRICtx, dPriv); rb = (void*)fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer; @@ -487,14 +493,25 @@ void r300SetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv) } _mesa_lock_texture(radeon->glCtx, texObj); + if (t->bo) { + t->bo = NULL; + } + if (t->mt) { + t->mt = NULL; + } + if (rImage->bo) { + radeon_bo_unref(rImage->bo); + rImage->bo = NULL; + } + if (rImage->mt) { + r300_miptree_unreference(rImage->mt); + rImage->mt = NULL; + } _mesa_init_teximage_fields(radeon->glCtx, target, texImage, rb->width, rb->height, rb->cpp, 0, rb->cpp); texImage->TexFormat = &_mesa_texformat_rgba8888_rev; + rImage->bo = rb->bo; - t = r300_tex_obj(texObj); - if (t == NULL) { - return; - } t->bo = rb->bo; t->tile_bits = 0; t->image_override = GL_TRUE; -- 2.30.2