Mesa (master): mesa: implement stencil unpacking for GL_FLOAT_32_UNSIGNED_INT_24_8_REV

Marek Olšák mareko at kemper.freedesktop.org
Sun Jul 10 19:44:50 UTC 2011


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

Author: Marek Olšák <maraeo at gmail.com>
Date:   Tue Jun 21 05:06:36 2011 +0200

mesa: implement stencil unpacking for GL_FLOAT_32_UNSIGNED_INT_24_8_REV

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/main/pack.c |   35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index a232a51..c284c7d 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -1971,7 +1971,8 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
           srcType == GL_INT ||
           srcType == GL_UNSIGNED_INT_24_8_EXT ||
           srcType == GL_HALF_FLOAT_ARB ||
-          srcType == GL_FLOAT);
+          srcType == GL_FLOAT ||
+          srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
 
    switch (srcType) {
       case GL_BITMAP:
@@ -2142,6 +2143,23 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
             }
          }
          break;
+      case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+         {
+            GLuint i;
+            const GLuint *s = (const GLuint *) src;
+            if (unpack->SwapBytes) {
+               for (i = 0; i < n; i++) {
+                  GLuint value = s[i*2+1];
+                  SWAP4BYTE(value);
+                  indexes[i] = value & 0xff;  /* lower 8 bits */
+               }
+            }
+            else {
+               for (i = 0; i < n; i++)
+                  indexes[i] = s[i*2+1] & 0xff;  /* lower 8 bits */
+            }
+         }
+         break;
 
       default:
          _mesa_problem(NULL, "bad srcType in extract_uint_indexes");
@@ -4412,11 +4430,13 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n,
           srcType == GL_INT ||
           srcType == GL_UNSIGNED_INT_24_8_EXT ||
           srcType == GL_HALF_FLOAT_ARB ||
-          srcType == GL_FLOAT);
+          srcType == GL_FLOAT ||
+          srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
 
    ASSERT(dstType == GL_UNSIGNED_BYTE ||
           dstType == GL_UNSIGNED_SHORT ||
-          dstType == GL_UNSIGNED_INT);
+          dstType == GL_UNSIGNED_INT ||
+          dstType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
 
    /* only shift and offset apply to stencil */
    transferOps &= IMAGE_SHIFT_OFFSET_BIT;
@@ -4488,6 +4508,15 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n,
          case GL_UNSIGNED_INT:
             memcpy(dest, indexes, n * sizeof(GLuint));
             break;
+         case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+            {
+               GLuint *dst = (GLuint *) dest;
+               GLuint i;
+               for (i = 0; i < n; i++) {
+                  dst[i*2+1] = indexes[i] & 0xff; /* lower 8 bits */
+               }
+            }
+            break;
          default:
             _mesa_problem(ctx, "bad dstType in _mesa_unpack_stencil_span");
       }




More information about the mesa-commit mailing list