mesa: Added _mesa_texstore_s8_z24
authorJakob Bornecrantz <jakob@tungstengraphics.com>
Tue, 17 Jun 2008 23:39:46 +0000 (01:39 +0200)
committerJakob Bornecrantz <jakob@tungstengraphics.com>
Tue, 17 Jun 2008 23:48:20 +0000 (01:48 +0200)
src/mesa/main/texformat.c
src/mesa/main/texstore.c
src/mesa/main/texstore.h

index ea55002f58d70033e0dbc50fd0aea68a1a52e608..11e7755960a9072c820750f7b14b4ce93bbda33b 100644 (file)
@@ -1221,11 +1221,7 @@ const struct gl_texture_format _mesa_texformat_s8_z24 = {
    24,                                 /* DepthBits */
    8,                                  /* StencilBits */
    4,                                  /* TexelBytes */
-#if 0
    _mesa_texstore_s8_z24,              /* StoreTexImageFunc */
-#else
-   _mesa_texstore_z24_s8,              /* StoreTexImageFunc */
-#endif
    NULL,                               /* FetchTexel1D */
    NULL,                               /* FetchTexel2D */
    NULL,                               /* FetchTexel3D */
index 562e07a0f5887c9500360ce8c17d4343b025560e..f3629cb0d1d4f70983228adac10ad8a7024c4c87 100644 (file)
@@ -2397,6 +2397,60 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
 }
 
 
+/**
+ * Store a combined depth/stencil texture image.
+ */
+GLboolean
+_mesa_texstore_s8_z24(TEXSTORE_PARAMS)
+{
+   const GLuint depthScale = 0xffffff;
+
+   ASSERT(dstFormat == &_mesa_texformat_s8_z24);
+   ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT);
+   ASSERT(srcType == GL_UNSIGNED_INT_24_8_EXT);
+
+
+   /* general path */
+   const GLint srcRowStride
+      = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
+      / sizeof(GLuint);
+   GLint img, row;
+
+   for (img = 0; img < srcDepth; img++) {
+      GLuint *dstRow = (GLuint *) dstAddr
+         + dstImageOffsets[dstZoffset + img]
+         + dstYoffset * dstRowStride / sizeof(GLuint)
+         + dstXoffset;
+      const GLuint *src
+         = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr,
+                                                srcWidth, srcHeight,
+                                                srcFormat, srcType,
+                                                img, 0, 0);
+      for (row = 0; row < srcHeight; row++) {
+         GLubyte stencil[MAX_WIDTH];
+         GLint i;
+         /* the 24 depth bits will be in the high position: */
+         _mesa_unpack_depth_span(ctx, srcWidth,
+                                 GL_UNSIGNED_INT, /* dst type */
+                                 dstRow, /* dst addr */
+                                 depthScale,
+                                 srcType, src, srcPacking);
+         /* get the 8-bit stencil values */
+         _mesa_unpack_stencil_span(ctx, srcWidth,
+                                   GL_UNSIGNED_BYTE, /* dst type */
+                                   stencil, /* dst addr */
+                                   srcType, src, srcPacking,
+                                   ctx->_ImageTransferState);
+         /* merge stencil values into depth values */
+         for (i = 0; i < srcWidth; i++)
+            dstRow[i] = stencil[i] << 24;
+
+         src += srcRowStride;
+         dstRow += dstRowStride / sizeof(GLuint);
+      }
+   }
+   return GL_TRUE;
+}
 
 /**
  * Store an image in any of the formats:
index da0c7cb78e56550a9be2cf61cdf2a3aa727d4fbf..c5813fbeeec657f6736946f95377ce69926a50cc 100644 (file)
@@ -57,6 +57,7 @@ extern GLboolean _mesa_texstore_a8(TEXSTORE_PARAMS);
 extern GLboolean _mesa_texstore_ci8(TEXSTORE_PARAMS);
 extern GLboolean _mesa_texstore_ycbcr(TEXSTORE_PARAMS);
 extern GLboolean _mesa_texstore_z24_s8(TEXSTORE_PARAMS);
+extern GLboolean _mesa_texstore_s8_z24(TEXSTORE_PARAMS);
 extern GLboolean _mesa_texstore_z16(TEXSTORE_PARAMS);
 extern GLboolean _mesa_texstore_z32(TEXSTORE_PARAMS);
 extern GLboolean _mesa_texstore_rgba_float32(TEXSTORE_PARAMS);