Mesa (master): mesa: do depth/stencil format conversion in glGetTexImage

Brian Paul brianp at kemper.freedesktop.org
Fri Feb 28 14:05:34 UTC 2014


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

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Feb 27 08:36:13 2014 -0700

mesa: do depth/stencil format conversion in glGetTexImage

glGetTexImage(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8) was just
using memcpy() instead of _mesa_unpack_uint_24_8_depth_stencil_row()
to convert texels from the hardware format to the GL format.

Fixes issue reported by David Meng at Intel.  The new piglit
ext_packed_depth_stencil-getteximage test checks for this bug.

Also, add some format/type assertions.  We don't yet handle the
GL_FLOAT_32_UNSIGNED_INT_24_8_REV type.  That should be fixed in
a follow-on patch.

Reviewed-by: Eric Anholt <eric at anholt.net>
Cc: "10.0" "10.1" <mesa-stable at lists.freedesktop.org>

---

 src/mesa/main/texgetimage.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index fedd814..daabf2e 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -130,6 +130,10 @@ get_tex_depth_stencil(struct gl_context *ctx, GLuint dimensions,
    const GLint depth = texImage->Depth;
    GLint img, row;
 
+   assert(format == GL_DEPTH_STENCIL);
+   assert(type == GL_UNSIGNED_INT_24_8);
+   /* XXX type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV is not handled yet */
+
    for (img = 0; img < depth; img++) {
       GLubyte *srcMap;
       GLint rowstride;
@@ -145,8 +149,11 @@ get_tex_depth_stencil(struct gl_context *ctx, GLuint dimensions,
             void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
                                              width, height, format, type,
                                              img, row, 0);
-            /* XXX Z24_S8 vs. S8_Z24??? */
-            memcpy(dest, src, width * sizeof(GLuint));
+            /* Unpack from texture's format to GL's z24_s8 layout */
+            _mesa_unpack_uint_24_8_depth_stencil_row(texImage->TexFormat,
+                                                     width,
+                                                     (const GLuint *) src,
+                                                     dest);
             if (ctx->Pack.SwapBytes) {
                _mesa_swap4((GLuint *) dest, width);
             }




More information about the mesa-commit mailing list