Mesa (texformat-rework): mesa: added MESA_FORMAT_X8_Z24 format

Brian Paul brianp at kemper.freedesktop.org
Thu Oct 22 03:21:29 UTC 2009


Module: Mesa
Branch: texformat-rework
Commit: e4c700dbbf2a802f32bf62256c801105998c3729
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e4c700dbbf2a802f32bf62256c801105998c3729

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Oct 21 19:55:44 2009 -0600

mesa: added MESA_FORMAT_X8_Z24 format

24-bit Z in 32-bit pixel.  We could probably use the MESA_FORMAT_S8_Z24
format but this there's a few places where we explicitly don't want stencil.
This format may go away at some point in the future.

---

 src/mesa/main/formats.c  |   13 +++++++++++++
 src/mesa/main/formats.h  |    1 +
 src/mesa/main/texfetch.c |    7 +++++++
 src/mesa/main/texstore.c |   36 ++++++++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 2924ab6..45ac39a 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -291,6 +291,14 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
       1, 1, 2                      /* BlockWidth/Height,Bytes */
    },
    {
+      MESA_FORMAT_X8_Z24,          /* Name */
+      GL_DEPTH_COMPONENT,          /* BaseFormat */
+      GL_UNSIGNED_INT,             /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 24, 0,              /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 4                      /* BlockWidth/Height,Bytes */
+   },
+   {
       MESA_FORMAT_Z32,             /* Name */
       GL_DEPTH_COMPONENT,          /* BaseFormat */
       GL_UNSIGNED_INT,             /* DataType */
@@ -873,6 +881,11 @@ _mesa_format_to_type_and_comps(gl_format format,
       *comps = 1;
       return;
 
+   case MESA_FORMAT_X8_Z24:
+      *datatype = GL_UNSIGNED_INT;
+      *comps = 1;
+      return;
+
    case MESA_FORMAT_Z32:
       *datatype = GL_UNSIGNED_INT;
       *comps = 1;
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index 30915bf..f8b4a6c 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -76,6 +76,7 @@ typedef enum
    MESA_FORMAT_Z24_S8,          /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */
    MESA_FORMAT_S8_Z24,          /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
    MESA_FORMAT_Z16,             /*                     ZZZZ ZZZZ ZZZZ ZZZZ */
+   MESA_FORMAT_X8_Z24,          /* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
    MESA_FORMAT_Z32,             /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
    MESA_FORMAT_S8,              /*                               SSSS SSSS */
    /*@}*/
diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c
index c502195..e6e28ae 100644
--- a/src/mesa/main/texfetch.c
+++ b/src/mesa/main/texfetch.c
@@ -523,6 +523,13 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
       store_texel_z16
    },
    {
+      MESA_FORMAT_X8_Z24,
+      fetch_texel_1d_f_s8_z24,
+      fetch_texel_2d_f_s8_z24,
+      fetch_texel_3d_f_s8_z24,
+      store_texel_s8_z24
+   },
+   {
       MESA_FORMAT_Z32,
       fetch_texel_1d_f_z32,
       fetch_texel_2d_f_z32,
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 604f6c4..d0d4250 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -1048,6 +1048,41 @@ _mesa_texstore_z32(TEXSTORE_PARAMS)
    return GL_TRUE;
 }
 
+
+/**
+ * Store a 24-bit integer depth component texture image.
+ */
+static GLboolean
+_mesa_texstore_x8_z24(TEXSTORE_PARAMS)
+{
+   const GLuint depthScale = 0xffffff;
+   const GLuint texelBytes = 4;
+
+   (void) dims;
+   ASSERT(dstFormat == MESA_FORMAT_X8_Z24);
+
+   {
+      /* general path */
+      GLint img, row;
+      for (img = 0; img < srcDepth; img++) {
+         GLubyte *dstRow = (GLubyte *) dstAddr
+            + dstImageOffsets[dstZoffset + img] * texelBytes
+            + dstYoffset * dstRowStride
+            + dstXoffset * texelBytes;
+         for (row = 0; row < srcHeight; row++) {
+            const GLvoid *src = _mesa_image_address(dims, srcPacking,
+                srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
+            _mesa_unpack_depth_span(ctx, srcWidth,
+                                    GL_UNSIGNED_INT, (GLuint *) dstRow,
+                                    depthScale, srcType, src, srcPacking);
+            dstRow += dstRowStride;
+         }
+      }
+   }
+   return GL_TRUE;
+}
+
+
 #define STRIDE_3D 0
 
 /**
@@ -3009,6 +3044,7 @@ texstore_funcs[MESA_FORMAT_COUNT] =
    { MESA_FORMAT_Z24_S8, _mesa_texstore_z24_s8 },
    { MESA_FORMAT_S8_Z24, _mesa_texstore_s8_z24 },
    { MESA_FORMAT_Z16, _mesa_texstore_z16 },
+   { MESA_FORMAT_X8_Z24, _mesa_texstore_x8_z24 },
    { MESA_FORMAT_Z32, _mesa_texstore_z32 },
    { MESA_FORMAT_S8, NULL/*_mesa_texstore_s8*/ },
    { MESA_FORMAT_SRGB8, _mesa_texstore_srgb8 },




More information about the mesa-commit mailing list