Mesa (master): mesa: comments and code documenting a bug with depth 32 TrueColor drawing/ reading

Brian Paul brianp at kemper.freedesktop.org
Tue Mar 3 00:56:43 UTC 2009


Module: Mesa
Branch: master
Commit: d652d26a975a884fecd9c407e77b7259fb291906
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d652d26a975a884fecd9c407e77b7259fb291906

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Mar  2 17:51:44 2009 -0700

mesa: comments and code documenting a bug with depth 32 TrueColor drawing/reading

It seems that XGetImage() from a depth 32 TrueColor window is flakey.
Drawing with XPutImage() instead of XPutPixel() seems to work better, but
still not perfectly.

Keep using the original code for now until more is learned.

---

 src/mesa/drivers/x11/xm_span.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/x11/xm_span.c b/src/mesa/drivers/x11/xm_span.c
index 57b5749..309cefc 100644
--- a/src/mesa/drivers/x11/xm_span.c
+++ b/src/mesa/drivers/x11/xm_span.c
@@ -471,8 +471,26 @@ static void put_row_8R8G8B_pixmap( PUT_ROW_ARGS )
    if (mask) {
       for (i=0;i<n;i++,x++) {
          if (mask[i]) {
+#if 1
+            /*
+             * XXX Something funny is going on here.
+             * If we're drawing into a window that uses a depth 32 TrueColor
+             * visual, we see the right pixels on screen, but when we read
+             * them back with XGetImage() we get random colors.
+             * The alternative code below which uses XPutImage() instead
+             * seems to mostly fix the problem, but not always.
+             * We don't normally create windows with this visual, but glean
+             * does and we're seeing some failures there.
+             */
             XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
             XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+#else
+            /* This code works more often, but not always */
+            XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+            GLuint *ptr4 = (GLuint *) rowimg->data;
+            *ptr4 = PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+            XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, 1, 1 );
+#endif
          }
       }
    }




More information about the mesa-commit mailing list