On Mon, 2009-09-21 at 16:46 +0200, mic...@daenzer.net wrote: 
> From: Michel Dänzer <daen...@vmware.com>
> 
> 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, [...]

Actually the patch turned out not to fix the compiz magnifier plugin
problem completely. The patch below does, does it look good?

      * Make sure the texture has a valid format in copy_tex_image(). 
      * Move up the _mesa_update_state() call in _swrast_ReadPixels(),
        so the driver doesn't map the wrong textures. 
      * Make the radeon texture (un)mapping code cope with textures
        which don't have a miptree associated with them yet.


diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 2175678..991a3db 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -55,6 +55,7 @@
 #include "main/stencil.h"
 #include "main/texobj.h"
 #include "main/texenv.h"
+#include "main/texformat.h"
 #include "main/teximage.h"
 #include "main/texparam.h"
 #include "main/texstate.h"
@@ -2172,6 +2173,12 @@ copy_tex_image(GLcontext *ctx, GLuint dims, GLenum 
target, GLint level,
       return;
    }
 
+   if (texImage->TexFormat == &_mesa_null_texformat)
+       texImage->TexFormat = ctx->Driver.ChooseTextureFormat(ctx,
+                                                             internalFormat,
+                                                             format,
+                                                             type);
+
    _mesa_unlock_texture(ctx, texObj); /* need to unlock first */
 
    /*
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c 
b/src/mesa/drivers/dri/radeon/radeon_texture.c
index 049284e..7b7392b 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -101,7 +101,12 @@ void radeonFreeTexImageData(GLcontext *ctx, struct 
gl_texture_image *timage)
 /* Set Data pointer and additional data for mapped texture image */
 static void teximage_set_map_data(radeon_texture_image *image)
 {
-       radeon_mipmap_level *lvl = &image->mt->levels[image->mtlevel];
+       radeon_mipmap_level *lvl;
+
+       if (!image->mt)
+               return;
+
+       lvl = &image->mt->levels[image->mtlevel];
 
        image->base.Data = image->mt->bo->ptr + 
lvl->faces[image->mtface].offset;
        image->base.RowStride = lvl->rowstride / image->mt->bpp;
@@ -969,7 +974,7 @@ int radeon_validate_texture_miptree(GLcontext * ctx, struct 
gl_texture_object *t
                        radeon_texture_image *image = 
get_radeon_texture_image(texObj->Image[face][level]);
                        if (RADEON_DEBUG & RADEON_TEXTURE)
                                fprintf(stderr, " face %i, level %i... %p vs %p 
", face, level, t->mt, image->mt);
-                       if (t->mt == image->mt) {
+                       if (t->mt == image->mt || (!image->mt && 
!image->base.Data)) {
                                if (RADEON_DEBUG & RADEON_TEXTURE)
                                        fprintf(stderr, "OK\n");
 
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 48b9408..a1aeb2e 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -555,15 +555,15 @@ _swrast_ReadPixels( GLcontext *ctx,
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    struct gl_pixelstore_attrib clippedPacking = *packing;
 
+   if (ctx->NewState)
+      _mesa_update_state(ctx);
+
    /* Need to do swrast_render_start() before clipping or anything else
     * since this is where a driver may grab the hw lock and get an updated
     * window size.
     */
    swrast_render_start(ctx);
 
-   if (ctx->NewState)
-      _mesa_update_state(ctx);
-
    if (swrast->NewState)
       _swrast_validate_derived( ctx );
 


-- 
Earthling Michel Dänzer           |                http://www.vmware.com
Libre software enthusiast         |          Debian, X and DRI developer

------------------------------------------------------------------------------
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
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to