Mesa (master): swrast: Fix fastpaths for glRead/WritePixels( GL_DEPTH_STENCIL)

Chad Versace chadversary at kemper.freedesktop.org
Tue Oct 18 11:44:16 PDT 2011


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

Author: Chad Versace <chad at chad-versace.us>
Date:   Fri Oct  7 16:22:56 2011 -0700

swrast: Fix fastpaths for glRead/WritePixels(GL_DEPTH_STENCIL)

In some cases, Intel hardware requires that depth and stencil buffers be
separate. To accommodate swrast, i965 resorts to hackery that causes
a segfault in the fastpaths of draw_depth_stencil_pixels() and
read_depth_stencil_pixels().

The hack is that i965 sets framebuffer->Attachment[BUFFER_DEPTH].Renderbuffer
and framebuffer->Attachment[BUFFER_STENCIL].Renderbuffer to a dummy
renderbuffer for which the GetRow accessors and friends are null. The real
buffers are located at framebuffer->_DepthBuffer and framebuffer->_Stencilbuffer.

To fix the segault, this patch skips the fastpath if
framebuffer->Attachment[BUFFER_DEPTH].Renderbuffer->GetRow is null.

Note: This is a candidate for the 7.11 branch.
Reviewed-by: Brian Paul <brianp at vmware.com>
Signed-off-by: Chad Versace <chad at chad-versace.us>

---

 src/mesa/swrast/s_drawpix.c |    2 ++
 src/mesa/swrast/s_readpix.c |    2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index 6535a8f..20bf4d6 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -593,6 +593,8 @@ draw_depth_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
        depthRb->Format == MESA_FORMAT_Z24_S8 &&
        type == GL_UNSIGNED_INT_24_8 &&
        depthRb == stencilRb &&
+       depthRb->GetRow &&  /* May be null if depthRb is a wrapper around
+			    * separate depth and stencil buffers. */
        !scaleOrBias &&
        !zoom &&
        ctx->Depth.Mask &&
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index d120468..0d2e63f 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -394,6 +394,8 @@ read_depth_stencil_pixels(struct gl_context *ctx,
        depthRb->Format == MESA_FORMAT_Z24_S8 &&
        type == GL_UNSIGNED_INT_24_8 &&
        depthRb == stencilRb &&
+       depthRb->GetRow &&  /* May be null if depthRb is a wrapper around
+			    * separate depth and stencil buffers. */
        !scaleOrBias &&
        !stencilTransfer) {
       /* This is the ideal case.



More information about the mesa-commit mailing list