r300: fix bo ref/unref, plugs DRI handle leaks
authorDave Airlie <airlied@redhat.com>
Tue, 24 Feb 2009 02:04:49 +0000 (12:04 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 24 Feb 2009 02:04:49 +0000 (12:04 +1000)
src/mesa/drivers/dri/r300/r300_tex.c
src/mesa/drivers/dri/r300/r300_texstate.c

index 27b907019e367c1c0611d2e83c0772fd5d6ff1df..0f5afbfa298afe6ecc6ae3e79435565818d66692 100644 (file)
@@ -270,6 +270,11 @@ static void r300DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
                                rmesa->hw.textures[i] = 0;
        }
 
+       if (t->bo) {
+               radeon_bo_unref(t->bo);
+               t->bo = NULL;
+       }
+
        if (t->mt) {
                radeon_miptree_unreference(t->mt);
                t->mt = 0;
index 4f145bdbb4e977af586318908e4c1b1f0c477a3c..ef13fed6b22d10b157ce27c283a96cd6c3f61683 100644 (file)
@@ -433,9 +433,15 @@ void r300SetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
        
        _mesa_lock_texture(radeon->glCtx, texObj);
        if (t->bo) {
+               radeon_bo_unref(t->bo);
                t->bo = NULL;
        }
+       if (rImage->bo) {
+               radeon_bo_unref(rImage->bo);
+               rImage->bo = NULL;
+       }
        if (t->mt) {
+               radeon_miptree_unreference(t->mt);
                t->mt = NULL;
        }
        if (rImage->mt) {
@@ -447,7 +453,7 @@ void r300SetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
                                   rb->width, rb->height, 1, 0, rb->cpp);
        texImage->TexFormat = &_mesa_texformat_rgba8888_rev;
        rImage->bo = rb->bo;
-       
+       radeon_bo_ref(rImage->bo);
        t->bo = rb->bo;
        radeon_bo_ref(t->bo);
        t->tile_bits = 0;