main: Added entry point for glGetCompressedTextureImage.
[mesa.git] / src / mesa / main / format_unpack.c
index 242df7bf326ac28acc522709dc21302e60eb637a..d5628a9e7cba235b173b21a134e988bc2f474929 100644 (file)
@@ -28,6 +28,7 @@
 #include "macros.h"
 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
+#include "util/format_srgb.h"
 
 
 /** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */
@@ -53,34 +54,6 @@ struct z32f_x24s8
 #define EXPAND_6_8(X)  ( ((X) << 2) | ((X) >> 4) )
 
 
-/**
- * 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.
- */
-GLfloat
-_mesa_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) pow((cs + 0.055) / 1.055, 2.4);
-         }
-      }
-      tableReady = GL_TRUE;
-   }
-   return table[cs8];
-}
-
-
 /**********************************************************************/
 /*  Unpack, returning GLfloat colors                                  */
 /**********************************************************************/
@@ -617,7 +590,7 @@ unpack_B10G10R10A2_UNORM(const void *src, GLfloat dst[][4], GLuint n)
 
 
 static void
-unpack_ARGB2101010_UINT(const void *src, GLfloat dst[][4], GLuint n)
+unpack_B10G10R10A2_UINT(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLuint *s = (const GLuint *) src;
    GLuint i;
@@ -631,7 +604,7 @@ unpack_ARGB2101010_UINT(const void *src, GLfloat dst[][4], GLuint n)
 
 
 static void
-unpack_ABGR2101010_UINT(const void *src, GLfloat dst[][4], GLuint n)
+unpack_R10G10B10A2_UINT(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLuint *s = ((const GLuint *) src);
    GLuint i;
@@ -645,7 +618,7 @@ unpack_ABGR2101010_UINT(const void *src, GLfloat dst[][4], GLuint n)
 
 
 static void
-unpack_Z24_S8(const void *src, GLfloat dst[][4], GLuint n)
+unpack_S8_UINT_Z24_UNORM(const void *src, GLfloat dst[][4], GLuint n)
 {
    /* only return Z, not stencil data */
    const GLuint *s = ((const GLuint *) src);
@@ -662,7 +635,7 @@ unpack_Z24_S8(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_S8_Z24(const void *src, GLfloat dst[][4], GLuint n)
+unpack_Z24_UNORM_S8_UINT(const void *src, GLfloat dst[][4], GLuint n)
 {
    /* only return Z, not stencil data */
    const GLuint *s = ((const GLuint *) src);
@@ -679,7 +652,7 @@ unpack_S8_Z24(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_Z16(const void *src, GLfloat dst[][4], GLuint n)
+unpack_Z_UNORM16(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLushort *s = ((const GLushort *) src);
    GLuint i;
@@ -692,19 +665,19 @@ unpack_Z16(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_X8_Z24(const void *src, GLfloat dst[][4], GLuint n)
+unpack_Z24_UNORM_X8_UINT(const void *src, GLfloat dst[][4], GLuint n)
 {
-   unpack_S8_Z24(src, dst, n);
+   unpack_Z24_UNORM_S8_UINT(src, dst, n);
 }
 
 static void
-unpack_Z24_X8(const void *src, GLfloat dst[][4], GLuint n)
+unpack_X8_UINT_Z24_UNORM(const void *src, GLfloat dst[][4], GLuint n)
 {
-   unpack_Z24_S8(src, dst, n);
+   unpack_S8_UINT_Z24_UNORM(src, dst, n);
 }
 
 static void
-unpack_Z32(const void *src, GLfloat dst[][4], GLuint n)
+unpack_Z_UNORM32(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLuint *s = ((const GLuint *) src);
    GLuint i;
@@ -717,20 +690,20 @@ unpack_Z32(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_Z32_FLOAT(const void *src, GLfloat dst[][4], GLuint n)
+unpack_Z32_FLOAT_S8X24_UINT(const void *src, GLfloat dst[][4], GLuint n)
 {
-   const GLfloat *s = ((const GLfloat *) src);
+   const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
    GLuint i;
    for (i = 0; i < n; i++) {
       dst[i][0] =
       dst[i][1] =
-      dst[i][2] = s[i * 2];
+      dst[i][2] = s[i].z;
       dst[i][3] = 1.0F;
    }
 }
 
 static void
-unpack_Z32_FLOAT_X24S8(const void *src, GLfloat dst[][4], GLuint n)
+unpack_Z_FLOAT32(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLfloat *s = ((const GLfloat *) src);
    GLuint i;
@@ -763,9 +736,9 @@ unpack_BGR_SRGB8(const void *src, GLfloat dst[][4], GLuint n)
    const GLubyte *s = (const GLubyte *) src;
    GLuint i;
    for (i = 0; i < n; i++) {
-      dst[i][RCOMP] = _mesa_nonlinear_to_linear(s[i*3+2]);
-      dst[i][GCOMP] = _mesa_nonlinear_to_linear(s[i*3+1]);
-      dst[i][BCOMP] = _mesa_nonlinear_to_linear(s[i*3+0]);
+      dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float(s[i*3+2]);
+      dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float(s[i*3+1]);
+      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float(s[i*3+0]);
       dst[i][ACOMP] = 1.0F;
    }
 }
@@ -776,9 +749,9 @@ unpack_A8B8G8R8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
    const GLuint *s = ((const GLuint *) src);
    GLuint i;
    for (i = 0; i < n; i++) {
-      dst[i][RCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 24) );
-      dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
-      dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] >>  8) & 0xff );
+      dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 24) );
+      dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff );
+      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>  8) & 0xff );
       dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] & 0xff ); /* linear! */
    }
 }
@@ -789,22 +762,35 @@ unpack_B8G8R8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
    const GLuint *s = ((const GLuint *) src);
    GLuint i;
    for (i = 0; i < n; i++) {
-      dst[i][RCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
-      dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >>  8) & 0xff );
-      dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i]      ) & 0xff );
+      dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff );
+      dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>  8) & 0xff );
+      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i]      ) & 0xff );
       dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] >> 24 ); /* linear! */
    }
 }
 
+static void
+unpack_A8R8G8B8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
+{
+   const GLuint *s = ((const GLuint *) src);
+   GLuint i;
+   for (i = 0; i < n; i++) {
+      dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>  8) & 0xff );
+      dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff );
+      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 24) );
+      dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] & 0xff ); /* linear! */
+   }
+}
+
 static void
 unpack_R8G8B8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLuint *s = ((const GLuint *) src);
    GLuint i;
    for (i = 0; i < n; i++) {
-      dst[i][RCOMP] = _mesa_nonlinear_to_linear( (s[i]      ) & 0xff );
-      dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >>  8) & 0xff );
-      dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
+      dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i]      ) & 0xff );
+      dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>  8) & 0xff );
+      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff );
       dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] >> 24 ); /* linear! */
    }
 }
@@ -817,7 +803,7 @@ unpack_L_SRGB8(const void *src, GLfloat dst[][4], GLuint n)
    for (i = 0; i < n; i++) {
       dst[i][RCOMP] = 
       dst[i][GCOMP] = 
-      dst[i][BCOMP] = _mesa_nonlinear_to_linear(s[i]);
+      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float(s[i]);
       dst[i][ACOMP] = 1.0F;
    }
 }
@@ -830,11 +816,24 @@ unpack_L8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
    for (i = 0; i < n; i++) {
       dst[i][RCOMP] =
       dst[i][GCOMP] =
-      dst[i][BCOMP] = _mesa_nonlinear_to_linear(s[i] & 0xff);
+      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float(s[i] & 0xff);
       dst[i][ACOMP] = UBYTE_TO_FLOAT(s[i] >> 8); /* linear! */
    }
 }
 
+static void
+unpack_A8L8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
+{
+   const GLushort *s = (const GLushort *) src;
+   GLuint i;
+   for (i = 0; i < n; i++) {
+      dst[i][RCOMP] =
+      dst[i][GCOMP] =
+      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float(s[i] >> 8);
+      dst[i][ACOMP] = UBYTE_TO_FLOAT(s[i] & 0xff); /* linear! */
+   }
+}
+
 static void
 unpack_SRGB_DXT1(const void *src, GLfloat dst[][4], GLuint n)
 {
@@ -1708,20 +1707,7 @@ unpack_RGBA_UINT32(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_DUDV8(const void *src, GLfloat dst[][4], GLuint n)
-{
-   const GLbyte *s = (const GLbyte *) src;
-   GLuint i;
-   for (i = 0; i < n; i++) {
-      dst[i][RCOMP] = BYTE_TO_FLOAT(s[i*2+0]);
-      dst[i][GCOMP] = BYTE_TO_FLOAT(s[i*2+1]);
-      dst[i][BCOMP] = 0;
-      dst[i][ACOMP] = 0;
-   }
-}
-
-static void
-unpack_SIGNED_R_UNORM8(const void *src, GLfloat dst[][4], GLuint n)
+unpack_R_SNORM8(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLbyte *s = ((const GLbyte *) src);
    GLuint i;
@@ -1734,7 +1720,7 @@ unpack_SIGNED_R_UNORM8(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_RG88_REV(const void *src, GLfloat dst[][4], GLuint n)
+unpack_R8G8_SNORM(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLushort *s = ((const GLushort *) src);
    GLuint i;
@@ -1747,7 +1733,7 @@ unpack_SIGNED_RG88_REV(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_RGBX8888(const void *src, GLfloat dst[][4], GLuint n)
+unpack_X8B8G8R8_SNORM(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLuint *s = ((const GLuint *) src);
    GLuint i;
@@ -1760,7 +1746,7 @@ unpack_SIGNED_RGBX8888(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_A8B8G8R8_UNORM(const void *src, GLfloat dst[][4], GLuint n)
+unpack_A8B8G8R8_SNORM(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLuint *s = ((const GLuint *) src);
    GLuint i;
@@ -1773,7 +1759,7 @@ unpack_SIGNED_A8B8G8R8_UNORM(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_R8G8B8A8_UNORM(const void *src, GLfloat dst[][4], GLuint n)
+unpack_R8G8B8A8_SNORM(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLuint *s = ((const GLuint *) src);
    GLuint i;
@@ -1786,7 +1772,7 @@ unpack_SIGNED_R8G8B8A8_UNORM(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_R_UNORM16(const void *src, GLfloat dst[][4], GLuint n)
+unpack_R_SNORM16(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLshort *s = ((const GLshort *) src);
    GLuint i;
@@ -1799,7 +1785,7 @@ unpack_SIGNED_R_UNORM16(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_R16G16_UNORM(const void *src, GLfloat dst[][4], GLuint n)
+unpack_R16G16_SNORM(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLuint *s = ((const GLuint *) src);
    GLuint i;
@@ -1812,7 +1798,7 @@ unpack_SIGNED_R16G16_UNORM(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_RGB_16(const void *src, GLfloat dst[][4], GLuint n)
+unpack_RGB_SNORM16(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLshort *s = (const GLshort *) src;
    GLuint i;
@@ -1825,7 +1811,7 @@ unpack_SIGNED_RGB_16(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_RGBA_16(const void *src, GLfloat dst[][4], GLuint n)
+unpack_RGBA_SNORM16(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLshort *s = (const GLshort *) src;
    GLuint i;
@@ -1967,7 +1953,7 @@ unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1(const void *src, GLfloat dst[][4],
 }
 
 static void
-unpack_SIGNED_A_UNORM8(const void *src, GLfloat dst[][4], GLuint n)
+unpack_A_SNORM8(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLbyte *s = ((const GLbyte *) src);
    GLuint i;
@@ -1980,7 +1966,7 @@ unpack_SIGNED_A_UNORM8(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_L_UNORM8(const void *src, GLfloat dst[][4], GLuint n)
+unpack_L_SNORM8(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLbyte *s = ((const GLbyte *) src);
    GLuint i;
@@ -1993,7 +1979,7 @@ unpack_SIGNED_L_UNORM8(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_L8A8_UNORM(const void *src, GLfloat dst[][4], GLuint n)
+unpack_L8A8_SNORM(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLshort *s = ((const GLshort *) src);
    GLuint i;
@@ -2005,8 +1991,22 @@ unpack_SIGNED_L8A8_UNORM(const void *src, GLfloat dst[][4], GLuint n)
    }
 }
 
+
+static void
+unpack_A8L8_SNORM(const void *src, GLfloat dst[][4], GLuint n)
+{
+   const GLshort *s = ((const GLshort *) src);
+   GLuint i;
+   for (i = 0; i < n; i++) {
+      dst[i][RCOMP] =
+      dst[i][GCOMP] =
+      dst[i][BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] >> 8) );
+      dst[i][ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] & 0xff) );
+   }
+}
+
 static void
-unpack_SIGNED_I_UNORM8(const void *src, GLfloat dst[][4], GLuint n)
+unpack_I_SNORM8(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLbyte *s = ((const GLbyte *) src);
    GLuint i;
@@ -2019,7 +2019,7 @@ unpack_SIGNED_I_UNORM8(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_A_UNORM16(const void *src, GLfloat dst[][4], GLuint n)
+unpack_A_SNORM16(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLshort *s = ((const GLshort *) src);
    GLuint i;
@@ -2032,7 +2032,7 @@ unpack_SIGNED_A_UNORM16(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_L_UNORM16(const void *src, GLfloat dst[][4], GLuint n)
+unpack_L_SNORM16(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLshort *s = ((const GLshort *) src);
    GLuint i;
@@ -2045,7 +2045,7 @@ unpack_SIGNED_L_UNORM16(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_L16A16_UNORM(const void *src, GLfloat dst[][4], GLuint n)
+unpack_LA_SNORM16(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLshort *s = (const GLshort *) src;
    GLuint i;
@@ -2058,7 +2058,7 @@ unpack_SIGNED_L16A16_UNORM(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_I_UNORM16(const void *src, GLfloat dst[][4], GLuint n)
+unpack_I_SNORM16(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLshort *s = ((const GLshort *) src);
    GLuint i;
@@ -2119,7 +2119,7 @@ unpack_XRGB1555_UNORM(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_XBGR8888_SNORM(const void *src, GLfloat dst[][4], GLuint n)
+unpack_R8G8B8X8_SNORM(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLuint *s = ((const GLuint *) src);
    GLuint i;
@@ -2137,10 +2137,23 @@ unpack_R8G8B8X8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
    const GLuint *s = ((const GLuint *) src);
    GLuint i;
    for (i = 0; i < n; i++) {
-      dst[i][RCOMP] = _mesa_nonlinear_to_linear( (s[i]      ) & 0xff );
-      dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >>  8) & 0xff );
-      dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
-      dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] >> 24 ); /* linear! */
+      dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i]      ) & 0xff );
+      dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>  8) & 0xff );
+      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff );
+      dst[i][ACOMP] = 1.0f;
+   }
+}
+
+static void
+unpack_X8B8G8R8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
+{
+   const GLuint *s = ((const GLuint *) src);
+   GLuint i;
+   for (i = 0; i < n; i++) {
+      dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 24) );
+      dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff );
+      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>  8) & 0xff );
+      dst[i][ACOMP] = 1.0f;
    }
 }
 
@@ -2197,7 +2210,7 @@ unpack_RGBX_UNORM16(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_XBGR16161616_SNORM(const void *src, GLfloat dst[][4], GLuint n)
+unpack_RGBX_SNORM16(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLshort *s = (const GLshort *) src;
    GLuint i;
@@ -2301,7 +2314,7 @@ unpack_R10G10B10A2_UNORM(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_G8R8_UNORM(const void *src, GLfloat dst[][4], GLuint n)
+unpack_G8R8_SNORM(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLushort *s = ((const GLushort *) src);
    GLuint i;
@@ -2314,7 +2327,7 @@ unpack_SIGNED_G8R8_UNORM(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
-unpack_SIGNED_G16R16_UNORM(const void *src, GLfloat dst[][4], GLuint n)
+unpack_G16R16_SNORM(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLuint *s = ((const GLuint *) src);
    GLuint i;
@@ -2332,9 +2345,22 @@ unpack_B8G8R8X8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
    const GLuint *s = ((const GLuint *) src);
    GLuint i;
    for (i = 0; i < n; i++) {
-      dst[i][RCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
-      dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >>  8) & 0xff );
-      dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i]      ) & 0xff );
+      dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff );
+      dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>  8) & 0xff );
+      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i]      ) & 0xff );
+      dst[i][ACOMP] = 1.0F;
+   }
+}
+
+static void
+unpack_X8R8G8B8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
+{
+   const GLuint *s = ((const GLuint *) src);
+   GLuint i;
+   for (i = 0; i < n; i++) {
+      dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>  8) & 0xff );
+      dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff );
+      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 24) );
       dst[i][ACOMP] = 1.0F;
    }
 }
@@ -2389,21 +2415,23 @@ get_unpack_rgba_function(mesa_format format)
       table[MESA_FORMAT_R16G16_UNORM] = unpack_R16G16_UNORM;
       table[MESA_FORMAT_G16R16_UNORM] = unpack_G16R16_UNORM;
       table[MESA_FORMAT_B10G10R10A2_UNORM] = unpack_B10G10R10A2_UNORM;
-      table[MESA_FORMAT_B10G10R10A2_UINT] = unpack_ARGB2101010_UINT;
-      table[MESA_FORMAT_R10G10B10A2_UINT] = unpack_ABGR2101010_UINT;
-      table[MESA_FORMAT_S8_UINT_Z24_UNORM] = unpack_Z24_S8;
-      table[MESA_FORMAT_Z24_UNORM_S8_UINT] = unpack_S8_Z24;
-      table[MESA_FORMAT_Z_UNORM16] = unpack_Z16;
-      table[MESA_FORMAT_Z24_UNORM_X8_UINT] = unpack_X8_Z24;
-      table[MESA_FORMAT_X8_UINT_Z24_UNORM] = unpack_Z24_X8;
-      table[MESA_FORMAT_Z_UNORM32] = unpack_Z32;
+      table[MESA_FORMAT_B10G10R10A2_UINT] = unpack_B10G10R10A2_UINT;
+      table[MESA_FORMAT_R10G10B10A2_UINT] = unpack_R10G10B10A2_UINT;
+      table[MESA_FORMAT_S8_UINT_Z24_UNORM] = unpack_S8_UINT_Z24_UNORM;
+      table[MESA_FORMAT_Z24_UNORM_S8_UINT] = unpack_Z24_UNORM_S8_UINT;
+      table[MESA_FORMAT_Z_UNORM16] = unpack_Z_UNORM16;
+      table[MESA_FORMAT_Z24_UNORM_X8_UINT] = unpack_Z24_UNORM_X8_UINT;
+      table[MESA_FORMAT_X8_UINT_Z24_UNORM] = unpack_X8_UINT_Z24_UNORM;
+      table[MESA_FORMAT_Z_UNORM32] = unpack_Z_UNORM32;
       table[MESA_FORMAT_S_UINT8] = unpack_S8;
       table[MESA_FORMAT_BGR_SRGB8] = unpack_BGR_SRGB8;
       table[MESA_FORMAT_A8B8G8R8_SRGB] = unpack_A8B8G8R8_SRGB;
       table[MESA_FORMAT_B8G8R8A8_SRGB] = unpack_B8G8R8A8_SRGB;
+      table[MESA_FORMAT_A8R8G8B8_SRGB] = unpack_A8R8G8B8_SRGB;
       table[MESA_FORMAT_R8G8B8A8_SRGB] = unpack_R8G8B8A8_SRGB;
       table[MESA_FORMAT_L_SRGB8] = unpack_L_SRGB8;
       table[MESA_FORMAT_L8A8_SRGB] = unpack_L8A8_SRGB;
+      table[MESA_FORMAT_A8L8_SRGB] = unpack_A8L8_SRGB;
       table[MESA_FORMAT_SRGB_DXT1] = unpack_SRGB_DXT1;
       table[MESA_FORMAT_SRGBA_DXT1] = unpack_SRGBA_DXT1;
       table[MESA_FORMAT_SRGBA_DXT3] = unpack_SRGBA_DXT3;
@@ -2486,16 +2514,15 @@ get_unpack_rgba_function(mesa_format format)
       table[MESA_FORMAT_RGB_UINT32] = unpack_RGB_UINT32;
       table[MESA_FORMAT_RGBA_UINT32] = unpack_RGBA_UINT32;
 
-      table[MESA_FORMAT_DUDV8] = unpack_DUDV8;
-      table[MESA_FORMAT_R_SNORM8] = unpack_SIGNED_R_UNORM8;
-      table[MESA_FORMAT_R8G8_SNORM] = unpack_SIGNED_RG88_REV;
-      table[MESA_FORMAT_X8B8G8R8_SNORM] = unpack_SIGNED_RGBX8888;
-      table[MESA_FORMAT_A8B8G8R8_SNORM] = unpack_SIGNED_A8B8G8R8_UNORM;
-      table[MESA_FORMAT_R8G8B8A8_SNORM] = unpack_SIGNED_R8G8B8A8_UNORM;
-      table[MESA_FORMAT_R_SNORM16] = unpack_SIGNED_R_UNORM16;
-      table[MESA_FORMAT_R16G16_SNORM] = unpack_SIGNED_R16G16_UNORM;
-      table[MESA_FORMAT_RGB_SNORM16] = unpack_SIGNED_RGB_16;
-      table[MESA_FORMAT_RGBA_SNORM16] = unpack_SIGNED_RGBA_16;
+      table[MESA_FORMAT_R_SNORM8] = unpack_R_SNORM8;
+      table[MESA_FORMAT_R8G8_SNORM] = unpack_R8G8_SNORM;
+      table[MESA_FORMAT_X8B8G8R8_SNORM] = unpack_X8B8G8R8_SNORM;
+      table[MESA_FORMAT_A8B8G8R8_SNORM] = unpack_A8B8G8R8_SNORM;
+      table[MESA_FORMAT_R8G8B8A8_SNORM] = unpack_R8G8B8A8_SNORM;
+      table[MESA_FORMAT_R_SNORM16] = unpack_R_SNORM16;
+      table[MESA_FORMAT_R16G16_SNORM] = unpack_R16G16_SNORM;
+      table[MESA_FORMAT_RGB_SNORM16] = unpack_RGB_SNORM16;
+      table[MESA_FORMAT_RGBA_SNORM16] = unpack_RGBA_SNORM16;
       table[MESA_FORMAT_RGBA_UNORM16] = unpack_RGBA_16;
 
       table[MESA_FORMAT_R_RGTC1_UNORM] = unpack_RED_RGTC1;
@@ -2524,27 +2551,29 @@ get_unpack_rgba_function(mesa_format format)
       table[MESA_FORMAT_A_SNORM8] = unpack_A_SNORM8;
       table[MESA_FORMAT_L_SNORM8] = unpack_L_SNORM8;
       table[MESA_FORMAT_L8A8_SNORM] = unpack_L8A8_SNORM;
-      table[MESA_FORMAT_I_SNORM8] = unpack_SIGNED_I_UNORM8;
+      table[MESA_FORMAT_A8L8_SNORM] = unpack_A8L8_SNORM;
+      table[MESA_FORMAT_I_SNORM8] = unpack_I_SNORM8;
       table[MESA_FORMAT_A_SNORM16] = unpack_A_SNORM16;
       table[MESA_FORMAT_L_SNORM16] = unpack_L_SNORM16;
       table[MESA_FORMAT_LA_SNORM16] = unpack_LA_SNORM16;
-      table[MESA_FORMAT_I_SNORM16] = unpack_SIGNED_I_UNORM16;
+      table[MESA_FORMAT_I_SNORM16] = unpack_I_SNORM16;
 
       table[MESA_FORMAT_R9G9B9E5_FLOAT] = unpack_R9G9B9E5_FLOAT;
       table[MESA_FORMAT_R11G11B10_FLOAT] = unpack_R11G11B10_FLOAT;
 
-      table[MESA_FORMAT_Z_FLOAT32] = unpack_Z32_FLOAT;
-      table[MESA_FORMAT_Z32_FLOAT_S8X24_UINT] = unpack_Z32_FLOAT_X24S8;
+      table[MESA_FORMAT_Z_FLOAT32] = unpack_Z_FLOAT32;
+      table[MESA_FORMAT_Z32_FLOAT_S8X24_UINT] = unpack_Z32_FLOAT_S8X24_UINT;
 
       table[MESA_FORMAT_B4G4R4X4_UNORM] = unpack_XRGB4444_UNORM;
       table[MESA_FORMAT_B5G5R5X1_UNORM] = unpack_XRGB1555_UNORM;
-      table[MESA_FORMAT_R8G8B8X8_SNORM] = unpack_XBGR8888_SNORM;
+      table[MESA_FORMAT_R8G8B8X8_SNORM] = unpack_R8G8B8X8_SNORM;
       table[MESA_FORMAT_R8G8B8X8_SRGB] = unpack_R8G8B8X8_SRGB;
+      table[MESA_FORMAT_X8B8G8R8_SRGB] = unpack_X8B8G8R8_SRGB;
       table[MESA_FORMAT_RGBX_UINT8] = unpack_XBGR8888_UINT;
       table[MESA_FORMAT_RGBX_SINT8] = unpack_XBGR8888_SINT;
       table[MESA_FORMAT_B10G10R10X2_UNORM] = unpack_B10G10R10X2_UNORM;
       table[MESA_FORMAT_RGBX_UNORM16] = unpack_RGBX_UNORM16;
-      table[MESA_FORMAT_RGBX_SNORM16] = unpack_XBGR16161616_SNORM;
+      table[MESA_FORMAT_RGBX_SNORM16] = unpack_RGBX_SNORM16;
       table[MESA_FORMAT_RGBX_FLOAT16] = unpack_XBGR16161616_FLOAT;
       table[MESA_FORMAT_RGBX_UINT16] = unpack_XBGR16161616_UINT;
       table[MESA_FORMAT_RGBX_SINT16] = unpack_XBGR16161616_SINT;
@@ -2554,10 +2583,11 @@ get_unpack_rgba_function(mesa_format format)
 
       table[MESA_FORMAT_R10G10B10A2_UNORM] = unpack_R10G10B10A2_UNORM;
 
-      table[MESA_FORMAT_G8R8_SNORM] = unpack_SIGNED_G8R8_UNORM;
-      table[MESA_FORMAT_G16R16_SNORM] = unpack_SIGNED_G16R16_UNORM;
+      table[MESA_FORMAT_G8R8_SNORM] = unpack_G8R8_SNORM;
+      table[MESA_FORMAT_G16R16_SNORM] = unpack_G16R16_SNORM;
 
       table[MESA_FORMAT_B8G8R8X8_SRGB] = unpack_B8G8R8X8_SRGB;
+      table[MESA_FORMAT_X8R8G8B8_SRGB] = unpack_X8R8G8B8_SRGB;
 
       initialized = GL_TRUE;
    }
@@ -3560,7 +3590,7 @@ unpack_int_rgba_INTENSITY_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
 }
 
 static void
-unpack_int_rgba_ARGB2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n)
+unpack_int_rgba_B10G10R10A2_UINT(const GLuint *src, GLuint dst[][4], GLuint n)
 {
    unsigned int i;
 
@@ -3574,7 +3604,7 @@ unpack_int_rgba_ARGB2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n)
 }
 
 static void
-unpack_int_rgba_ABGR2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n)
+unpack_int_rgba_R10G10B10A2_UINT(const GLuint *src, GLuint dst[][4], GLuint n)
 {
    unsigned int i;
 
@@ -3848,11 +3878,11 @@ _mesa_unpack_uint_rgba_row(mesa_format format, GLuint n,
       break;
 
    case MESA_FORMAT_B10G10R10A2_UINT:
-      unpack_int_rgba_ARGB2101010_UINT(src, dst, n);
+      unpack_int_rgba_B10G10R10A2_UINT(src, dst, n);
       break;
 
    case MESA_FORMAT_R10G10B10A2_UINT:
-      unpack_int_rgba_ABGR2101010_UINT(src, dst, n);
+      unpack_int_rgba_R10G10B10A2_UINT(src, dst, n);
       break;
 
    case MESA_FORMAT_B10G10R10A2_UNORM:
@@ -3935,7 +3965,7 @@ _mesa_unpack_rgba_block(mesa_format format,
 typedef void (*unpack_float_z_func)(GLuint n, const void *src, GLfloat *dst);
 
 static void
-unpack_float_z_Z24_X8(GLuint n, const void *src, GLfloat *dst)
+unpack_float_z_X8_UINT_Z24_UNORM(GLuint n, const void *src, GLfloat *dst)
 {
    /* only return Z, not stencil data */
    const GLuint *s = ((const GLuint *) src);
@@ -3949,7 +3979,7 @@ unpack_float_z_Z24_X8(GLuint n, const void *src, GLfloat *dst)
 }
 
 static void
-unpack_float_z_X8_Z24(GLuint n, const void *src, GLfloat *dst)
+unpack_float_z_Z24_UNORM_X8_UINT(GLuint n, const void *src, GLfloat *dst)
 {
    /* only return Z, not stencil data */
    const GLuint *s = ((const GLuint *) src);
@@ -3963,7 +3993,7 @@ unpack_float_z_X8_Z24(GLuint n, const void *src, GLfloat *dst)
 }
 
 static void
-unpack_float_z_Z16(GLuint n, const void *src, GLfloat *dst)
+unpack_float_Z_UNORM16(GLuint n, const void *src, GLfloat *dst)
 {
    const GLushort *s = ((const GLushort *) src);
    GLuint i;
@@ -3973,7 +4003,7 @@ unpack_float_z_Z16(GLuint n, const void *src, GLfloat *dst)
 }
 
 static void
-unpack_float_z_Z32(GLuint n, const void *src, GLfloat *dst)
+unpack_float_Z_UNORM32(GLuint n, const void *src, GLfloat *dst)
 {
    const GLuint *s = ((const GLuint *) src);
    GLuint i;
@@ -3983,7 +4013,7 @@ unpack_float_z_Z32(GLuint n, const void *src, GLfloat *dst)
 }
 
 static void
-unpack_float_z_Z32F(GLuint n, const void *src, GLfloat *dst)
+unpack_float_Z_FLOAT32(GLuint n, const void *src, GLfloat *dst)
 {
    memcpy(dst, src, n * sizeof(float));
 }
@@ -4013,20 +4043,20 @@ _mesa_unpack_float_z_row(mesa_format format, GLuint n,
    switch (format) {
    case MESA_FORMAT_S8_UINT_Z24_UNORM:
    case MESA_FORMAT_X8_UINT_Z24_UNORM:
-      unpack = unpack_float_z_Z24_X8;
+      unpack = unpack_float_z_X8_UINT_Z24_UNORM;
       break;
    case MESA_FORMAT_Z24_UNORM_S8_UINT:
    case MESA_FORMAT_Z24_UNORM_X8_UINT:
-      unpack = unpack_float_z_X8_Z24;
+      unpack = unpack_float_z_Z24_UNORM_X8_UINT;
       break;
    case MESA_FORMAT_Z_UNORM16:
-      unpack = unpack_float_z_Z16;
+      unpack = unpack_float_Z_UNORM16;
       break;
    case MESA_FORMAT_Z_UNORM32:
-      unpack = unpack_float_z_Z32;
+      unpack = unpack_float_Z_UNORM32;
       break;
    case MESA_FORMAT_Z_FLOAT32:
-      unpack = unpack_float_z_Z32F;
+      unpack = unpack_float_Z_FLOAT32;
       break;
    case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
       unpack = unpack_float_z_Z32X24S8;
@@ -4045,7 +4075,7 @@ _mesa_unpack_float_z_row(mesa_format format, GLuint n,
 typedef void (*unpack_uint_z_func)(const void *src, GLuint *dst, GLuint n);
 
 static void
-unpack_uint_z_Z24_X8(const void *src, GLuint *dst, GLuint n)
+unpack_uint_z_X8_UINT_Z24_UNORM(const void *src, GLuint *dst, GLuint n)
 {
    /* only return Z, not stencil data */
    const GLuint *s = ((const GLuint *) src);
@@ -4056,7 +4086,7 @@ unpack_uint_z_Z24_X8(const void *src, GLuint *dst, GLuint n)
 }
 
 static void
-unpack_uint_z_X8_Z24(const void *src, GLuint *dst, GLuint n)
+unpack_uint_z_Z24_UNORM_X8_UINT(const void *src, GLuint *dst, GLuint n)
 {
    /* only return Z, not stencil data */
    const GLuint *s = ((const GLuint *) src);
@@ -4067,7 +4097,7 @@ unpack_uint_z_X8_Z24(const void *src, GLuint *dst, GLuint n)
 }
 
 static void
-unpack_uint_z_Z16(const void *src, GLuint *dst, GLuint n)
+unpack_uint_Z_UNORM16(const void *src, GLuint *dst, GLuint n)
 {
    const GLushort *s = ((const GLushort *)src);
    GLuint i;
@@ -4077,13 +4107,13 @@ unpack_uint_z_Z16(const void *src, GLuint *dst, GLuint n)
 }
 
 static void
-unpack_uint_z_Z32(const void *src, GLuint *dst, GLuint n)
+unpack_uint_Z_UNORM32(const void *src, GLuint *dst, GLuint n)
 {
    memcpy(dst, src, n * sizeof(GLuint));
 }
 
 static void
-unpack_uint_z_Z32_FLOAT(const void *src, GLuint *dst, GLuint n)
+unpack_uint_Z_FLOAT32(const void *src, GLuint *dst, GLuint n)
 {
    const float *s = (const float *)src;
    GLuint i;
@@ -4093,7 +4123,7 @@ unpack_uint_z_Z32_FLOAT(const void *src, GLuint *dst, GLuint n)
 }
 
 static void
-unpack_uint_z_Z32_FLOAT_X24S8(const void *src, GLuint *dst, GLuint n)
+unpack_uint_Z_FLOAT32_X24S8(const void *src, GLuint *dst, GLuint n)
 {
    const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
    GLuint i;
@@ -4118,23 +4148,23 @@ _mesa_unpack_uint_z_row(mesa_format format, GLuint n,
    switch (format) {
    case MESA_FORMAT_S8_UINT_Z24_UNORM:
    case MESA_FORMAT_X8_UINT_Z24_UNORM:
-      unpack = unpack_uint_z_Z24_X8;
+      unpack = unpack_uint_z_X8_UINT_Z24_UNORM;
       break;
    case MESA_FORMAT_Z24_UNORM_S8_UINT:
    case MESA_FORMAT_Z24_UNORM_X8_UINT:
-      unpack = unpack_uint_z_X8_Z24;
+      unpack = unpack_uint_z_Z24_UNORM_X8_UINT;
       break;
    case MESA_FORMAT_Z_UNORM16:
-      unpack = unpack_uint_z_Z16;
+      unpack = unpack_uint_Z_UNORM16;
       break;
    case MESA_FORMAT_Z_UNORM32:
-      unpack = unpack_uint_z_Z32;
+      unpack = unpack_uint_Z_UNORM32;
       break;
    case MESA_FORMAT_Z_FLOAT32:
-      unpack = unpack_uint_z_Z32_FLOAT;
+      unpack = unpack_uint_Z_FLOAT32;
       break;
    case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
-      unpack = unpack_uint_z_Z32_FLOAT_X24S8;
+      unpack = unpack_uint_Z_FLOAT32_X24S8;
       break;
    default:
       _mesa_problem(NULL, "bad format %s in _mesa_unpack_uint_z_row",
@@ -4147,13 +4177,13 @@ _mesa_unpack_uint_z_row(mesa_format format, GLuint n,
 
 
 static void
-unpack_ubyte_s_S8(const void *src, GLubyte *dst, GLuint n)
+unpack_ubyte_s_S_UINT8(const void *src, GLubyte *dst, GLuint n)
 {
    memcpy(dst, src, n);
 }
 
 static void
-unpack_ubyte_s_Z24_S8(const void *src, GLubyte *dst, GLuint n)
+unpack_ubyte_s_S8_UINT_Z24_UNORM(const void *src, GLubyte *dst, GLuint n)
 {
    GLuint i;
    const GLuint *src32 = src;
@@ -4163,7 +4193,7 @@ unpack_ubyte_s_Z24_S8(const void *src, GLubyte *dst, GLuint n)
 }
 
 static void
-unpack_ubyte_s_S8_Z24(const void *src, GLubyte *dst, GLuint n)
+unpack_ubyte_s_Z24_UNORM_S8_UINT(const void *src, GLubyte *dst, GLuint n)
 {
    GLuint i;
    const GLuint *src32 = src;
@@ -4173,7 +4203,7 @@ unpack_ubyte_s_S8_Z24(const void *src, GLubyte *dst, GLuint n)
 }
 
 static void
-unpack_ubyte_s_Z32_FLOAT_X24S8(const void *src, GLubyte *dst, GLuint n)
+unpack_ubyte_s_Z32_FLOAT_S8X24_UINT(const void *src, GLubyte *dst, GLuint n)
 {
    GLuint i;
    const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
@@ -4188,16 +4218,16 @@ _mesa_unpack_ubyte_stencil_row(mesa_format format, GLuint n,
 {
    switch (format) {
    case MESA_FORMAT_S_UINT8:
-      unpack_ubyte_s_S8(src, dst, n);
+      unpack_ubyte_s_S_UINT8(src, dst, n);
       break;
    case MESA_FORMAT_S8_UINT_Z24_UNORM:
-      unpack_ubyte_s_Z24_S8(src, dst, n);
+      unpack_ubyte_s_S8_UINT_Z24_UNORM(src, dst, n);
       break;
    case MESA_FORMAT_Z24_UNORM_S8_UINT:
-      unpack_ubyte_s_S8_Z24(src, dst, n);
+      unpack_ubyte_s_Z24_UNORM_S8_UINT(src, dst, n);
       break;
    case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
-      unpack_ubyte_s_Z32_FLOAT_X24S8(src, dst, n);
+      unpack_ubyte_s_Z32_FLOAT_S8X24_UINT(src, dst, n);
       break;
    default:
       _mesa_problem(NULL, "bad format %s in _mesa_unpack_ubyte_s_row",
@@ -4207,7 +4237,7 @@ _mesa_unpack_ubyte_stencil_row(mesa_format format, GLuint n,
 }
 
 static void
-unpack_uint_24_8_depth_stencil_S8_Z24(const GLuint *src, GLuint *dst, GLuint n)
+unpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(const GLuint *src, GLuint *dst, GLuint n)
 {
    GLuint i;
 
@@ -4233,7 +4263,7 @@ unpack_uint_24_8_depth_stencil_Z32_S8X24(const GLuint *src,
 }
 
 static void
-unpack_uint_24_8_depth_stencil_Z24_S8(const GLuint *src, GLuint *dst, GLuint n)
+unpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(const GLuint *src, GLuint *dst, GLuint n)
 {
    memcpy(dst, src, n * 4);
 }
@@ -4248,10 +4278,10 @@ _mesa_unpack_uint_24_8_depth_stencil_row(mesa_format format, GLuint n,
 {
    switch (format) {
    case MESA_FORMAT_S8_UINT_Z24_UNORM:
-      unpack_uint_24_8_depth_stencil_Z24_S8(src, dst, n);
+      unpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(src, dst, n);
       break;
    case MESA_FORMAT_Z24_UNORM_S8_UINT:
-      unpack_uint_24_8_depth_stencil_S8_Z24(src, dst, n);
+      unpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(src, dst, n);
       break;
    case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
       unpack_uint_24_8_depth_stencil_Z32_S8X24(src, dst, n);
@@ -4263,3 +4293,108 @@ _mesa_unpack_uint_24_8_depth_stencil_row(mesa_format format, GLuint n,
       return;
    }
 }
+
+static void
+unpack_float_32_uint_24_8_Z24_UNORM_S8_UINT(const GLuint *src,
+                                            GLuint *dst, GLuint n)
+{
+   GLuint i;
+   struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
+   const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
+
+   for (i = 0; i < n; i++) {
+      const GLuint z24 = src[i] & 0xffffff;
+      d[i].z = z24 * scale;
+      d[i].x24s8 = src[i] >> 24;
+      assert(d[i].z >= 0.0f);
+      assert(d[i].z <= 1.0f);
+   }
+}
+
+static void
+unpack_float_32_uint_24_8_Z32_FLOAT_S8X24_UINT(const GLuint *src,
+                                               GLuint *dst, GLuint n)
+{
+   memcpy(dst, src, n * sizeof(struct z32f_x24s8));
+}
+
+static void
+unpack_float_32_uint_24_8_S8_UINT_Z24_UNORM(const GLuint *src,
+                                            GLuint *dst, GLuint n)
+{
+   GLuint i;
+   struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
+   const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
+
+   for (i = 0; i < n; i++) {
+      const GLuint z24 = src[i] >> 8;
+      d[i].z = z24 * scale;
+      d[i].x24s8 = src[i] & 0xff;
+      assert(d[i].z >= 0.0f);
+      assert(d[i].z <= 1.0f);
+   }
+}
+
+/**
+ * Unpack depth/stencil returning as GL_FLOAT_32_UNSIGNED_INT_24_8_REV.
+ * \param format  the source data format
+ *
+ * In GL_FLOAT_32_UNSIGNED_INT_24_8_REV lower 4 bytes contain float
+ * component and higher 4 bytes contain packed 24-bit and 8-bit
+ * components.
+ *
+ *    31 30 29 28 ... 4 3 2 1 0    31 30 29 ... 9 8 7 6 5 ... 2 1 0
+ *    +-------------------------+  +--------------------------------+
+ *    |    Float Component      |  | Unused         | 8 bit stencil |
+ *    +-------------------------+  +--------------------------------+
+ *          lower 4 bytes                  higher 4 bytes
+ */
+void
+_mesa_unpack_float_32_uint_24_8_depth_stencil_row(mesa_format format, GLuint n,
+                                                 const void *src, GLuint *dst)
+{
+   switch (format) {
+   case MESA_FORMAT_S8_UINT_Z24_UNORM:
+      unpack_float_32_uint_24_8_S8_UINT_Z24_UNORM(src, dst, n);
+      break;
+   case MESA_FORMAT_Z24_UNORM_S8_UINT:
+      unpack_float_32_uint_24_8_Z24_UNORM_S8_UINT(src, dst, n);
+      break;
+   case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
+      unpack_float_32_uint_24_8_Z32_FLOAT_S8X24_UINT(src, dst, n);
+      break;
+   default:
+      _mesa_problem(NULL,
+                    "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
+                    _mesa_get_format_name(format));
+      return;
+   }
+}
+
+/**
+ * Unpack depth/stencil
+ * \param format  the source data format
+ * \param type the destination data type
+ */
+void
+_mesa_unpack_depth_stencil_row(mesa_format format, GLuint n,
+                              const void *src, GLenum type,
+                               GLuint *dst)
+{
+   assert(type == GL_UNSIGNED_INT_24_8 ||
+          type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+
+   switch (type) {
+   case GL_UNSIGNED_INT_24_8:
+      _mesa_unpack_uint_24_8_depth_stencil_row(format, n, src, dst);
+      break;
+   case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+      _mesa_unpack_float_32_uint_24_8_depth_stencil_row(format, n, src, dst);
+      break;
+   default:
+      _mesa_problem(NULL,
+                    "bad type 0x%x in _mesa_unpack_depth_stencil_row",
+                    type);
+      return;
+   }
+}