texenv: Match state.c in deciding whether we'll be using a vertex shader.
[mesa.git] / src / mesa / main / texformat.c
index 794dea313aa41331dfcaa44267f847741853792c..c709004784b624d15664a5bf6d9982429cdf9bc9 100644 (file)
@@ -1,8 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
+ * Version:  6.5.1
  *
- * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (c) 2008 VMware, Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
 #include "texstore.h"
 
 
+#if FEATURE_EXT_texture_sRGB
+
+/**
+ * Convert an 8-bit sRGB value from non-linear space to a
+ * linear RGB value in [0, 1].
+ * Implemented with a 256-entry lookup table.
+ */
+static INLINE GLfloat
+nonlinear_to_linear(GLubyte cs8)
+{
+   static GLfloat table[256];
+   static GLboolean tableReady = GL_FALSE;
+   if (!tableReady) {
+      /* compute lookup table now */
+      GLuint i;
+      for (i = 0; i < 256; i++) {
+         const GLfloat cs = UBYTE_TO_FLOAT(i);
+         if (cs <= 0.04045) {
+            table[i] = cs / 12.92f;
+         }
+         else {
+            table[i] = (GLfloat) _mesa_pow((cs + 0.055) / 1.055, 2.4);
+         }
+      }
+      tableReady = GL_TRUE;
+   }
+   return table[cs8];
+}
+
+
+#endif /* FEATURE_EXT_texture_sRGB */
+
 
 /* Texel fetch routines for all supported formats
  */
@@ -79,6 +112,11 @@ static void fetch_null_texelf( const struct gl_texture_image *texImage,
 static void store_null_texel(struct gl_texture_image *texImage,
                              GLint i, GLint j, GLint k, const void *texel)
 {
+   (void) texImage;
+   (void) i;
+   (void) j;
+   (void) k;
+   (void) texel;
    /* no-op */
 }
 
@@ -113,11 +151,12 @@ const struct gl_texture_format _mesa_texformat_rgba = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    4 * sizeof(GLchan),                 /* TexelBytes */
    _mesa_texstore_rgba,                        /* StoreTexImageFunc */
-   fetch_texel_1d_rgba,                        /* FetchTexel1D */
-   fetch_texel_2d_rgba,                        /* FetchTexel2D */
-   fetch_texel_3d_rgba,                        /* FetchTexel3D */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
    fetch_texel_1d_f_rgba,              /* FetchTexel1Df */
    fetch_texel_2d_f_rgba,              /* FetchTexel2Df */
    fetch_texel_3d_f_rgba,              /* FetchTexel3Df */
@@ -136,11 +175,12 @@ const struct gl_texture_format _mesa_texformat_rgb = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    3 * sizeof(GLchan),                 /* TexelBytes */
    _mesa_texstore_rgba,/*yes*/         /* StoreTexImageFunc */
-   fetch_texel_1d_rgb,                 /* FetchTexel1D */
-   fetch_texel_2d_rgb,                 /* FetchTexel2D */
-   fetch_texel_3d_rgb,                 /* FetchTexel3D */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
    fetch_texel_1d_f_rgb,               /* FetchTexel1Df */
    fetch_texel_2d_f_rgb,               /* FetchTexel2Df */
    fetch_texel_3d_f_rgb,               /* FetchTexel3Df */
@@ -159,14 +199,15 @@ const struct gl_texture_format _mesa_texformat_alpha = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    sizeof(GLchan),                     /* TexelBytes */
    _mesa_texstore_rgba,/*yes*/         /* StoreTexImageFunc */
-   fetch_texel_1d_alpha,               /* FetchTexel1D */
-   fetch_texel_2d_alpha,               /* FetchTexel2D */
-   fetch_texel_3d_alpha,               /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_alpha,             /* FetchTexel1Df */
+   fetch_texel_2d_f_alpha,             /* FetchTexel2Df */
+   fetch_texel_3d_f_alpha,             /* FetchTexel3Df */
    store_texel_alpha                   /* StoreTexel */
 };
 
@@ -182,14 +223,15 @@ const struct gl_texture_format _mesa_texformat_luminance = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    sizeof(GLchan),                     /* TexelBytes */
    _mesa_texstore_rgba,/*yes*/         /* StoreTexImageFunc */
-   fetch_texel_1d_luminance,           /* FetchTexel1D */
-   fetch_texel_2d_luminance,           /* FetchTexel2D */
-   fetch_texel_3d_luminance,           /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_luminance,         /* FetchTexel1Df */
+   fetch_texel_2d_f_luminance,         /* FetchTexel2Df */
+   fetch_texel_3d_f_luminance,         /* FetchTexel3Df */
    store_texel_luminance               /* StoreTexel */
 };
 
@@ -205,14 +247,15 @@ const struct gl_texture_format _mesa_texformat_luminance_alpha = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    2 * sizeof(GLchan),                 /* TexelBytes */
    _mesa_texstore_rgba,/*yes*/         /* StoreTexImageFunc */
-   fetch_texel_1d_luminance_alpha,     /* FetchTexel1D */
-   fetch_texel_2d_luminance_alpha,     /* FetchTexel2D */
-   fetch_texel_3d_luminance_alpha,     /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_luminance_alpha,   /* FetchTexel1Df */
+   fetch_texel_2d_f_luminance_alpha,   /* FetchTexel2Df */
+   fetch_texel_3d_f_luminance_alpha,   /* FetchTexel3Df */
    store_texel_luminance_alpha         /* StoreTexel */
 };
 
@@ -228,63 +271,144 @@ const struct gl_texture_format _mesa_texformat_intensity = {
    CHAN_BITS,                          /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    sizeof(GLchan),                     /* TexelBytes */
    _mesa_texstore_rgba,/*yes*/         /* StoreTexImageFunc */
-   fetch_texel_1d_intensity,           /* FetchTexel1D */
-   fetch_texel_2d_intensity,           /* FetchTexel2D */
-   fetch_texel_3d_intensity,           /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_intensity,         /* FetchTexel1Df */
+   fetch_texel_2d_f_intensity,         /* FetchTexel2Df */
+   fetch_texel_3d_f_intensity,         /* FetchTexel3Df */
    store_texel_intensity               /* StoreTexel */
 };
 
-const struct gl_texture_format _mesa_texformat_depth_component_float32 = {
-   MESA_FORMAT_DEPTH_COMPONENT_FLOAT32,        /* MesaFormat */
-   GL_DEPTH_COMPONENT,                 /* BaseFormat */
+
+#if FEATURE_EXT_texture_sRGB
+
+const struct gl_texture_format _mesa_texformat_srgb8 = {
+   MESA_FORMAT_SRGB8,                  /* MesaFormat */
+   GL_RGB,                             /* BaseFormat */
    GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
+   8,                                  /* RedBits */
+   8,                                  /* GreenBits */
+   8,                                  /* BlueBits */
    0,                                  /* AlphaBits */
    0,                                  /* LuminanceBits */
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
-   sizeof(GLfloat) * 8,                        /* DepthBits */
-   sizeof(GLfloat),                    /* TexelBytes */
-   _mesa_texstore_depth_component_float32,/* StoreTexImageFunc */
+   0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
+   3,                                  /* TexelBytes */
+   _mesa_texstore_srgb8,               /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_srgb8,               /* FetchTexel1Df */
+   fetch_texel_2d_srgb8,               /* FetchTexel2Df */
+   fetch_texel_3d_srgb8,               /* FetchTexel3Df */
+   store_texel_srgb8                   /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_srgba8 = {
+   MESA_FORMAT_SRGBA8,                 /* MesaFormat */
+   GL_RGBA,                            /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   8,                                  /* RedBits */
+   8,                                  /* GreenBits */
+   8,                                  /* BlueBits */
+   8,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
+   4,                                  /* TexelBytes */
+   _mesa_texstore_srgba8,              /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_srgba8,              /* FetchTexel1Df */
+   fetch_texel_2d_srgba8,              /* FetchTexel2Df */
+   fetch_texel_3d_srgba8,              /* FetchTexel3Df */
+   store_texel_srgba8                  /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_sargb8 = {
+   MESA_FORMAT_SARGB8,                 /* MesaFormat */
+   GL_RGBA,                            /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   8,                                  /* RedBits */
+   8,                                  /* GreenBits */
+   8,                                  /* BlueBits */
+   8,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
+   4,                                  /* TexelBytes */
+   _mesa_texstore_sargb8,              /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
-   fetch_texel_1d_f_depth_component_f32,/* FetchTexel1Df */
-   fetch_texel_2d_f_depth_component_f32,/* FetchTexel2Df */
-   fetch_texel_3d_f_depth_component_f32,/* FetchTexel3Df */
-   store_texel_depth_component_f32     /* StoreTexel */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_sargb8,              /* FetchTexel1Df */
+   fetch_texel_2d_sargb8,              /* FetchTexel2Df */
+   fetch_texel_3d_sargb8,              /* FetchTexel3Df */
+   store_texel_sargb8                  /* StoreTexel */
 };
 
-const struct gl_texture_format _mesa_texformat_depth_component16 = {
-   MESA_FORMAT_DEPTH_COMPONENT16,      /* MesaFormat */
-   GL_DEPTH_COMPONENT,                 /* BaseFormat */
+const struct gl_texture_format _mesa_texformat_sl8 = {
+   MESA_FORMAT_SL8,                    /* MesaFormat */
+   GL_LUMINANCE,                       /* BaseFormat */
    GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
    0,                                  /* RedBits */
    0,                                  /* GreenBits */
    0,                                  /* BlueBits */
    0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
+   8,                                  /* LuminanceBits */
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
-   sizeof(GLushort) * 8,               /* DepthBits */
-   sizeof(GLushort),                   /* TexelBytes */
-   _mesa_texstore_depth_component16,   /* StoreTexImageFunc */
-   NULL,                               /* FetchTexel1D */
+   0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
+   1,                                  /* TexelBytes */
+   _mesa_texstore_sl8,                 /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_sl8,                 /* FetchTexel1Df */
+   fetch_texel_2d_sl8,                 /* FetchTexel2Df */
+   fetch_texel_3d_sl8,                 /* FetchTexel3Df */
+   store_texel_sl8                     /* StoreTexel */
+};
+
+/* Note: this format name looks like a misnomer, make it sal8? */
+const struct gl_texture_format _mesa_texformat_sla8 = {
+   MESA_FORMAT_SLA8,                   /* MesaFormat */
+   GL_LUMINANCE_ALPHA,                 /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   0,                                  /* RedBits */
+   0,                                  /* GreenBits */
+   0,                                  /* BlueBits */
+   8,                                  /* AlphaBits */
+   8,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
+   2,                                  /* TexelBytes */
+   _mesa_texstore_sla8,                        /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
-   fetch_texel_1d_f_depth_component16, /* FetchTexel1Df */
-   fetch_texel_2d_f_depth_component16, /* FetchTexel2Df */
-   fetch_texel_3d_f_depth_component16, /* FetchTexel3Df */
-   store_texel_depth_component16       /* StoreTexel */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_sla8,                        /* FetchTexel1Df */
+   fetch_texel_2d_sla8,                        /* FetchTexel2Df */
+   fetch_texel_3d_sla8,                        /* FetchTexel3Df */
+   store_texel_sla8                    /* StoreTexel */
 };
 
+#endif /* FEATURE_EXT_texture_sRGB */
+
 const struct gl_texture_format _mesa_texformat_rgba_float32 = {
    MESA_FORMAT_RGBA_FLOAT32,           /* MesaFormat */
    GL_RGBA,                            /* BaseFormat */
@@ -297,6 +421,7 @@ const struct gl_texture_format _mesa_texformat_rgba_float32 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    4 * sizeof(GLfloat),                        /* TexelBytes */
    _mesa_texstore_rgba_float32,                /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
@@ -320,6 +445,7 @@ const struct gl_texture_format _mesa_texformat_rgba_float16 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    4 * sizeof(GLhalfARB),              /* TexelBytes */
    _mesa_texstore_rgba_float16,                /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
@@ -343,6 +469,7 @@ const struct gl_texture_format _mesa_texformat_rgb_float32 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    3 * sizeof(GLfloat),                        /* TexelBytes */
    _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
@@ -366,6 +493,7 @@ const struct gl_texture_format _mesa_texformat_rgb_float16 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    3 * sizeof(GLhalfARB),              /* TexelBytes */
    _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
@@ -389,6 +517,7 @@ const struct gl_texture_format _mesa_texformat_alpha_float32 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    1 * sizeof(GLfloat),                        /* TexelBytes */
    _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
@@ -412,6 +541,7 @@ const struct gl_texture_format _mesa_texformat_alpha_float16 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    1 * sizeof(GLhalfARB),              /* TexelBytes */
    _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
@@ -435,6 +565,7 @@ const struct gl_texture_format _mesa_texformat_luminance_float32 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    1 * sizeof(GLfloat),                        /* TexelBytes */
    _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
@@ -458,6 +589,7 @@ const struct gl_texture_format _mesa_texformat_luminance_float16 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    1 * sizeof(GLhalfARB),              /* TexelBytes */
    _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
@@ -481,6 +613,7 @@ const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    2 * sizeof(GLfloat),                        /* TexelBytes */
    _mesa_texstore_rgba_float32,                /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
@@ -504,6 +637,7 @@ const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    2 * sizeof(GLhalfARB),              /* TexelBytes */
    _mesa_texstore_rgba_float16,                /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
@@ -527,6 +661,7 @@ const struct gl_texture_format _mesa_texformat_intensity_float32 = {
    8 * sizeof(GLfloat),                        /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    1 * sizeof(GLfloat),                        /* TexelBytes */
    _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
@@ -550,6 +685,7 @@ const struct gl_texture_format _mesa_texformat_intensity_float16 = {
    8 * sizeof(GLhalfARB),              /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    1 * sizeof(GLhalfARB),              /* TexelBytes */
    _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
    NULL,                               /* FetchTexel1D */
@@ -561,6 +697,79 @@ const struct gl_texture_format _mesa_texformat_intensity_float16 = {
    store_texel_intensity_f16           /* StoreTexel */
 };
 
+const struct gl_texture_format _mesa_texformat_dudv8 = {
+   MESA_FORMAT_DUDV8,                  /* MesaFormat */
+   GL_DUDV_ATI,                                /* BaseFormat */
+   GL_SIGNED_NORMALIZED,               /* DataType */
+   /* maybe should add dudvBits field, but spec seems to be
+      lacking the ability to query with GetTexLevelParameter anyway */
+   0,                                  /* RedBits */
+   0,                                  /* GreenBits */
+   0,                                  /* BlueBits */
+   0,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
+   2,                                  /* TexelBytes */
+   _mesa_texstore_dudv8,               /* StoreTexImageFunc */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_dudv8,               /* FetchTexel1Df */
+   fetch_texel_2d_dudv8,               /* FetchTexel2Df */
+   fetch_texel_3d_dudv8,               /* FetchTexel3Df */
+   NULL                                        /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_signed_rgba8888 = {
+   MESA_FORMAT_SIGNED_RGBA8888,                /* MesaFormat */
+   GL_RGBA,                            /* BaseFormat */
+   GL_SIGNED_NORMALIZED,               /* DataType */
+   8,                                  /* RedBits */
+   8,                                  /* GreenBits */
+   8,                                  /* BlueBits */
+   8,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
+   4,                                  /* TexelBytes */
+   _mesa_texstore_signed_rgba8888,     /* StoreTexImageFunc */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_signed_rgba8888,     /* FetchTexel1Df */
+   fetch_texel_2d_signed_rgba8888,     /* FetchTexel2Df */
+   fetch_texel_3d_signed_rgba8888,     /* FetchTexel3Df */
+   store_texel_signed_rgba8888         /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_signed_rgba8888_rev = {
+   MESA_FORMAT_SIGNED_RGBA8888_REV,    /* MesaFormat */
+   GL_RGBA,                            /* BaseFormat */
+   GL_SIGNED_NORMALIZED,               /* DataType */
+   8,                                  /* RedBits */
+   8,                                  /* GreenBits */
+   8,                                  /* BlueBits */
+   8,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
+   4,                                  /* TexelBytes */
+   _mesa_texstore_signed_rgba8888,     /* StoreTexImageFunc */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_signed_rgba8888_rev, /* FetchTexel1Df */
+   fetch_texel_2d_signed_rgba8888_rev, /* FetchTexel2Df */
+   fetch_texel_3d_signed_rgba8888_rev, /* FetchTexel3Df */
+   store_texel_signed_rgba8888_rev             /* StoreTexel */
+};
 
 /*@}*/
 
@@ -581,14 +790,15 @@ const struct gl_texture_format _mesa_texformat_rgba8888 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    4,                                  /* TexelBytes */
    _mesa_texstore_rgba8888,            /* StoreTexImageFunc */
-   fetch_texel_1d_rgba8888,            /* FetchTexel1D */
-   fetch_texel_2d_rgba8888,            /* FetchTexel2D */
-   fetch_texel_3d_rgba8888,            /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_rgba8888,          /* FetchTexel1Df */
+   fetch_texel_2d_f_rgba8888,          /* FetchTexel2Df */
+   fetch_texel_3d_f_rgba8888,          /* FetchTexel3Df */
    store_texel_rgba8888                        /* StoreTexel */
 };
 
@@ -604,14 +814,15 @@ const struct gl_texture_format _mesa_texformat_rgba8888_rev = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    4,                                  /* TexelBytes */
    _mesa_texstore_rgba8888,            /* StoreTexImageFunc */
-   fetch_texel_1d_rgba8888_rev,                /* FetchTexel1D */
-   fetch_texel_2d_rgba8888_rev,                /* FetchTexel2D */
-   fetch_texel_3d_rgba8888_rev,                /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_rgba8888_rev,      /* FetchTexel1Df */
+   fetch_texel_2d_f_rgba8888_rev,      /* FetchTexel2Df */
+   fetch_texel_3d_f_rgba8888_rev,      /* FetchTexel3Df */
    store_texel_rgba8888_rev            /* StoreTexel */
 };
 
@@ -627,14 +838,15 @@ const struct gl_texture_format _mesa_texformat_argb8888 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    4,                                  /* TexelBytes */
    _mesa_texstore_argb8888,            /* StoreTexImageFunc */
-   fetch_texel_1d_argb8888,            /* FetchTexel1D */
-   fetch_texel_2d_argb8888,            /* FetchTexel2D */
-   fetch_texel_3d_argb8888,            /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_argb8888,          /* FetchTexel1Df */
+   fetch_texel_2d_f_argb8888,          /* FetchTexel2Df */
+   fetch_texel_3d_f_argb8888,          /* FetchTexel3Df */
    store_texel_argb8888                        /* StoreTexel */
 };
 
@@ -650,14 +862,15 @@ const struct gl_texture_format _mesa_texformat_argb8888_rev = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    4,                                  /* TexelBytes */
    _mesa_texstore_argb8888,            /* StoreTexImageFunc */
-   fetch_texel_1d_argb8888_rev,                /* FetchTexel1D */
-   fetch_texel_2d_argb8888_rev,                /* FetchTexel2D */
-   fetch_texel_3d_argb8888_rev,                /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_argb8888_rev,      /* FetchTexel1Df */
+   fetch_texel_2d_f_argb8888_rev,      /* FetchTexel2Df */
+   fetch_texel_3d_f_argb8888_rev,      /* FetchTexel3Df */
    store_texel_argb8888_rev            /* StoreTexel */
 };
 
@@ -673,14 +886,15 @@ const struct gl_texture_format _mesa_texformat_rgb888 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    3,                                  /* TexelBytes */
    _mesa_texstore_rgb888,              /* StoreTexImageFunc */
-   fetch_texel_1d_rgb888,              /* FetchTexel1D */
-   fetch_texel_2d_rgb888,              /* FetchTexel2D */
-   fetch_texel_3d_rgb888,              /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_rgb888,            /* FetchTexel1Df */
+   fetch_texel_2d_f_rgb888,            /* FetchTexel2Df */
+   fetch_texel_3d_f_rgb888,            /* FetchTexel3Df */
    store_texel_rgb888                  /* StoreTexel */
 };
 
@@ -696,14 +910,15 @@ const struct gl_texture_format _mesa_texformat_bgr888 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    3,                                  /* TexelBytes */
    _mesa_texstore_bgr888,              /* StoreTexImageFunc */
-   fetch_texel_1d_bgr888,              /* FetchTexel1D */
-   fetch_texel_2d_bgr888,              /* FetchTexel2D */
-   fetch_texel_3d_bgr888,              /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_bgr888,            /* FetchTexel1Df */
+   fetch_texel_2d_f_bgr888,            /* FetchTexel2Df */
+   fetch_texel_3d_f_bgr888,            /* FetchTexel3Df */
    store_texel_bgr888                  /* StoreTexel */
 };
 
@@ -719,14 +934,15 @@ const struct gl_texture_format _mesa_texformat_rgb565 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    2,                                  /* TexelBytes */
    _mesa_texstore_rgb565,              /* StoreTexImageFunc */
-   fetch_texel_1d_rgb565,              /* FetchTexel1D */
-   fetch_texel_2d_rgb565,              /* FetchTexel2D */
-   fetch_texel_3d_rgb565,              /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_rgb565,            /* FetchTexel1Df */
+   fetch_texel_2d_f_rgb565,            /* FetchTexel2Df */
+   fetch_texel_3d_f_rgb565,            /* FetchTexel3Df */
    store_texel_rgb565                  /* StoreTexel */
 };
 
@@ -742,17 +958,42 @@ const struct gl_texture_format _mesa_texformat_rgb565_rev = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    2,                                  /* TexelBytes */
    _mesa_texstore_rgb565,              /* StoreTexImageFunc */
-   fetch_texel_1d_rgb565_rev,          /* FetchTexel1D */
-   fetch_texel_2d_rgb565_rev,          /* FetchTexel2D */
-   fetch_texel_3d_rgb565_rev,          /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_rgb565_rev,                /* FetchTexel1Df */
+   fetch_texel_2d_f_rgb565_rev,                /* FetchTexel2Df */
+   fetch_texel_3d_f_rgb565_rev,                /* FetchTexel3Df */
    store_texel_rgb565_rev              /* StoreTexel */
 };
 
+const struct gl_texture_format _mesa_texformat_rgba4444 = {
+   MESA_FORMAT_RGBA4444,               /* MesaFormat */
+   GL_RGBA,                            /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   4,                                  /* RedBits */
+   4,                                  /* GreenBits */
+   4,                                  /* BlueBits */
+   4,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
+   2,                                  /* TexelBytes */
+   _mesa_texstore_rgba4444,            /* StoreTexImageFunc */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_rgba4444,          /* FetchTexel1Df */
+   fetch_texel_2d_f_rgba4444,          /* FetchTexel2Df */
+   fetch_texel_3d_f_rgba4444,          /* FetchTexel3Df */
+   store_texel_rgba4444                        /* StoreTexel */
+};
+
 const struct gl_texture_format _mesa_texformat_argb4444 = {
    MESA_FORMAT_ARGB4444,               /* MesaFormat */
    GL_RGBA,                            /* BaseFormat */
@@ -765,14 +1006,15 @@ const struct gl_texture_format _mesa_texformat_argb4444 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    2,                                  /* TexelBytes */
    _mesa_texstore_argb4444,            /* StoreTexImageFunc */
-   fetch_texel_1d_argb4444,            /* FetchTexel1D */
-   fetch_texel_2d_argb4444,            /* FetchTexel2D */
-   fetch_texel_3d_argb4444,            /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_argb4444,          /* FetchTexel1Df */
+   fetch_texel_2d_f_argb4444,          /* FetchTexel2Df */
+   fetch_texel_3d_f_argb4444,          /* FetchTexel3Df */
    store_texel_argb4444                        /* StoreTexel */
 };
 
@@ -788,17 +1030,42 @@ const struct gl_texture_format _mesa_texformat_argb4444_rev = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    2,                                  /* TexelBytes */
    _mesa_texstore_argb4444,            /* StoreTexImageFunc */
-   fetch_texel_1d_argb4444_rev,                /* FetchTexel1D */
-   fetch_texel_2d_argb4444_rev,                /* FetchTexel2D */
-   fetch_texel_3d_argb4444_rev,                /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_argb4444_rev,      /* FetchTexel1Df */
+   fetch_texel_2d_f_argb4444_rev,      /* FetchTexel2Df */
+   fetch_texel_3d_f_argb4444_rev,      /* FetchTexel3Df */
    store_texel_argb4444_rev            /* StoreTexel */
 };
 
+const struct gl_texture_format _mesa_texformat_rgba5551 = {
+   MESA_FORMAT_RGBA5551,               /* MesaFormat */
+   GL_RGBA,                            /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   5,                                  /* RedBits */
+   5,                                  /* GreenBits */
+   5,                                  /* BlueBits */
+   1,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
+   2,                                  /* TexelBytes */
+   _mesa_texstore_rgba5551,            /* StoreTexImageFunc */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_rgba5551,          /* FetchTexel1Df */
+   fetch_texel_2d_f_rgba5551,          /* FetchTexel2Df */
+   fetch_texel_3d_f_rgba5551,          /* FetchTexel3Df */
+   store_texel_rgba5551                        /* StoreTexel */
+};
+
 const struct gl_texture_format _mesa_texformat_argb1555 = {
    MESA_FORMAT_ARGB1555,               /* MesaFormat */
    GL_RGBA,                            /* BaseFormat */
@@ -811,14 +1078,15 @@ const struct gl_texture_format _mesa_texformat_argb1555 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    2,                                  /* TexelBytes */
    _mesa_texstore_argb1555,            /* StoreTexImageFunc */
-   fetch_texel_1d_argb1555,            /* FetchTexel1D */
-   fetch_texel_2d_argb1555,            /* FetchTexel2D */
-   fetch_texel_3d_argb1555,            /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_argb1555,          /* FetchTexel1Df */
+   fetch_texel_2d_f_argb1555,          /* FetchTexel2Df */
+   fetch_texel_3d_f_argb1555,          /* FetchTexel3Df */
    store_texel_argb1555                        /* StoreTexel */
 };
 
@@ -834,14 +1102,15 @@ const struct gl_texture_format _mesa_texformat_argb1555_rev = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    2,                                  /* TexelBytes */
    _mesa_texstore_argb1555,            /* StoreTexImageFunc */
-   fetch_texel_1d_argb1555_rev,                /* FetchTexel1D */
-   fetch_texel_2d_argb1555_rev,                /* FetchTexel2D */
-   fetch_texel_3d_argb1555_rev,                /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_argb1555_rev,      /* FetchTexel1Df */
+   fetch_texel_2d_f_argb1555_rev,      /* FetchTexel2Df */
+   fetch_texel_3d_f_argb1555_rev,      /* FetchTexel3Df */
    store_texel_argb1555_rev            /* StoreTexel */
 };
 
@@ -857,14 +1126,15 @@ const struct gl_texture_format _mesa_texformat_al88 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    2,                                  /* TexelBytes */
    _mesa_texstore_al88,                        /* StoreTexImageFunc */
-   fetch_texel_1d_al88,                        /* FetchTexel1D */
-   fetch_texel_2d_al88,                        /* FetchTexel2D */
-   fetch_texel_3d_al88,                        /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_al88,              /* FetchTexel1Df */
+   fetch_texel_2d_f_al88,              /* FetchTexel2Df */
+   fetch_texel_3d_f_al88,              /* FetchTexel3Df */
    store_texel_al88                    /* StoreTexel */
 };
 
@@ -880,14 +1150,15 @@ const struct gl_texture_format _mesa_texformat_al88_rev = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    2,                                  /* TexelBytes */
    _mesa_texstore_al88,                        /* StoreTexImageFunc */
-   fetch_texel_1d_al88_rev,            /* FetchTexel1D */
-   fetch_texel_2d_al88_rev,            /* FetchTexel2D */
-   fetch_texel_3d_al88_rev,            /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_al88_rev,          /* FetchTexel1Df */
+   fetch_texel_2d_f_al88_rev,          /* FetchTexel2Df */
+   fetch_texel_3d_f_al88_rev,          /* FetchTexel3Df */
    store_texel_al88_rev                        /* StoreTexel */
 };
 
@@ -903,14 +1174,15 @@ const struct gl_texture_format _mesa_texformat_rgb332 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    1,                                  /* TexelBytes */
    _mesa_texstore_rgb332,              /* StoreTexImageFunc */
-   fetch_texel_1d_rgb332,              /* FetchTexel1D */
-   fetch_texel_2d_rgb332,              /* FetchTexel2D */
-   fetch_texel_3d_rgb332,              /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_rgb332,            /* FetchTexel1Df */
+   fetch_texel_2d_f_rgb332,            /* FetchTexel2Df */
+   fetch_texel_3d_f_rgb332,            /* FetchTexel3Df */
    store_texel_rgb332                  /* StoreTexel */
 };
 
@@ -926,14 +1198,15 @@ const struct gl_texture_format _mesa_texformat_a8 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    1,                                  /* TexelBytes */
    _mesa_texstore_a8,                  /* StoreTexImageFunc */
-   fetch_texel_1d_a8,                  /* FetchTexel1D */
-   fetch_texel_2d_a8,                  /* FetchTexel2D */
-   fetch_texel_3d_a8,                  /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_a8,                        /* FetchTexel1Df */
+   fetch_texel_2d_f_a8,                        /* FetchTexel2Df */
+   fetch_texel_3d_f_a8,                        /* FetchTexel3Df */
    store_texel_a8                      /* StoreTexel */
 };
 
@@ -949,14 +1222,15 @@ const struct gl_texture_format _mesa_texformat_l8 = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    1,                                  /* TexelBytes */
    _mesa_texstore_a8,/*yes*/           /* StoreTexImageFunc */
-   fetch_texel_1d_l8,                  /* FetchTexel1D */
-   fetch_texel_2d_l8,                  /* FetchTexel2D */
-   fetch_texel_3d_l8,                  /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_l8,                        /* FetchTexel1Df */
+   fetch_texel_2d_f_l8,                        /* FetchTexel2Df */
+   fetch_texel_3d_f_l8,                        /* FetchTexel3Df */
    store_texel_l8                      /* StoreTexel */
 };
 
@@ -972,14 +1246,15 @@ const struct gl_texture_format _mesa_texformat_i8 = {
    8,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    1,                                  /* TexelBytes */
    _mesa_texstore_a8,/*yes*/           /* StoreTexImageFunc */
-   fetch_texel_1d_i8,                  /* FetchTexel1D */
-   fetch_texel_2d_i8,                  /* FetchTexel2D */
-   fetch_texel_3d_i8,                  /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_i8,                        /* FetchTexel1Df */
+   fetch_texel_2d_f_i8,                        /* FetchTexel2Df */
+   fetch_texel_3d_f_i8,                        /* FetchTexel3Df */
    store_texel_i8                      /* StoreTexel */
 };
 
@@ -995,14 +1270,15 @@ const struct gl_texture_format _mesa_texformat_ci8 = {
    0,                                  /* IntensityBits */
    8,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    1,                                  /* TexelBytes */
    _mesa_texstore_ci8,                 /* StoreTexImageFunc */
-   fetch_texel_1d_ci8,                 /* FetchTexel1D */
-   fetch_texel_2d_ci8,                 /* FetchTexel2D */
-   fetch_texel_3d_ci8,                 /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_ci8,               /* FetchTexel1Df */
+   fetch_texel_2d_f_ci8,               /* FetchTexel2Df */
+   fetch_texel_3d_f_ci8,               /* FetchTexel3Df */
    store_texel_ci8                     /* StoreTexel */
 };
 
@@ -1018,14 +1294,15 @@ const struct gl_texture_format _mesa_texformat_ycbcr = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    2,                                  /* TexelBytes */
    _mesa_texstore_ycbcr,               /* StoreTexImageFunc */
-   fetch_texel_1d_ycbcr,               /* FetchTexel1D */
-   fetch_texel_2d_ycbcr,               /* FetchTexel2D */
-   fetch_texel_3d_ycbcr,               /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_ycbcr,             /* FetchTexel1Df */
+   fetch_texel_2d_f_ycbcr,             /* FetchTexel2Df */
+   fetch_texel_3d_f_ycbcr,             /* FetchTexel3Df */
    store_texel_ycbcr                   /* StoreTexel */
 };
 
@@ -1041,17 +1318,114 @@ const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    2,                                  /* TexelBytes */
    _mesa_texstore_ycbcr,               /* StoreTexImageFunc */
-   fetch_texel_1d_ycbcr_rev,           /* FetchTexel1D */
-   fetch_texel_2d_ycbcr_rev,           /* FetchTexel2D */
-   fetch_texel_3d_ycbcr_rev,           /* FetchTexel3D */
-   NULL,                               /* FetchTexel1Df */
-   NULL,                               /* FetchTexel2Df */
-   NULL,                               /* FetchTexel3Df */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   fetch_texel_1d_f_ycbcr_rev,         /* FetchTexel1Df */
+   fetch_texel_2d_f_ycbcr_rev,         /* FetchTexel2Df */
+   fetch_texel_3d_f_ycbcr_rev,         /* FetchTexel3Df */
    store_texel_ycbcr_rev               /* StoreTexel */
 };
 
+const struct gl_texture_format _mesa_texformat_z24_s8 = {
+   MESA_FORMAT_Z24_S8,                 /* MesaFormat */
+   GL_DEPTH_STENCIL_EXT,               /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   0,                                  /* RedBits */
+   0,                                  /* GreenBits */
+   0,                                  /* BlueBits */
+   0,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   24,                                 /* DepthBits */
+   8,                                  /* StencilBits */
+   4,                                  /* TexelBytes */
+   _mesa_texstore_z24_s8,              /* StoreTexImageFunc */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   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 */
+};
+
+const struct gl_texture_format _mesa_texformat_s8_z24 = {
+   MESA_FORMAT_S8_Z24,                 /* MesaFormat */
+   GL_DEPTH_STENCIL_EXT,               /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   0,                                  /* RedBits */
+   0,                                  /* GreenBits */
+   0,                                  /* BlueBits */
+   0,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   24,                                 /* DepthBits */
+   8,                                  /* StencilBits */
+   4,                                  /* TexelBytes */
+   _mesa_texstore_s8_z24,              /* StoreTexImageFunc */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel2D */
+   NULL,                               /* FetchTexel3D */
+   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 */
+};
+
+const struct gl_texture_format _mesa_texformat_z16 = {
+   MESA_FORMAT_Z16,                    /* MesaFormat */
+   GL_DEPTH_COMPONENT,                 /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   0,                                  /* RedBits */
+   0,                                  /* GreenBits */
+   0,                                  /* BlueBits */
+   0,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   sizeof(GLushort) * 8,               /* DepthBits */
+   0,                                  /* StencilBits */
+   sizeof(GLushort),                   /* TexelBytes */
+   _mesa_texstore_z16,                 /* StoreTexImageFunc */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel1D */
+   fetch_texel_1d_f_z16,               /* FetchTexel1Df */
+   fetch_texel_2d_f_z16,               /* FetchTexel2Df */
+   fetch_texel_3d_f_z16,               /* FetchTexel3Df */
+   store_texel_z16                     /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_z32 = {
+   MESA_FORMAT_Z32,                    /* MesaFormat */
+   GL_DEPTH_COMPONENT,                 /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   0,                                  /* RedBits */
+   0,                                  /* GreenBits */
+   0,                                  /* BlueBits */
+   0,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   sizeof(GLuint) * 8,                 /* DepthBits */
+   0,                                  /* StencilBits */
+   sizeof(GLuint),                     /* TexelBytes */
+   _mesa_texstore_z32,                 /* StoreTexImageFunc */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel1D */
+   NULL,                               /* FetchTexel1D */
+   fetch_texel_1d_f_z32,               /* FetchTexel1Df */
+   fetch_texel_2d_f_z32,               /* FetchTexel2Df */
+   fetch_texel_3d_f_z32,               /* FetchTexel3Df */
+   store_texel_z32                     /* StoreTexel */
+};
+
 /*@}*/
 
 
@@ -1071,6 +1445,7 @@ const struct gl_texture_format _mesa_null_texformat = {
    0,                                  /* IntensityBits */
    0,                                  /* IndexBits */
    0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
    0,                                  /* TexelBytes */
    NULL,                               /* StoreTexImageFunc */
    fetch_null_texel,                   /* FetchTexel1D */
@@ -1192,49 +1567,52 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
          ; /* fallthrough */
    }
 
-   if (ctx->Extensions.SGIX_depth_texture ||
-       ctx->Extensions.ARB_depth_texture) {
+   if (ctx->Extensions.ARB_depth_texture) {
       switch (internalFormat) {
          case GL_DEPTH_COMPONENT:
-         case GL_DEPTH_COMPONENT24_SGIX:
-         case GL_DEPTH_COMPONENT32_SGIX:
-            return &_mesa_texformat_depth_component_float32;
-         case GL_DEPTH_COMPONENT16_SGIX:
-            return &_mesa_texformat_depth_component16;
+         case GL_DEPTH_COMPONENT24:
+         case GL_DEPTH_COMPONENT32:
+            return &_mesa_texformat_z32;
+         case GL_DEPTH_COMPONENT16:
+            return &_mesa_texformat_z16;
          default:
             ; /* fallthrough */
       }
    }
 
-   if (ctx->Extensions.ARB_texture_compression) {
-      switch (internalFormat) {
-         case GL_COMPRESSED_ALPHA_ARB:
-            return &_mesa_texformat_alpha;
-         case GL_COMPRESSED_LUMINANCE_ARB:
-            return &_mesa_texformat_luminance;
-         case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
-            return &_mesa_texformat_luminance_alpha;
-         case GL_COMPRESSED_INTENSITY_ARB:
-            return &_mesa_texformat_intensity;
-         case GL_COMPRESSED_RGB_ARB:
-            if (ctx->Extensions.TDFX_texture_compression_FXT1)
-               return &_mesa_texformat_rgb_fxt1;
-            else if (ctx->Extensions.EXT_texture_compression_s3tc ||
-                     ctx->Extensions.S3_s3tc)
-               return &_mesa_texformat_rgb_dxt1;
-            else
-               return &_mesa_texformat_rgb;
-         case GL_COMPRESSED_RGBA_ARB:
-            if (ctx->Extensions.TDFX_texture_compression_FXT1)
-               return &_mesa_texformat_rgba_fxt1;
-            else if (ctx->Extensions.EXT_texture_compression_s3tc ||
-                     ctx->Extensions.S3_s3tc)
-               return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */
-            else
-               return &_mesa_texformat_rgba;
-         default:
-            ; /* fallthrough */
-      }
+   switch (internalFormat) {
+      case GL_COMPRESSED_ALPHA_ARB:
+         return &_mesa_texformat_alpha;
+      case GL_COMPRESSED_LUMINANCE_ARB:
+         return &_mesa_texformat_luminance;
+      case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
+         return &_mesa_texformat_luminance_alpha;
+      case GL_COMPRESSED_INTENSITY_ARB:
+         return &_mesa_texformat_intensity;
+      case GL_COMPRESSED_RGB_ARB:
+#if FEATURE_texture_fxt1
+         if (ctx->Extensions.TDFX_texture_compression_FXT1)
+            return &_mesa_texformat_rgb_fxt1;
+#endif
+#if FEATURE_texture_s3tc
+         if (ctx->Extensions.EXT_texture_compression_s3tc ||
+             ctx->Extensions.S3_s3tc)
+            return &_mesa_texformat_rgb_dxt1;
+#endif
+         return &_mesa_texformat_rgb;
+      case GL_COMPRESSED_RGBA_ARB:
+#if FEATURE_texture_fxt1
+         if (ctx->Extensions.TDFX_texture_compression_FXT1)
+            return &_mesa_texformat_rgba_fxt1;
+#endif
+#if FEATURE_texture_s3tc
+         if (ctx->Extensions.EXT_texture_compression_s3tc ||
+             ctx->Extensions.S3_s3tc)
+            return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */
+#endif
+         return &_mesa_texformat_rgba;
+      default:
+         ; /* fallthrough */
    }
 
    if (ctx->Extensions.MESA_ycbcr_texture) {
@@ -1246,6 +1624,7 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       }
    }
 
+#if FEATURE_texture_fxt1
    if (ctx->Extensions.TDFX_texture_compression_FXT1) {
       switch (internalFormat) {
          case GL_COMPRESSED_RGB_FXT1_3DFX:
@@ -1256,7 +1635,9 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
             ; /* fallthrough */
       }
    }
+#endif
 
+#if FEATURE_texture_s3tc
    if (ctx->Extensions.EXT_texture_compression_s3tc) {
       switch (internalFormat) {
          case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
@@ -1284,6 +1665,7 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
             ; /* fallthrough */
       }
    }
+#endif
 
    if (ctx->Extensions.ARB_texture_float) {
       switch (internalFormat) {
@@ -1316,6 +1698,292 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       }
    }
 
+   if (ctx->Extensions.EXT_packed_depth_stencil) {
+      switch (internalFormat) {
+         case GL_DEPTH_STENCIL_EXT:
+         case GL_DEPTH24_STENCIL8_EXT:
+            return &_mesa_texformat_z24_s8;
+         default:
+            ; /* fallthrough */
+      }
+   }
+
+   if (ctx->Extensions.ATI_envmap_bumpmap) {
+      switch (internalFormat) {
+         case GL_DUDV_ATI:
+         case GL_DU8DV8_ATI:
+            return &_mesa_texformat_dudv8;
+         default:
+            ; /* fallthrough */
+      }
+   }
+
+   if (ctx->Extensions.MESA_texture_signed_rgba) {
+      switch (internalFormat) {
+         case GL_RGBA_SNORM:
+         case GL_RGBA8_SNORM:
+            return &_mesa_texformat_signed_rgba8888;
+         default:
+            ; /* fallthrough */
+      }
+   }
+
+
+#if FEATURE_EXT_texture_sRGB
+   if (ctx->Extensions.EXT_texture_sRGB) {
+      switch (internalFormat) {
+         case GL_SRGB_EXT:
+         case GL_SRGB8_EXT:
+            return &_mesa_texformat_srgb8;
+         case GL_SRGB_ALPHA_EXT:
+         case GL_SRGB8_ALPHA8_EXT:
+            return &_mesa_texformat_srgba8;
+         case GL_SLUMINANCE_EXT:
+         case GL_SLUMINANCE8_EXT:
+            return &_mesa_texformat_sl8;
+         case GL_SLUMINANCE_ALPHA_EXT:
+         case GL_SLUMINANCE8_ALPHA8_EXT:
+            return &_mesa_texformat_sla8;
+         case GL_COMPRESSED_SLUMINANCE_EXT:
+            return &_mesa_texformat_sl8;
+         case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
+            return &_mesa_texformat_sla8;
+         case GL_COMPRESSED_SRGB_EXT:
+#if FEATURE_texture_s3tc
+            if (ctx->Extensions.EXT_texture_compression_s3tc)
+               return &_mesa_texformat_srgb_dxt1;
+#endif
+            return &_mesa_texformat_srgb8;
+         case GL_COMPRESSED_SRGB_ALPHA_EXT:
+#if FEATURE_texture_s3tc
+            if (ctx->Extensions.EXT_texture_compression_s3tc)
+               return &_mesa_texformat_srgba_dxt3; /* Not srgba_dxt1, see spec */
+#endif
+            return &_mesa_texformat_srgba8;
+#if FEATURE_texture_s3tc
+         case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+            if (ctx->Extensions.EXT_texture_compression_s3tc)
+               return &_mesa_texformat_srgb_dxt1;
+            break;
+         case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
+            if (ctx->Extensions.EXT_texture_compression_s3tc)
+               return &_mesa_texformat_srgba_dxt1;
+            break;
+         case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+            if (ctx->Extensions.EXT_texture_compression_s3tc)
+               return &_mesa_texformat_srgba_dxt3;
+            break;
+         case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+            if (ctx->Extensions.EXT_texture_compression_s3tc)
+               return &_mesa_texformat_srgba_dxt5;
+            break;
+#endif
+         default:
+            ; /* fallthrough */
+      }
+   }
+#endif /* FEATURE_EXT_texture_sRGB */
+
    _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
    return NULL;
 }
+
+
+
+/**
+ * Return datatype and number of components per texel for the
+ * given gl_texture_format.
+ */
+void
+_mesa_format_to_type_and_comps(const struct gl_texture_format *format,
+                               GLenum *datatype, GLuint *comps)
+{
+   switch (format->MesaFormat) {
+   case MESA_FORMAT_RGBA8888:
+   case MESA_FORMAT_RGBA8888_REV:
+   case MESA_FORMAT_ARGB8888:
+   case MESA_FORMAT_ARGB8888_REV:
+      *datatype = CHAN_TYPE;
+      *comps = 4;
+      return;
+   case MESA_FORMAT_RGB888:
+   case MESA_FORMAT_BGR888:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 3;
+      return;
+   case MESA_FORMAT_RGB565:
+   case MESA_FORMAT_RGB565_REV:
+      *datatype = GL_UNSIGNED_SHORT_5_6_5;
+      *comps = 3;
+      return;
+
+   case MESA_FORMAT_ARGB4444:
+   case MESA_FORMAT_ARGB4444_REV:
+      *datatype = GL_UNSIGNED_SHORT_4_4_4_4;
+      *comps = 4;
+      return;
+
+   case MESA_FORMAT_ARGB1555:
+   case MESA_FORMAT_ARGB1555_REV:
+      *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+      *comps = 4;
+      return;
+
+   case MESA_FORMAT_AL88:
+   case MESA_FORMAT_AL88_REV:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 2;
+      return;
+   case MESA_FORMAT_RGB332:
+      *datatype = GL_UNSIGNED_BYTE_3_3_2;
+      *comps = 3;
+      return;
+
+   case MESA_FORMAT_A8:
+   case MESA_FORMAT_L8:
+   case MESA_FORMAT_I8:
+   case MESA_FORMAT_CI8:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 1;
+      return;
+
+   case MESA_FORMAT_YCBCR:
+   case MESA_FORMAT_YCBCR_REV:
+      *datatype = GL_UNSIGNED_SHORT;
+      *comps = 2;
+      return;
+
+   case MESA_FORMAT_Z24_S8:
+      *datatype = GL_UNSIGNED_INT;
+      *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;
+      return;
+
+   case MESA_FORMAT_Z32:
+      *datatype = GL_UNSIGNED_INT;
+      *comps = 1;
+      return;
+
+   case MESA_FORMAT_DUDV8:
+      *datatype = GL_BYTE;
+      *comps = 2;
+      return;
+
+   case MESA_FORMAT_SIGNED_RGBA8888:
+   case MESA_FORMAT_SIGNED_RGBA8888_REV:
+      *datatype = GL_BYTE;
+      *comps = 4;
+      return;
+
+#if FEATURE_EXT_texture_sRGB
+   case MESA_FORMAT_SRGB8:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 3;
+      return;
+   case MESA_FORMAT_SRGBA8:
+   case MESA_FORMAT_SARGB8:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 4;
+      return;
+   case MESA_FORMAT_SL8:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 1;
+      return;
+   case MESA_FORMAT_SLA8:
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 2;
+      return;
+#endif
+
+#if FEATURE_texture_fxt1
+   case MESA_FORMAT_RGB_FXT1:
+   case MESA_FORMAT_RGBA_FXT1:
+#endif
+#if FEATURE_texture_s3tc
+   case MESA_FORMAT_RGB_DXT1:
+   case MESA_FORMAT_RGBA_DXT1:
+   case MESA_FORMAT_RGBA_DXT3:
+   case MESA_FORMAT_RGBA_DXT5:
+#if FEATURE_EXT_texture_sRGB
+   case MESA_FORMAT_SRGB_DXT1:
+   case MESA_FORMAT_SRGBA_DXT1:
+   case MESA_FORMAT_SRGBA_DXT3:
+   case MESA_FORMAT_SRGBA_DXT5:
+#endif
+      /* XXX generate error instead? */
+      *datatype = GL_UNSIGNED_BYTE;
+      *comps = 0;
+      return;
+#endif
+
+   case MESA_FORMAT_RGBA:
+      *datatype = CHAN_TYPE;
+      *comps = 4;
+      return;
+   case MESA_FORMAT_RGB:
+      *datatype = CHAN_TYPE;
+      *comps = 3;
+      return;
+   case MESA_FORMAT_LUMINANCE_ALPHA:
+      *datatype = CHAN_TYPE;
+      *comps = 2;
+      return;
+   case MESA_FORMAT_ALPHA:
+   case MESA_FORMAT_LUMINANCE:
+   case MESA_FORMAT_INTENSITY:
+      *datatype = CHAN_TYPE;
+      *comps = 1;
+      return;
+
+   case MESA_FORMAT_RGBA_FLOAT32:
+      *datatype = GL_FLOAT;
+      *comps = 4;
+      return;
+   case MESA_FORMAT_RGBA_FLOAT16:
+      *datatype = GL_HALF_FLOAT_ARB;
+      *comps = 4;
+      return;
+   case MESA_FORMAT_RGB_FLOAT32:
+      *datatype = GL_FLOAT;
+      *comps = 3;
+      return;
+   case MESA_FORMAT_RGB_FLOAT16:
+      *datatype = GL_HALF_FLOAT_ARB;
+      *comps = 3;
+      return;
+   case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
+      *datatype = GL_FLOAT;
+      *comps = 2;
+      return;
+   case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
+      *datatype = GL_HALF_FLOAT_ARB;
+      *comps = 2;
+      return;
+   case MESA_FORMAT_ALPHA_FLOAT32:
+   case MESA_FORMAT_LUMINANCE_FLOAT32:
+   case MESA_FORMAT_INTENSITY_FLOAT32:
+      *datatype = GL_FLOAT;
+      *comps = 1;
+      return;
+   case MESA_FORMAT_ALPHA_FLOAT16:
+   case MESA_FORMAT_LUMINANCE_FLOAT16:
+   case MESA_FORMAT_INTENSITY_FLOAT16:
+      *datatype = GL_HALF_FLOAT_ARB;
+      *comps = 1;
+      return;
+
+   default:
+      _mesa_problem(NULL, "bad format in _mesa_format_to_type_and_comps");
+      *datatype = 0;
+      *comps = 1;
+   }
+}