r300: release bo from pixmap
authorJerome Glisse <glisse@freedesktop.org>
Thu, 13 Nov 2008 19:04:50 +0000 (20:04 +0100)
committerJerome Glisse <glisse@freedesktop.org>
Fri, 14 Nov 2008 10:26:17 +0000 (11:26 +0100)
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_tex.c
src/mesa/drivers/dri/r300/r300_texstate.c

index aec03a8..30229ed 100644 (file)
@@ -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 */
index fa96cdf..9ceac70 100644 (file)
@@ -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;
+    }
 }
 
 
index 9153646..bb2f093 100644 (file)
@@ -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;