mesa: move _mesa_update_fetch_functions() calls into swrast
[mesa.git] / src / mesa / main / texfetch_tmp.h
index 9d57ad7679bd2a59b8d5acca0746ba7f1412d7e0..dbed3dba99b4a574333eb770caef7440b4e92ed6 100644 (file)
@@ -438,6 +438,110 @@ static void store_texel_intensity_f16(struct gl_texture_image *texImage,
 #endif
 
 
+/* MESA_FORMAT_R_FLOAT32 *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D R_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_r_f32)( const struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+   texel[RCOMP] = src[0];
+   texel[GCOMP] = 0.0F;
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_r_f32(struct gl_texture_image *texImage,
+                              GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *rgba = (const GLfloat *) texel;
+   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+   dst[0] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_R_FLOAT16 *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D R_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_r_f16)( const struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+   texel[RCOMP] = _mesa_half_to_float(src[0]);
+   texel[GCOMP] = 0.0F;
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_r_f16(struct gl_texture_image *texImage,
+                              GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *rgba = (const GLfloat *) texel;
+   GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+   dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RG_FLOAT32 ****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RG_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_rg_f32)( const struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+   texel[RCOMP] = src[0];
+   texel[GCOMP] = src[1];
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rg_f32(struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *rgba = (const GLfloat *) texel;
+   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+   dst[0] = rgba[RCOMP];
+   dst[1] = rgba[GCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RG_FLOAT16 ****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RG_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_rg_f16)( const struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
+   texel[RCOMP] = _mesa_half_to_float(src[0]);
+   texel[GCOMP] = _mesa_half_to_float(src[1]);
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rg_f16(struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *rgba = (const GLfloat *) texel;
+   GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
+   dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+   dst[1] = _mesa_float_to_half(rgba[GCOMP]);
+}
+#endif
 
 
 /*
@@ -688,9 +792,12 @@ static void FETCH(f_rgb565_rev)( const struct gl_texture_image *texImage,
 static void store_texel_rgb565_rev(struct gl_texture_image *texImage,
                                   GLint i, GLint j, GLint k, const void *texel)
 {
-   const GLubyte *rgba = (const GLubyte *) texel;
+   const GLchan *rgba = (const GLchan *) texel;
    GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_565(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
+   GLushort p = PACK_COLOR_565(CHAN_TO_UBYTE(rgba[RCOMP]),
+                               CHAN_TO_UBYTE(rgba[GCOMP]),
+                               CHAN_TO_UBYTE(rgba[BCOMP]));
+   *dst = (p >> 8) | (p << 8); /* byte swap */
 }
 #endif
 
@@ -713,9 +820,12 @@ static void FETCH(f_argb4444)( const struct gl_texture_image *texImage,
 static void store_texel_argb4444(struct gl_texture_image *texImage,
                                  GLint i, GLint j, GLint k, const void *texel)
 {
-   const GLubyte *rgba = (const GLubyte *) texel;
+   const GLchan *rgba = (const GLchan *) texel;
    GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+   *dst = PACK_COLOR_4444(CHAN_TO_UBYTE(rgba[ACOMP]),
+                          CHAN_TO_UBYTE(rgba[RCOMP]),
+                          CHAN_TO_UBYTE(rgba[GCOMP]),
+                          CHAN_TO_UBYTE(rgba[BCOMP]));
 }
 #endif
 
@@ -737,9 +847,12 @@ static void FETCH(f_argb4444_rev)( const struct gl_texture_image *texImage,
 static void store_texel_argb4444_rev(struct gl_texture_image *texImage,
                                  GLint i, GLint j, GLint k, const void *texel)
 {
-   const GLubyte *rgba = (const GLubyte *) texel;
+   const GLchan *rgba = (const GLchan *) texel;
    GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
+   *dst = PACK_COLOR_4444(CHAN_TO_UBYTE(rgba[GCOMP]),
+                          CHAN_TO_UBYTE(rgba[BCOMP]),
+                          CHAN_TO_UBYTE(rgba[ACOMP]),
+                          CHAN_TO_UBYTE(rgba[RCOMP]));
 }
 #endif
 
@@ -835,9 +948,13 @@ static void FETCH(f_argb2101010)( const struct gl_texture_image *texImage,
 static void store_texel_argb2101010(struct gl_texture_image *texImage,
                                     GLint i, GLint j, GLint k, const void *texel)
 {
-   const GLubyte *rgba = (const GLubyte *) texel;
+   const GLchan *rgba = (const GLchan *) texel;
    GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_2101010(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+   GLushort r = CHAN_TO_USHORT(rgba[RCOMP]);
+   GLushort g = CHAN_TO_USHORT(rgba[GCOMP]);
+   GLushort b = CHAN_TO_USHORT(rgba[BCOMP]);
+   GLushort a = CHAN_TO_USHORT(rgba[ACOMP]);
+   *dst = PACK_COLOR_2101010_US(a, r, g, b);
 }
 #endif
 
@@ -859,9 +976,11 @@ static void FETCH(f_rg88)( const struct gl_texture_image *texImage,
 static void store_texel_rg88(struct gl_texture_image *texImage,
                              GLint i, GLint j, GLint k, const void *texel)
 {
-   const GLubyte *rgba = (const GLubyte *) texel;
+   const GLchan *rgba = (const GLubyte *) texel;
    GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_88(rgba[RCOMP], rgba[GCOMP]);
+   GLubyte r = CHAN_TO_UBYTE(rgba[RCOMP]);
+   GLubyte g = CHAN_TO_UBYTE(rgba[GCOMP]);
+   *dst = PACK_COLOR_88(g, r);
 }
 #endif
 
@@ -979,9 +1098,9 @@ static void FETCH(f_r16)(const struct gl_texture_image *texImage,
 static void store_texel_r16(struct gl_texture_image *texImage,
                            GLint i, GLint j, GLint k, const void *texel)
 {
-   const GLushort *rgba = (const GLushort *) texel;
+   const GLchan *rgba = (const GLchan *) texel;
    GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = rgba[RCOMP];
+   *dst = CHAN_TO_USHORT(rgba[RCOMP]);
 }
 #endif
 
@@ -1027,9 +1146,11 @@ static void FETCH(f_rg1616)( const struct gl_texture_image *texImage,
 static void store_texel_rg1616(struct gl_texture_image *texImage,
                              GLint i, GLint j, GLint k, const void *texel)
 {
-   const GLubyte *rgba = (const GLubyte *) texel;
-   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_1616(rgba[RCOMP], rgba[GCOMP]);
+   const GLchan *rgba = (const GLchan *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   GLushort r = CHAN_TO_USHORT(rgba[RCOMP]);
+   GLushort g = CHAN_TO_USHORT(rgba[GCOMP]);
+   *dst = PACK_COLOR_1616(g, r);
 }
 #endif
 
@@ -1075,9 +1196,11 @@ static void FETCH(f_al1616)( const struct gl_texture_image *texImage,
 static void store_texel_al1616(struct gl_texture_image *texImage,
                              GLint i, GLint j, GLint k, const void *texel)
 {
-   const GLushort *rgba = (const GLushort *) texel;
+   const GLchan *rgba = (const GLchan *) texel;
    GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_1616(rgba[ACOMP], rgba[RCOMP]);
+   GLushort l = CHAN_TO_USHORT(rgba[RCOMP]);
+   GLushort a = CHAN_TO_USHORT(rgba[ACOMP]);
+   *dst = PACK_COLOR_1616(a, l);
 }
 #endif
 
@@ -1172,9 +1295,9 @@ static void FETCH(f_a16)( const struct gl_texture_image *texImage,
 static void store_texel_a16(struct gl_texture_image *texImage,
                             GLint i, GLint j, GLint k, const void *texel)
 {
-   const GLushort *rgba = (const GLushort *) texel;
+   const GLchan *rgba = (const GLchan *) texel;
    GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = rgba[ACOMP];
+   *dst = CHAN_TO_USHORT(rgba[ACOMP]);
 }
 #endif
 
@@ -1275,88 +1398,6 @@ static void store_texel_i16(struct gl_texture_image *texImage,
 #endif
 
 
-/* MESA_FORMAT_CI8 ***********************************************************/
-
-/* Fetch CI texel from 1D, 2D or 3D ci8 texture, lookup the index in a
- * color table, and return 4 GLchans.
- */
-static void FETCH(f_ci8)( const struct gl_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
-   const struct gl_color_table *palette;
-   GLuint index;
-   GET_CURRENT_CONTEXT(ctx);
-
-   if (ctx->Texture.SharedPalette) {
-      palette = &ctx->Texture.Palette;
-   }
-   else {
-      palette = &texImage->TexObject->Palette;
-   }
-   if (palette->Size == 0)
-      return; /* undefined results */
-
-   /* Mask the index against size of palette to avoid going out of bounds */
-   index = (*src) & (palette->Size - 1);
-
-   {
-      const GLfloat *table = palette->TableF;
-      switch (palette->_BaseFormat) {
-      case GL_ALPHA:
-         texel[RCOMP] =
-         texel[GCOMP] =
-         texel[BCOMP] = 0.0F;
-         texel[ACOMP] = table[index];
-         break;
-      case GL_LUMINANCE:
-         texel[RCOMP] =
-         texel[GCOMP] =
-         texel[BCOMP] = table[index];
-         texel[ACOMP] = 1.0F;
-         break;
-      case GL_INTENSITY:
-         texel[RCOMP] =
-         texel[GCOMP] =
-         texel[BCOMP] =
-         texel[ACOMP] = table[index];
-         break;
-      case GL_LUMINANCE_ALPHA:
-         texel[RCOMP] =
-         texel[GCOMP] =
-         texel[BCOMP] = table[index * 2 + 0];
-         texel[ACOMP] = table[index * 2 + 1];
-         break;
-      case GL_RGB:
-         texel[RCOMP] = table[index * 3 + 0];
-         texel[GCOMP] = table[index * 3 + 1];
-         texel[BCOMP] = table[index * 3 + 2];
-         texel[ACOMP] = 1.0F;
-         break;
-      case GL_RGBA:
-         texel[RCOMP] = table[index * 4 + 0];
-         texel[GCOMP] = table[index * 4 + 1];
-         texel[BCOMP] = table[index * 4 + 2];
-         texel[ACOMP] = table[index * 4 + 3];
-         break;
-      default:
-         _mesa_problem(ctx, "Bad palette format in fetch_texel_ci8");
-         return;
-      }
-   }
-}
-
-#if DIM == 3
-static void store_texel_ci8(struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, const void *texel)
-{
-   const GLubyte *index = (const GLubyte *) texel;
-   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
-   *dst = *index;
-}
-#endif
-
-
 /* Fetch texel from 1D, 2D or 3D srgb8 texture, return 4 GLfloats */
 /* Note: component order is same as for MESA_FORMAT_RGB888 */
 static void FETCH(srgb8)(const struct gl_texture_image *texImage,
@@ -1673,25 +1714,117 @@ static void store_texel_signed_r8(struct gl_texture_image *texImage,
 #endif
 
 
-/* MESA_FORMAT_SIGNED_RG88 ***********************************************/
+/* MESA_FORMAT_SIGNED_A8 ***********************************************/
 
-static void FETCH(signed_rg88)( const struct gl_texture_image *texImage,
-                                GLint i, GLint j, GLint k, GLfloat *texel )
+static void FETCH(signed_a8)( const struct gl_texture_image *texImage,
+                              GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+   texel[RCOMP] = 0.0F;
+   texel[GCOMP] = 0.0F;
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = BYTE_TO_FLOAT_TEX( s );
+}
+
+#if DIM == 3
+static void store_texel_signed_a8(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLbyte *rgba = (const GLbyte *) texel;
+   GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+   *dst = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_L8 ***********************************************/
+
+static void FETCH(signed_l8)( const struct gl_texture_image *texImage,
+                              GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = BYTE_TO_FLOAT_TEX( s );
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_signed_l8(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLbyte *rgba = (const GLbyte *) texel;
+   GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+   *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_I8 ***********************************************/
+
+static void FETCH(signed_i8)( const struct gl_texture_image *texImage,
+                              GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] =
+   texel[ACOMP] = BYTE_TO_FLOAT_TEX( s );
+}
+
+#if DIM == 3
+static void store_texel_signed_i8(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLbyte *rgba = (const GLbyte *) texel;
+   GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+   *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RG88_REV ***********************************************/
+
+static void FETCH(signed_rg88_rev)( const struct gl_texture_image *texImage,
+                                    GLint i, GLint j, GLint k, GLfloat *texel )
 {
    const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
-   texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
-   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
+   texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
+   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
    texel[BCOMP] = 0.0F;
    texel[ACOMP] = 1.0F;
 }
 
 #if DIM == 3
-static void store_texel_signed_rg88(struct gl_texture_image *texImage,
+static void store_texel_signed_rg88_rev(struct gl_texture_image *texImage,
+                                        GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLbyte *rg = (const GLbyte *) texel;
+   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   dst[0] = PACK_COLOR_88(rg[GCOMP], rg[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_AL88 ***********************************************/
+
+static void FETCH(signed_al88)( const struct gl_texture_image *texImage,
+                                GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
+   texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
+}
+
+#if DIM == 3
+static void store_texel_signed_al88(struct gl_texture_image *texImage,
                                     GLint i, GLint j, GLint k, const void *texel)
 {
    const GLbyte *rg = (const GLbyte *) texel;
-   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 2);
-   *dst = PACK_COLOR_88(rg[RCOMP], rg[GCOMP]);
+   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   dst[0] = PACK_COLOR_88(rg[ACOMP], rg[RCOMP]);
 }
 #endif
 
@@ -1763,11 +1896,11 @@ static void store_texel_signed_rgba8888_rev(struct gl_texture_image *texImage,
 
 
 
-/* MESA_FORMAT_SIGNED_R_16 ***********************************************/
+/* MESA_FORMAT_SIGNED_R16 ***********************************************/
 
 static void
-FETCH(signed_r_16)(const struct gl_texture_image *texImage,
-                   GLint i, GLint j, GLint k, GLfloat *texel)
+FETCH(signed_r16)(const struct gl_texture_image *texImage,
+                  GLint i, GLint j, GLint k, GLfloat *texel)
 {
    const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
    texel[RCOMP] = SHORT_TO_FLOAT_TEX( s );
@@ -1778,8 +1911,8 @@ FETCH(signed_r_16)(const struct gl_texture_image *texImage,
 
 #if DIM == 3
 static void
-store_texel_signed_r_16(struct gl_texture_image *texImage,
-                        GLint i, GLint j, GLint k, const void *texel)
+store_texel_signed_r16(struct gl_texture_image *texImage,
+                       GLint i, GLint j, GLint k, const void *texel)
 {
    const GLshort *rgba = (const GLshort *) texel;
    GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
@@ -1788,10 +1921,85 @@ store_texel_signed_r_16(struct gl_texture_image *texImage,
 #endif
 
 
-/* MESA_FORMAT_SIGNED_RG_16 ***********************************************/
+/* MESA_FORMAT_SIGNED_A16 ***********************************************/
 
 static void
-FETCH(signed_rg_16)(const struct gl_texture_image *texImage,
+FETCH(signed_a16)(const struct gl_texture_image *texImage,
+                  GLint i, GLint j, GLint k, GLfloat *texel)
+{
+   const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+   texel[RCOMP] = 0.0F;
+   texel[GCOMP] = 0.0F;
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = SHORT_TO_FLOAT_TEX( s );
+}
+
+#if DIM == 3
+static void
+store_texel_signed_a16(struct gl_texture_image *texImage,
+                       GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLshort *rgba = (const GLshort *) texel;
+   GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+   *dst = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_L16 ***********************************************/
+
+static void
+FETCH(signed_l16)(const struct gl_texture_image *texImage,
+                  GLint i, GLint j, GLint k, GLfloat *texel)
+{
+   const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = SHORT_TO_FLOAT_TEX( s );
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void
+store_texel_signed_l16(struct gl_texture_image *texImage,
+                       GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLshort *rgba = (const GLshort *) texel;
+   GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+   *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_I16 ***********************************************/
+
+static void
+FETCH(signed_i16)(const struct gl_texture_image *texImage,
+                  GLint i, GLint j, GLint k, GLfloat *texel)
+{
+   const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] =
+   texel[ACOMP] = SHORT_TO_FLOAT_TEX( s );
+}
+
+#if DIM == 3
+static void
+store_texel_signed_i16(struct gl_texture_image *texImage,
+                       GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLshort *rgba = (const GLshort *) texel;
+   GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+   *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RG1616 ***********************************************/
+
+static void
+FETCH(signed_rg1616)(const struct gl_texture_image *texImage,
                     GLint i, GLint j, GLint k, GLfloat *texel)
 {
    const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
@@ -1803,18 +2011,44 @@ FETCH(signed_rg_16)(const struct gl_texture_image *texImage,
 
 #if DIM == 3
 static void
-store_texel_signed_rg_16(struct gl_texture_image *texImage,
+store_texel_signed_rg1616(struct gl_texture_image *texImage,
                          GLint i, GLint j, GLint k, const void *texel)
 {
-   const GLshort *rgba = (const GLshort *) texel;
+   const GLchan *rgba = (const GLchan *) texel;
    GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
-   dst[0] = rgba[RCOMP];
-   dst[1] = rgba[GCOMP];
+   dst[0] = CHAN_TO_SHORT(rgba[RCOMP]);
+   dst[1] = CHAN_TO_SHORT(rgba[GCOMP]);
 }
 #endif
 
 
-/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/
+/* MESA_FORMAT_SIGNED_AL1616 ***********************************************/
+
+static void
+FETCH(signed_al1616)(const struct gl_texture_image *texImage,
+                    GLint i, GLint j, GLint k, GLfloat *texel)
+{
+   const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
+   texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[1] );
+}
+
+#if DIM == 3
+static void
+store_texel_signed_al1616(struct gl_texture_image *texImage,
+                         GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLchan *rgba = (const GLchan *) texel;
+   GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
+   dst[0] = CHAN_TO_SHORT(rgba[RCOMP]);
+   dst[1] = CHAN_TO_SHORT(rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RGB_16 ***********************************************/
 
 static void 
 FETCH(signed_rgb_16)(const struct gl_texture_image *texImage,
@@ -1832,11 +2066,11 @@ static void
 store_texel_signed_rgb_16(struct gl_texture_image *texImage,
                           GLint i, GLint j, GLint k, const void *texel)
 {
-   const GLshort *rgba = (const GLshort *) texel;
+   const GLchan *rgba = (const GLchan *) texel;
    GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 3);
-   dst[0] = rgba[RCOMP];
-   dst[1] = rgba[GCOMP];
-   dst[2] = rgba[BCOMP];
+   dst[0] = CHAN_TO_SHORT(rgba[RCOMP]);
+   dst[1] = CHAN_TO_SHORT(rgba[GCOMP]);
+   dst[2] = CHAN_TO_SHORT(rgba[BCOMP]);
 }
 #endif
 
@@ -1859,12 +2093,12 @@ static void
 store_texel_signed_rgba_16(struct gl_texture_image *texImage,
                            GLint i, GLint j, GLint k, const void *texel)
 {
-   const GLshort *rgba = (const GLshort *) texel;
+   const GLchan *rgba = (const GLchan *) texel;
    GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
-   dst[0] = rgba[RCOMP];
-   dst[1] = rgba[GCOMP];
-   dst[2] = rgba[BCOMP];
-   dst[3] = rgba[ACOMP];
+   dst[0] = CHAN_TO_SHORT(rgba[RCOMP]);
+   dst[1] = CHAN_TO_SHORT(rgba[GCOMP]);
+   dst[2] = CHAN_TO_SHORT(rgba[BCOMP]);
+   dst[3] = CHAN_TO_SHORT(rgba[ACOMP]);
 }
 #endif
 
@@ -1888,12 +2122,12 @@ static void
 store_texel_rgba_16(struct gl_texture_image *texImage,
                     GLint i, GLint j, GLint k, const void *texel)
 {
-   const GLushort *rgba = (const GLushort *) texel;
+   const GLchan *rgba = (const GLchan *) texel;
    GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
-   dst[0] = rgba[RCOMP];
-   dst[1] = rgba[GCOMP];
-   dst[2] = rgba[BCOMP];
-   dst[3] = rgba[ACOMP];
+   dst[0] = CHAN_TO_USHORT(rgba[RCOMP]);
+   dst[1] = CHAN_TO_USHORT(rgba[GCOMP]);
+   dst[2] = CHAN_TO_USHORT(rgba[BCOMP]);
+   dst[3] = CHAN_TO_USHORT(rgba[ACOMP]);
 }
 #endif
 
@@ -1990,7 +2224,8 @@ static void FETCH(f_z24_s8)( const struct gl_texture_image *texImage,
    const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
    const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
    texel[0] = ((*src) >> 8) * scale;
-   ASSERT(texImage->TexFormat == MESA_FORMAT_Z24_S8);
+   ASSERT(texImage->TexFormat == MESA_FORMAT_Z24_S8 ||
+         texImage->TexFormat == MESA_FORMAT_Z24_X8);
    ASSERT(texel[0] >= 0.0F);
    ASSERT(texel[0] <= 1.0F);
 }
@@ -2017,7 +2252,8 @@ static void FETCH(f_s8_z24)( const struct gl_texture_image *texImage,
    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 == MESA_FORMAT_S8_Z24);
+   ASSERT(texImage->TexFormat == MESA_FORMAT_S8_Z24 ||
+         texImage->TexFormat == MESA_FORMAT_X8_Z24);
    ASSERT(texel[0] >= 0.0F);
    ASSERT(texel[0] <= 1.0F);
 }
@@ -2035,6 +2271,71 @@ static void store_texel_s8_z24(struct gl_texture_image *texImage,
 #endif
 
 
+/* MESA_FORMAT_RGB9_E5 ******************************************************/
+
+static void FETCH(rgb9_e5)( const struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   rgb9e5_to_float3(*src, texel);
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb9_e5(struct gl_texture_image *texImage,
+                                GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *src = (const GLfloat *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = float3_to_rgb9e5(src);
+}
+#endif
+
+
+/* MESA_FORMAT_R11_G11_B10_FLOAT *********************************************/
+
+static void FETCH(r11_g11_b10f)( const struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   r11g11b10f_to_float3(*src, texel);
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_r11_g11_b10f(struct gl_texture_image *texImage,
+                                     GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *src = (const GLfloat *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = float3_to_r11g11b10f(src);
+}
+#endif
+
+
+/* MESA_FORMAT_Z32_FLOAT_X24S8 ***********************************************/
+
+static void FETCH(z32f_x24s8)(const struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel)
+{
+   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+   texel[RCOMP] = src[0];
+   texel[GCOMP] = 0.0F;
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_z32f_x24s8(struct gl_texture_image *texImage,
+                                   GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *src = (const GLfloat *) texel;
+   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+   dst[0] = src[0];
+}
+#endif
+
+
 #undef TEXEL_ADDR
 #undef DIM
 #undef FETCH