From: Michel Dänzer <[email protected]>

Since commit 6f9dbe773953b024075910b3bec11ebc96c2e8e0 ('mesa: use new
_mesa_meta_CopyTex[Sub]Image() functions'), I was seeing crashes when using the
compiz magnifier plugin, apparently because the code in radeon_texture.c ends
up unmapping a texture BO more times than it was mapped. There may be a better
fix for that particular problem, but this at least works around it and may be
desirable anyway for more resiliance towards similar problems.
---
 src/mesa/drivers/dri/radeon/radeon_texture.c |   29 ++++++++++---------------
 1 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c 
b/src/mesa/drivers/dri/radeon/radeon_texture.c
index 049284e..b2c3a34 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -124,11 +124,12 @@ void radeon_teximage_map(radeon_texture_image *image, 
GLboolean write_enable)
 
 void radeon_teximage_unmap(radeon_texture_image *image)
 {
-       if (image->mt) {
-               assert(image->base.Data);
-
+       if (image->mt && image->base.Data) {
+               if (image->base.Data == image->mt->bo->ptr)
+                       radeon_bo_unmap(image->mt->bo);
+               else
+                       _mesa_free_texmemory(image->base.Data);
                image->base.Data = 0;
-               radeon_bo_unmap(image->mt->bo);
        }
 }
 
@@ -169,10 +170,10 @@ void radeonMapTexture(GLcontext *ctx, struct 
gl_texture_object *texObj)
        if (!t->mt)
                return;
 
-       radeon_bo_map(t->mt->bo, GL_FALSE);
        for(face = 0; face < t->mt->faces; ++face) {
                for(level = t->mt->firstLevel; level <= t->mt->lastLevel; 
++level)
-                       
teximage_set_map_data(get_radeon_texture_image(texObj->Image[face][level]));
+                       
radeon_teximage_map(get_radeon_texture_image(texObj->Image[face][level]),
+                                           GL_FALSE);
        }
 }
 
@@ -189,9 +190,8 @@ void radeonUnmapTexture(GLcontext *ctx, struct 
gl_texture_object *texObj)
 
        for(face = 0; face < t->mt->faces; ++face) {
                for(level = t->mt->firstLevel; level <= t->mt->lastLevel; 
++level)
-                       texObj->Image[face][level]->Data = 0;
+                       
radeon_teximage_unmap(get_radeon_texture_image(texObj->Image[face][level]));
        }
-       radeon_bo_unmap(t->mt->bo);
 }
 
 GLuint radeon_face_for_target(GLenum target)
@@ -659,14 +659,11 @@ static void radeon_teximage(
                        if (dims == 3)
                                _mesa_free(dstImageOffsets);
                }
+
+               radeon_teximage_unmap(image);
        }
 
        _mesa_unmap_teximage_pbo(ctx, packing);
-
-       if (pixels)
-         radeon_teximage_unmap(image);
-
-
 }
 
 void radeonTexImage1D(GLcontext * ctx, GLenum target, GLint level,
@@ -787,13 +784,11 @@ static void radeon_texsubimage(GLcontext* ctx, int dims, 
GLenum target, int leve
                                                             format, type, 
pixels, packing))
                                _mesa_error(ctx, GL_OUT_OF_MEMORY, 
"glTexSubImage");
                }
-       }
 
-       radeon_teximage_unmap(image);
+               radeon_teximage_unmap(image);
+       }
 
        _mesa_unmap_teximage_pbo(ctx, packing);
-
-
 }
 
 void radeonTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
-- 
1.6.4.3


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to