mesa: Most of the functions of MESA_TEXTURE_S8_Z24 are now supported
authorJakob Bornecrantz <jakob@tungstengraphics.com>
Mon, 9 Jun 2008 14:29:57 +0000 (16:29 +0200)
committerJakob Bornecrantz <jakob@tungstengraphics.com>
Mon, 9 Jun 2008 14:33:14 +0000 (16:33 +0200)
src/mesa/main/texformat.c
src/mesa/main/texformat_tmp.h

index d479bf510ee3ae083cd7314795254a37ed5be9cd..17859a9fec6edf554544f4f599e7108d6effe860 100644 (file)
@@ -1229,17 +1229,10 @@ const struct gl_texture_format _mesa_texformat_s8_z24 = {
    NULL,                               /* FetchTexel1D */
    NULL,                               /* FetchTexel2D */
    NULL,                               /* FetchTexel3D */
-#if 0
    fetch_texel_1d_f_s8_z24,            /* FetchTexel1Df */
    fetch_texel_2d_f_s8_z24,            /* FetchTexel2Df */
    fetch_texel_3d_f_s8_z24,            /* FetchTexel3Df */
    store_texel_s8_z24                  /* StoreTexel */
-#else
-   fetch_texel_1d_f_z24_s8,            /* FetchTexel1Df */
-   fetch_texel_2d_f_z24_s8,            /* FetchTexel2Df */
-   fetch_texel_3d_f_z24_s8,            /* FetchTexel3Df */
-   store_texel_z24_s8                  /* StoreTexel */
-#endif
 };
 
 const struct gl_texture_format _mesa_texformat_z16 = {
@@ -1675,6 +1668,11 @@ _mesa_format_to_type_and_comps(const struct gl_texture_format *format,
       *comps = 1; /* XXX OK? */
       return;
 
+   case MESA_FORMAT_S8_Z24:
+      *datatype = GL_UNSIGNED_INT;
+      *comps = 1; /* XXX OK? */
+      return;
+
    case MESA_FORMAT_Z16:
       *datatype = GL_UNSIGNED_SHORT;
       *comps = 1;
index 99785da1a0a2f6206d2bcaa932a875f24ca78dfa..63939f40111ae3d97d81347ea3ffa92022320430 100644 (file)
@@ -1363,6 +1363,32 @@ static void store_texel_z24_s8(struct gl_texture_image *texImage,
 #endif
 
 
+/* MESA_TEXFORMAT_S8_Z24 ***************************************************/
+
+static void FETCH(f_s8_z24)( const struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   /* only return Z, not stencil data */
+   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
+   texel[0] = ((*src) & 0x00ffffff) * scale;
+   ASSERT(texImage->TexFormat->MesaFormat == MESA_FORMAT_S8_Z24);
+   ASSERT(texel[0] >= 0.0F);
+   ASSERT(texel[0] <= 1.0F);
+}
+
+#if DIM == 3
+static void store_texel_s8_z24(struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, const void *texel)
+{
+   /* only store Z, not stencil */
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   GLfloat depth = *((GLfloat *) texel);
+   GLuint zi = (GLuint) (depth * 0xffffff);
+   *dst = zi | (*dst & 0xff000000);
+}
+#endif
+
 
 #undef TEXEL_ADDR
 #undef DIM