OSDN Git Service

Added big-endian texture formats.
authorBrian Paul <brian.paul@tungstengraphics.com>
Wed, 12 May 2004 01:50:30 +0000 (01:50 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Wed, 12 May 2004 01:50:30 +0000 (01:50 +0000)
Moved CI->RGBA palette lookup into texel fetch function.

src/mesa/main/colormac.h
src/mesa/main/mtypes.h
src/mesa/main/texformat.c
src/mesa/main/texformat.h
src/mesa/main/texformat_tmp.h
src/mesa/main/teximage.c
src/mesa/main/texstore.c
src/mesa/main/texstore.h
src/mesa/swrast/s_texture.c

index cf89a81..9b67fa1 100644 (file)
@@ -1,13 +1,8 @@
-/**
- * \file colormac.h
- * Color-related macros
- */
-
 /*
  * Mesa 3-D graphics library
- * Version:  5.1
+ * Version:  6.1
  *
- * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  */
 
 
+/**
+ * \file colormac.h
+ * Color-related macros
+ */
+
 
 #ifndef COLORMAC_H
 #define COLORMAC_H
@@ -174,66 +174,42 @@ do {                                              \
 
 
 /**
- * \name Generic color packing macros
+ * \name Generic color packing macros.  All inputs should be GLubytes.
  *
- * \todo We may move these into texutil.h at some point.
+ * \todo We may move these into texstore.h at some point.
  */
 /*@{*/
 
-#define PACK_COLOR_8888( a, b, c, d )                                  \
-   (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
-
-#define PACK_COLOR_888( a, b, c )                                      \
-   (((a) << 16) | ((b) << 8) | (c))
-
-#define PACK_COLOR_565( a, b, c )                                      \
-   ((((a) & 0xf8) << 8) | (((b) & 0xfc) << 3) | (((c) & 0xf8) >> 3))
-
-#define PACK_COLOR_1555( a, b, c, d )                                  \
-   ((((b) & 0xf8) << 7) | (((c) & 0xf8) << 2) | (((d) & 0xf8) >> 3) |  \
-    ((a) ? 0x8000 : 0))
-
-#define PACK_COLOR_4444( a, b, c, d )                                  \
-   ((((a) & 0xf0) << 8) | (((b) & 0xf0) << 4) | ((c) & 0xf0) | ((d) >> 4))
-
-#define PACK_COLOR_88( a, b )                                          \
-   (((a) << 8) | (b))
-
-#define PACK_COLOR_332( a, b, c )                                      \
-   (((a) & 0xe0) | (((b) & 0xe0) >> 3) | (((c) & 0xc0) >> 6))
-
-
-#ifdef MESA_BIG_ENDIAN
-
-#define PACK_COLOR_8888_LE( a, b, c, d )       PACK_COLOR_8888( d, c, b, a )
-
-#define PACK_COLOR_565_LE( a, b, c )                                   \
-   (((a) & 0xf8) | (((b) & 0xe0) >> 5) | (((b) & 0x1c) << 11) |                \
-   (((c) & 0xf8) << 5))
-
-#define PACK_COLOR_1555_LE( a, b, c, d )                               \
-   ((((b) & 0xf8) >> 1) | (((c) & 0xc0) >> 6) | (((c) & 0x38) << 10) | \
-    (((d) & 0xf8) << 5) | ((a) ? 0x80 : 0))
-
-#define PACK_COLOR_4444_LE( a, b, c, d )       PACK_COLOR_4444( c, d, a, b )
-
-#define PACK_COLOR_88_LE( a, b )               PACK_COLOR_88( b, a )
+#define PACK_COLOR_8888( R, G, B, A )                                  \
+   (((R) << 24) | ((G) << 16) | ((B) << 8) | (A))
 
-#else  /* little endian */
+#define PACK_COLOR_888( R, G, B )                                      \
+   (((R) << 16) | ((G) << 8) | (B))
 
-#define PACK_COLOR_8888_LE( a, b, c, d )       PACK_COLOR_8888( a, b, c, d )
+#define PACK_COLOR_565( R, G, B )                                      \
+   ((((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | (((B) & 0xf8) >> 3))
 
-#define PACK_COLOR_565_LE( a, b, c )           PACK_COLOR_565( a, b, c )
+#define PACK_COLOR_1555( A, B, G, R )                                  \
+   ((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) |  \
+    ((A) ? 0x8000 : 0))
 
-#define PACK_COLOR_1555_LE( a, b, c, d )       PACK_COLOR_1555( a, b, c, d )
+#define PACK_COLOR_5551( R, G, B, A )                                  \
+   ((((B) & 0xf8) << 8) |                                              \
+    (((G) & 0xf8) << 3) |                                              \
+    (((R) & 0xf8) >> 2) |                                              \
+    (((A) & 0x80) >> 7))
 
-#define PACK_COLOR_4444_LE( a, b, c, d )       PACK_COLOR_4444( a, b, c, d )
+#define PACK_COLOR_4444( R, G, B, A )                                  \
+   ((((R) & 0xf0) << 8) | (((G) & 0xf0) << 4) | ((B) & 0xf0) | ((A) >> 4))
 
-#define PACK_COLOR_88_LE( a, b )               PACK_COLOR_88( a, b )
+#define PACK_COLOR_88( L, A )                                          \
+   (((L) << 8) | (A))
 
-#endif /* endianness */
+#define PACK_COLOR_332( R, G, B )                                      \
+   (((R) & 0xe0) | (((G) & 0xe0) >> 3) | (((B) & 0xc0) >> 6))
 
-/*@}*/
+#define PACK_COLOR_233( B, G, R )                                      \
+   (((B) & 0xc0) | (((G) & 0xe0) >> 2) | (((R) & 0xe0) >> 5))
 
 
 #endif /* COLORMAC_H */
index 1458f16..a0b254a 100644 (file)
@@ -1116,6 +1116,8 @@ struct gl_texture_image {
 
    const struct gl_texture_format *TexFormat;
 
+   struct gl_texture_object *TexObject;  /**< Pointer back to parent object */
+
    FetchTexelFuncC FetchTexelc;        /**< GLchan texel fetch function pointer */
    FetchTexelFuncF FetchTexelf;        /**< Float texel fetch function pointer */
 
index c018e0c..00e15b9 100644 (file)
@@ -217,28 +217,6 @@ const struct gl_texture_format _mesa_texformat_intensity = {
    fetch_texel_3d_f_intensity,         /* FetchTexel3Df */
 };
 
-const struct gl_texture_format _mesa_texformat_color_index = {
-   MESA_FORMAT_COLOR_INDEX,            /* MesaFormat */
-   GL_COLOR_INDEX,                     /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   CHAN_BITS,                          /* IndexBits */
-   0,                                  /* DepthBits */
-   sizeof(GLchan),                     /* TexelBytes */
-   _mesa_texstore_color_index,         /* StoreTexImageFunc */
-   fetch_texel_1d_color_index,         /* FetchTexel1D */
-   fetch_texel_2d_color_index,         /* FetchTexel2D */
-   fetch_texel_3d_color_index,         /* FetchTexel3D */
-   fetch_texel_1d_f_color_index,       /* FetchTexel1Df */
-   fetch_texel_2d_f_color_index,       /* FetchTexel2Df */
-   fetch_texel_3d_f_color_index,       /* FetchTexel3Df */
-};
-
 const struct gl_texture_format _mesa_texformat_depth_component_float32 = {
    MESA_FORMAT_DEPTH_COMPONENT_FLOAT32,        /* MesaFormat */
    GL_DEPTH_COMPONENT,                 /* BaseFormat */
@@ -577,6 +555,28 @@ const struct gl_texture_format _mesa_texformat_rgba8888 = {
    fetch_texel_3d_f_rgba8888,          /* FetchTexel3Df */
 };
 
+const struct gl_texture_format _mesa_texformat_abgr8888 = {
+   MESA_FORMAT_ABGR8888,               /* 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 */
+   4,                                  /* TexelBytes */
+   _mesa_texstore_abgr8888,            /* StoreTexImageFunc */
+   fetch_texel_1d_abgr8888,            /* FetchTexel1D */
+   fetch_texel_2d_abgr8888,            /* FetchTexel2D */
+   fetch_texel_3d_abgr8888,            /* FetchTexel3D */
+   fetch_texel_1d_f_abgr8888,          /* FetchTexel1Df */
+   fetch_texel_2d_f_abgr8888,          /* FetchTexel2Df */
+   fetch_texel_3d_f_abgr8888,          /* FetchTexel3Df */
+};
+
 const struct gl_texture_format _mesa_texformat_argb8888 = {
    MESA_FORMAT_ARGB8888,               /* MesaFormat */
    GL_RGBA,                            /* BaseFormat */
@@ -599,6 +599,28 @@ const struct gl_texture_format _mesa_texformat_argb8888 = {
    fetch_texel_3d_f_argb8888,          /* FetchTexel3Df */
 };
 
+const struct gl_texture_format _mesa_texformat_bgra8888 = {
+   MESA_FORMAT_BGRA8888,               /* 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 */
+   4,                                  /* TexelBytes */
+   _mesa_texstore_bgra8888,            /* StoreTexImageFunc */
+   fetch_texel_1d_bgra8888,            /* FetchTexel1D */
+   fetch_texel_2d_bgra8888,            /* FetchTexel2D */
+   fetch_texel_3d_bgra8888,            /* FetchTexel3D */
+   fetch_texel_1d_f_bgra8888,          /* FetchTexel1Df */
+   fetch_texel_2d_f_bgra8888,          /* FetchTexel2Df */
+   fetch_texel_3d_f_bgra8888,          /* FetchTexel3Df */
+};
+
 const struct gl_texture_format _mesa_texformat_rgb888 = {
    MESA_FORMAT_RGB888,                 /* MesaFormat */
    GL_RGB,                             /* BaseFormat */
@@ -621,6 +643,28 @@ const struct gl_texture_format _mesa_texformat_rgb888 = {
    fetch_texel_3d_f_rgb888,            /* FetchTexel3Df */
 };
 
+const struct gl_texture_format _mesa_texformat_bgr888 = {
+   MESA_FORMAT_BGR888,                 /* MesaFormat */
+   GL_RGB,                             /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   8,                                  /* RedBits */
+   8,                                  /* GreenBits */
+   8,                                  /* BlueBits */
+   0,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   0,                                  /* DepthBits */
+   3,                                  /* TexelBytes */
+   _mesa_texstore_bgr888,              /* StoreTexImageFunc */
+   fetch_texel_1d_bgr888,              /* FetchTexel1D */
+   fetch_texel_2d_bgr888,              /* FetchTexel2D */
+   fetch_texel_3d_bgr888,              /* FetchTexel3D */
+   fetch_texel_1d_f_bgr888,            /* FetchTexel1Df */
+   fetch_texel_2d_f_bgr888,            /* FetchTexel2Df */
+   fetch_texel_3d_f_bgr888,            /* FetchTexel3Df */
+};
+
 const struct gl_texture_format _mesa_texformat_rgb565 = {
    MESA_FORMAT_RGB565,                 /* MesaFormat */
    GL_RGB,                             /* BaseFormat */
@@ -643,6 +687,28 @@ const struct gl_texture_format _mesa_texformat_rgb565 = {
    fetch_texel_3d_f_rgb565,            /* FetchTexel3Df */
 };
 
+const struct gl_texture_format _mesa_texformat_bgr565 = {
+   MESA_FORMAT_BGR565,                 /* MesaFormat */
+   GL_RGB,                             /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   5,                                  /* RedBits */
+   6,                                  /* GreenBits */
+   5,                                  /* BlueBits */
+   0,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   0,                                  /* DepthBits */
+   2,                                  /* TexelBytes */
+   _mesa_texstore_bgr565,              /* StoreTexImageFunc */
+   fetch_texel_1d_bgr565,              /* FetchTexel1D */
+   fetch_texel_2d_bgr565,              /* FetchTexel2D */
+   fetch_texel_3d_bgr565,              /* FetchTexel3D */
+   fetch_texel_1d_f_bgr565,            /* FetchTexel1Df */
+   fetch_texel_2d_f_bgr565,            /* FetchTexel2Df */
+   fetch_texel_3d_f_bgr565,            /* FetchTexel3Df */
+};
+
 const struct gl_texture_format _mesa_texformat_argb4444 = {
    MESA_FORMAT_ARGB4444,               /* MesaFormat */
    GL_RGBA,                            /* BaseFormat */
@@ -665,6 +731,28 @@ const struct gl_texture_format _mesa_texformat_argb4444 = {
    fetch_texel_3d_f_argb4444,          /* FetchTexel3Df */
 };
 
+const struct gl_texture_format _mesa_texformat_bgra4444 = {
+   MESA_FORMAT_BGRA4444,               /* 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 */
+   2,                                  /* TexelBytes */
+   _mesa_texstore_bgra4444,            /* StoreTexImageFunc */
+   fetch_texel_1d_bgra4444,            /* FetchTexel1D */
+   fetch_texel_2d_bgra4444,            /* FetchTexel2D */
+   fetch_texel_3d_bgra4444,            /* FetchTexel3D */
+   fetch_texel_1d_f_bgra4444,          /* FetchTexel1Df */
+   fetch_texel_2d_f_bgra4444,          /* FetchTexel2Df */
+   fetch_texel_3d_f_bgra4444,          /* FetchTexel3Df */
+};
+
 const struct gl_texture_format _mesa_texformat_argb1555 = {
    MESA_FORMAT_ARGB1555,               /* MesaFormat */
    GL_RGBA,                            /* BaseFormat */
@@ -687,6 +775,28 @@ const struct gl_texture_format _mesa_texformat_argb1555 = {
    fetch_texel_3d_f_argb1555,          /* FetchTexel3Df */
 };
 
+const struct gl_texture_format _mesa_texformat_bgra5551 = {
+   MESA_FORMAT_BGRA5551,               /* 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 */
+   2,                                  /* TexelBytes */
+   _mesa_texstore_bgra5551,            /* StoreTexImageFunc */
+   fetch_texel_1d_bgra5551,            /* FetchTexel1D */
+   fetch_texel_2d_bgra5551,            /* FetchTexel2D */
+   fetch_texel_3d_bgra5551,            /* FetchTexel3D */
+   fetch_texel_1d_f_bgra5551,          /* FetchTexel1Df */
+   fetch_texel_2d_f_bgra5551,          /* FetchTexel2Df */
+   fetch_texel_3d_f_bgra5551,          /* FetchTexel3Df */
+};
+
 const struct gl_texture_format _mesa_texformat_al88 = {
    MESA_FORMAT_AL88,                   /* MesaFormat */
    GL_LUMINANCE_ALPHA,                 /* BaseFormat */
@@ -709,6 +819,28 @@ const struct gl_texture_format _mesa_texformat_al88 = {
    fetch_texel_3d_f_al88,              /* FetchTexel3Df */
 };
 
+const struct gl_texture_format _mesa_texformat_la88 = {
+   MESA_FORMAT_LA88,                   /* 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 */
+   2,                                  /* TexelBytes */
+   _mesa_texstore_la88,                        /* StoreTexImageFunc */
+   fetch_texel_1d_la88,                        /* FetchTexel1D */
+   fetch_texel_2d_la88,                        /* FetchTexel2D */
+   fetch_texel_3d_la88,                        /* FetchTexel3D */
+   fetch_texel_1d_f_la88,              /* FetchTexel1Df */
+   fetch_texel_2d_f_la88,              /* FetchTexel2Df */
+   fetch_texel_3d_f_la88,              /* FetchTexel3Df */
+};
+
 const struct gl_texture_format _mesa_texformat_rgb332 = {
    MESA_FORMAT_RGB332,                 /* MesaFormat */
    GL_RGB,                             /* BaseFormat */
@@ -731,6 +863,28 @@ const struct gl_texture_format _mesa_texformat_rgb332 = {
    fetch_texel_3d_f_rgb332,            /* FetchTexel3Df */
 };
 
+const struct gl_texture_format _mesa_texformat_bgr233 = {
+   MESA_FORMAT_BGR233,                 /* MesaFormat */
+   GL_RGB,                             /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   3,                                  /* RedBits */
+   3,                                  /* GreenBits */
+   2,                                  /* BlueBits */
+   0,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   0,                                  /* DepthBits */
+   1,                                  /* TexelBytes */
+   _mesa_texstore_bgr233,              /* StoreTexImageFunc */
+   fetch_texel_1d_bgr233,              /* FetchTexel1D */
+   fetch_texel_2d_bgr233,              /* FetchTexel2D */
+   fetch_texel_3d_bgr233,              /* FetchTexel3D */
+   fetch_texel_1d_f_bgr233,            /* FetchTexel1Df */
+   fetch_texel_2d_f_bgr233,            /* FetchTexel2Df */
+   fetch_texel_3d_f_bgr233,            /* FetchTexel3Df */
+};
+
 const struct gl_texture_format _mesa_texformat_a8 = {
    MESA_FORMAT_A8,                     /* MesaFormat */
    GL_ALPHA,                           /* BaseFormat */
@@ -863,177 +1017,6 @@ const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
    fetch_texel_3d_f_ycbcr_rev,         /* FetchTexel3Df */
 };
 
-
-/* Big-endian */
-#if 0
-const struct gl_texture_format _mesa_texformat_abgr8888 = {
-   MESA_FORMAT_ABGR8888,               /* 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 */
-   4,                                  /* TexelBytes */
-   NULL,                               /* StoreTexImageFunc */
-   fetch_texel_1d_abgr8888,            /* FetchTexel1D */
-   fetch_texel_2d_abgr8888,            /* FetchTexel2D */
-   fetch_texel_3d_abgr8888,            /* FetchTexel3D */
-   /* XXX float fetchers */
-};
-
-const struct gl_texture_format _mesa_texformat_bgra8888 = {
-   MESA_FORMAT_BGRA8888,               /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   GL_UNSIGNED_INT_8_8_8_8,            /* Type */
-   8,                                  /* RedBits */
-   8,                                  /* GreenBits */
-   8,                                  /* BlueBits */
-   8,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   4,                                  /* TexelBytes */
-   NULL,                               /* StoreTexImageFunc */
-   fetch_texel_1d_bgra8888,            /* FetchTexel1D */
-   fetch_texel_2d_bgra8888,            /* FetchTexel2D */
-   fetch_texel_3d_bgra8888,            /* FetchTexel3D */
-   /* XXX float fetchers */
-};
-
-const struct gl_texture_format _mesa_texformat_bgr888 = {
-   MESA_FORMAT_BGR888,                 /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   GL_UNSIGNED_BYTE,                   /* Type */
-   8,                                  /* RedBits */
-   8,                                  /* GreenBits */
-   8,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   3,                                  /* TexelBytes */
-   NULL,                               /* StoreTexImageFunc */
-   fetch_texel_1d_bgr888,              /* FetchTexel1D */
-   fetch_texel_2d_bgr888,              /* FetchTexel2D */
-   fetch_texel_3d_bgr888,              /* FetchTexel3D */
-   /* XXX float fetchers */
-};
-
-const struct gl_texture_format _mesa_texformat_bgr565 = {
-   MESA_FORMAT_BGR565,                 /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   GL_UNSIGNED_SHORT_5_6_5,            /* Type */
-   5,                                  /* RedBits */
-   6,                                  /* GreenBits */
-   5,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   2,                                  /* TexelBytes */
-   NULL,                               /* StoreTexImageFunc */
-   fetch_texel_1d_bgr565,              /* FetchTexel1D */
-   fetch_texel_2d_bgr565,              /* FetchTexel2D */
-   fetch_texel_3d_bgr565,              /* FetchTexel3D */
-   /* XXX float fetchers */
-};
-
-const struct gl_texture_format _mesa_texformat_bgra4444 = {
-   MESA_FORMAT_BGRA4444,               /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   GL_UNSIGNED_SHORT_4_4_4_4_REV,      /* Type */
-   4,                                  /* RedBits */
-   4,                                  /* GreenBits */
-   4,                                  /* BlueBits */
-   4,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   2,                                  /* TexelBytes */
-   NULL,                               /* StoreTexImageFunc */
-   fetch_texel_1d_bgra4444,            /* FetchTexel1D */
-   fetch_texel_2d_bgra4444,            /* FetchTexel2D */
-   fetch_texel_3d_bgra4444,            /* FetchTexel3D */
-   /* XXX float fetchers */
-};
-
-const struct gl_texture_format _mesa_texformat_bgra5551 = {
-   MESA_FORMAT_BGRA5551,               /* MesaFormat */
-   GL_RGBA,                            /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   GL_UNSIGNED_SHORT_1_5_5_5_REV,      /* Type */
-   5,                                  /* RedBits */
-   5,                                  /* GreenBits */
-   5,                                  /* BlueBits */
-   1,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   2,                                  /* TexelBytes */
-   NULL,                               /* StoreTexImageFunc */
-   fetch_texel_1d_bgra1555,            /* FetchTexel1D */
-   fetch_texel_2d_bgra1555,            /* FetchTexel2D */
-   fetch_texel_3d_bgra1555,            /* FetchTexel3D */
-   /* XXX float fetchers */
-};
-
-const struct gl_texture_format _mesa_texformat_la88 = {
-   MESA_FORMAT_LA88,                   /* MesaFormat */
-   GL_LUMINANCE_ALPHA,                 /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
-   GL_UNSIGNED_BYTE,                   /* Type */
-   0,                                  /* RedBits */
-   0,                                  /* GreenBits */
-   0,                                  /* BlueBits */
-   8,                                  /* AlphaBits */
-   8,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   2,                                  /* TexelBytes */
-   NULL,                               /* StoreTexImageFunc */
-   fetch_texel_1d_la88,                        /* FetchTexel1D */
-   fetch_texel_2d_la88,                        /* FetchTexel2D */
-   fetch_texel_3d_la88,                        /* FetchTexel3D */
-   /* XXX float fetchers */
-};
-
-const struct gl_texture_format _mesa_texformat_bgr233 = {
-   MESA_FORMAT_BGR233,                 /* MesaFormat */
-   GL_RGB,                             /* BaseFormat */
-   GL_UNSIGNED_NORMALIZED_ARB          /* DataType */
-   GL_UNSIGNED_BYTE_3_3_2,             /* Type */
-   3,                                  /* RedBits */
-   3,                                  /* GreenBits */
-   2,                                  /* BlueBits */
-   0,                                  /* AlphaBits */
-   0,                                  /* LuminanceBits */
-   0,                                  /* IntensityBits */
-   0,                                  /* IndexBits */
-   0,                                  /* DepthBits */
-   1,                                  /* TexelBytes */
-   NULL,                               /* StoreTexImageFunc */
-   fetch_texel_1d_bgr233,              /* FetchTexel1D */
-   fetch_texel_2d_bgr233,              /* FetchTexel2D */
-   fetch_texel_3d_bgr233,              /* FetchTexel3D */
-   /* XXX float fetchers */
-};
-#endif
-
 /*@}*/
 
 
@@ -1092,11 +1075,12 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       /* RGBA formats */
       case 4:
       case GL_RGBA:
-      case GL_RGBA8:
       case GL_RGB10_A2:
       case GL_RGBA12:
       case GL_RGBA16:
          return &_mesa_texformat_rgba;
+      case GL_RGBA8:
+         return &_mesa_texformat_rgba8888;
       case GL_RGB5_A1:
          return &_mesa_texformat_argb1555;
       case GL_RGBA2:
@@ -1120,10 +1104,11 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       /* Alpha formats */
       case GL_ALPHA:
       case GL_ALPHA4:
-      case GL_ALPHA8:
       case GL_ALPHA12:
       case GL_ALPHA16:
          return &_mesa_texformat_alpha;
+      case GL_ALPHA8:
+         return &_mesa_texformat_a8;
 
       /* Luminance formats */
       case 1:
@@ -1161,7 +1146,6 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       case GL_COLOR_INDEX4_EXT:
       case GL_COLOR_INDEX12_EXT:
       case GL_COLOR_INDEX16_EXT:
-         return &_mesa_texformat_color_index;
       case GL_COLOR_INDEX8_EXT:
          return &_mesa_texformat_ci8;
 
index d6cd02a..c785d10 100644 (file)
@@ -66,13 +66,21 @@ enum _format {
                                /* msb <------ TEXEL BITS -----------> lsb */
                                /* ---- ---- ---- ---- ---- ---- ---- ---- */
    MESA_FORMAT_RGBA8888,       /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
+   MESA_FORMAT_ABGR8888,       /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
    MESA_FORMAT_ARGB8888,       /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
+   MESA_FORMAT_BGRA8888,       /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
    MESA_FORMAT_RGB888,         /*           RRRR RRRR GGGG GGGG BBBB BBBB */
+   MESA_FORMAT_BGR888,         /*           BBBB BBBB GGGG GGGG RRRR RRRR */
    MESA_FORMAT_RGB565,         /*                     RRRR RGGG GGGB BBBB */
+   MESA_FORMAT_BGR565,         /*                     BBBB BGGG GGGR RRRR */
    MESA_FORMAT_ARGB4444,       /*                     AAAA RRRR GGGG BBBB */
+   MESA_FORMAT_BGRA4444,       /*                     AAAA RRRR GGGG BBBB */
    MESA_FORMAT_ARGB1555,       /*                     ARRR RRGG GGGB BBBB */
+   MESA_FORMAT_BGRA5551,       /*                     BBBB BGGG GGRR RRRA */
    MESA_FORMAT_AL88,           /*                     AAAA AAAA LLLL LLLL */
+   MESA_FORMAT_LA88,           /*                     LLLL LLLL AAAA AAAA */
    MESA_FORMAT_RGB332,         /*                               RRRG GGBB */
+   MESA_FORMAT_BGR233,         /*                               BBGG GRRR */
    MESA_FORMAT_A8,             /*                               AAAA AAAA */
    MESA_FORMAT_L8,             /*                               LLLL LLLL */
    MESA_FORMAT_I8,             /*                               IIII IIII */
@@ -81,24 +89,6 @@ enum _format {
    MESA_FORMAT_YCBCR_REV,      /*                     UorV UorV YYYY YYYY */
    /*@}*/
 
-#if 0
-   /** 
-    * \name Upcoming little-endian formats 
-    */
-   /*@{*/
-                               /* msb <------ TEXEL BITS -----------> lsb */
-                               /* ---- ---- ---- ---- ---- ---- ---- ---- */
-   MESA_FORMAT_ABGR8888,       /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
-   MESA_FORMAT_BGRA8888,       /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
-   MESA_FORMAT_BGR888,         /*           BBBB BBBB GGGG GGGG RRRR RRRR */
-   MESA_FORMAT_BGR565,         /*                     BBBB BGGG GGGR RRRR */
-   MESA_FORMAT_BGRA4444,       /*                     BBBB GGGG RRRR AAAA */
-   MESA_FORMAT_BGRA5551,       /*                     BBBB BGGG GGRR RRRA */
-   MESA_FORMAT_LA88,           /*                     LLLL LLLL AAAA AAAA */
-   MESA_FORMAT_BGR233,         /*                               BBGG GRRR */
-   /*@}*/
-#endif
-
    /**
     * \name Compressed texture formats.
     */
@@ -128,7 +118,6 @@ enum _format {
    MESA_FORMAT_LUMINANCE,
    MESA_FORMAT_LUMINANCE_ALPHA,
    MESA_FORMAT_INTENSITY,
-   MESA_FORMAT_COLOR_INDEX,
    /*@}*/
 
    /**
@@ -167,7 +156,6 @@ extern const struct gl_texture_format _mesa_texformat_alpha;
 extern const struct gl_texture_format _mesa_texformat_luminance;
 extern const struct gl_texture_format _mesa_texformat_luminance_alpha;
 extern const struct gl_texture_format _mesa_texformat_intensity;
-extern const struct gl_texture_format _mesa_texformat_color_index;
 /*@}*/
 
 /** Depth textures */
@@ -195,17 +183,26 @@ extern const struct gl_texture_format _mesa_texformat_intensity_float16;
 /** \name Assorted hardware-friendly formats */
 /*@{*/
 extern const struct gl_texture_format _mesa_texformat_rgba8888;
+extern const struct gl_texture_format _mesa_texformat_abgr8888;
 extern const struct gl_texture_format _mesa_texformat_argb8888;
+extern const struct gl_texture_format _mesa_texformat_bgra8888;
 extern const struct gl_texture_format _mesa_texformat_rgb888;
+extern const struct gl_texture_format _mesa_texformat_bgr888;
 extern const struct gl_texture_format _mesa_texformat_rgb565;
+extern const struct gl_texture_format _mesa_texformat_bgr565;
 extern const struct gl_texture_format _mesa_texformat_argb4444;
+extern const struct gl_texture_format _mesa_texformat_bgra4444;
 extern const struct gl_texture_format _mesa_texformat_argb1555;
+extern const struct gl_texture_format _mesa_texformat_bgra5551;
 extern const struct gl_texture_format _mesa_texformat_al88;
+extern const struct gl_texture_format _mesa_texformat_la88;
 extern const struct gl_texture_format _mesa_texformat_rgb332;
+extern const struct gl_texture_format _mesa_texformat_bgr233;
 extern const struct gl_texture_format _mesa_texformat_a8;
 extern const struct gl_texture_format _mesa_texformat_l8;
 extern const struct gl_texture_format _mesa_texformat_i8;
 extern const struct gl_texture_format _mesa_texformat_ci8;
+
 /*@}*/
 
 /** \name YCbCr formats */
index 5c5bf6d..3f49974 100644 (file)
@@ -228,23 +228,6 @@ static void FETCH(f_intensity)( const struct gl_texture_image *texImage,
 }
 
 
-/* Fetch CI texel from 1D, 2D or 3D CI texture, returning 1 GLchan */
-static void FETCH(color_index)( const struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, GLchan *texel )
-{
-   const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
-   texel[0] = src[0];
-}
-
-/* Fetch CI texel from 1D, 2D or 3D CI texture, returning 1 GLfloat */
-static void FETCH(f_color_index)( const struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
-   texel[0] = (GLfloat) src[0];
-}
-
-
 /* Fetch depth texel from 1D, 2D or 3D float32 DEPTH texture,
  * returning 1 GLfloat.
  * Note: no GLchan version of this function.
@@ -610,6 +593,29 @@ static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage,
 }
 
 
+/* Fetch color texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */
+static void FETCH(abgr8888)( const struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLchan *texel )
+{
+   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
+   texel[RCOMP] = UBYTE_TO_CHAN( src[0] );
+   texel[GCOMP] = UBYTE_TO_CHAN( src[1] );
+   texel[BCOMP] = UBYTE_TO_CHAN( src[2] );
+   texel[ACOMP] = UBYTE_TO_CHAN( src[3] );
+}
+
+/* Fetch color texel from 1D, 2D or 3D abgr8888 texture, return 4 GLfloats */
+static void FETCH(f_abgr8888)( const struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
+   texel[RCOMP] = UBYTE_TO_FLOAT( src[0] );
+   texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
+   texel[BCOMP] = UBYTE_TO_FLOAT( src[2] );
+   texel[ACOMP] = UBYTE_TO_FLOAT( src[3] );
+}
+
+
 /* Fetch color texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */
 static void FETCH(argb8888)( const struct gl_texture_image *texImage,
                             GLint i, GLint j, GLint k, GLchan *texel )
@@ -633,6 +639,29 @@ static void FETCH(f_argb8888)( const struct gl_texture_image *texImage,
 }
 
 
+/* Fetch color texel from 1D, 2D or 3D bgra8888 texture, return 4 GLchans */
+static void FETCH(bgra8888)( const struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLchan *texel )
+{
+   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
+   texel[RCOMP] = UBYTE_TO_CHAN( src[1] );
+   texel[GCOMP] = UBYTE_TO_CHAN( src[2] );
+   texel[BCOMP] = UBYTE_TO_CHAN( src[3] );
+   texel[ACOMP] = UBYTE_TO_CHAN( src[0] );
+}
+
+/* Fetch color texel from 1D, 2D or 3D bgra8888 texture, return 4 GLfloats */
+static void FETCH(f_bgra8888)( const struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
+   texel[RCOMP] = UBYTE_TO_FLOAT( src[1] );
+   texel[GCOMP] = UBYTE_TO_FLOAT( src[2] );
+   texel[BCOMP] = UBYTE_TO_FLOAT( src[3] );
+   texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
+}
+
+
 /* Fetch color texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */
 static void FETCH(rgb888)( const struct gl_texture_image *texImage,
                           GLint i, GLint j, GLint k, GLchan *texel )
@@ -656,6 +685,29 @@ static void FETCH(f_rgb888)( const struct gl_texture_image *texImage,
 }
 
 
+/* Fetch color texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */
+static void FETCH(bgr888)( const struct gl_texture_image *texImage,
+                          GLint i, GLint j, GLint k, GLchan *texel )
+{
+   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 );
+   texel[RCOMP] = UBYTE_TO_CHAN( src[0] );
+   texel[GCOMP] = UBYTE_TO_CHAN( src[1] );
+   texel[BCOMP] = UBYTE_TO_CHAN( src[2] );
+   texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch color texel from 1D, 2D or 3D bgr888 texture, return 4 GLfloats */
+static void FETCH(f_bgr888)( const struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 );
+   texel[RCOMP] = UBYTE_TO_FLOAT( src[0] );
+   texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
+   texel[BCOMP] = UBYTE_TO_FLOAT( src[2] );
+   texel[ACOMP] = CHAN_MAXF;
+}
+
+
 /* Fetch color texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */
 static void FETCH(rgb565)( const struct gl_texture_image *texImage,
                           GLint i, GLint j, GLint k, GLchan *texel )
@@ -681,7 +733,32 @@ static void FETCH(f_rgb565)( const struct gl_texture_image *texImage,
 }
 
 
-/* Fetch color texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */
+/* Fetch color texel from 1D, 2D or 3D bgr565 texture, return 4 GLchans */
+static void FETCH(bgr565)( const struct gl_texture_image *texImage,
+                          GLint i, GLint j, GLint k, GLchan *texel )
+{
+   const GLushort *src = USHORT_SRC( texImage, i, j, k );
+   const GLushort s = *src;
+   texel[RCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 );
+   texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc );
+   texel[BCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 );
+   texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch color texel from 1D, 2D or 3D bgr565 texture, return 4 GLfloats */
+static void FETCH(f_bgr565)( const struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort *src = USHORT_SRC( texImage, i, j, k );
+   const GLushort s = *src;
+   texel[RCOMP] = ((s << 3) & 0xf8) * (1.0F / 248.0F);
+   texel[GCOMP] = ((s >> 3) & 0xfc) * (1.0F / 252.0F);
+   texel[BCOMP] = ((s >> 8) & 0xf8) * (1.0F / 248.0F);
+   texel[ACOMP] = CHAN_MAXF;
+}
+
+
+/* Fetch color texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */
 static void FETCH(argb4444)( const struct gl_texture_image *texImage,
                             GLint i, GLint j, GLint k, GLchan *texel )
 {
@@ -693,7 +770,7 @@ static void FETCH(argb4444)( const struct gl_texture_image *texImage,
    texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf );
 }
 
-/* Fetch color texel from 1D, 2D or 3D rgb565 texture, return 4 GLfloats */
+/* Fetch color texel from 1D, 2D or 3D argb4444 texture, return 4 GLfloats */
 static void FETCH(f_argb4444)( const struct gl_texture_image *texImage,
                             GLint i, GLint j, GLint k, GLfloat *texel )
 {
@@ -706,6 +783,31 @@ static void FETCH(f_argb4444)( const struct gl_texture_image *texImage,
 }
 
 
+/* Fetch color texel from 1D, 2D or 3D bgra444 texture, return 4 GLchans */
+static void FETCH(bgra4444)( const struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLchan *texel )
+{
+   const GLushort *src = USHORT_SRC( texImage, i, j, k );
+   const GLushort s = *src;
+   texel[RCOMP] = UBYTE_TO_CHAN( ((s >>  4) & 0xf) * 255 / 0xf );
+   texel[GCOMP] = UBYTE_TO_CHAN( ((s >>  8) & 0xf) * 255 / 0xf );
+   texel[BCOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf );
+   texel[ACOMP] = UBYTE_TO_CHAN( ((s      ) & 0xf) * 255 / 0xf );
+}
+
+/* Fetch color texel from 1D, 2D or 3D bgra4444 texture, return 4 GLfloats */
+static void FETCH(f_bgra4444)( const struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort *src = USHORT_SRC( texImage, i, j, k );
+   const GLushort s = *src;
+   texel[RCOMP] = ((s >>  4) & 0xf) * (1.0F / 15.0F);
+   texel[GCOMP] = ((s >>  8) & 0xf) * (1.0F / 15.0F);
+   texel[BCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
+   texel[ACOMP] = ((s      ) & 0xf) * (1.0F / 15.0F);
+}
+
+
 /* Fetch color texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
 static void FETCH(argb1555)( const struct gl_texture_image *texImage,
                             GLint i, GLint j, GLint k, GLchan *texel )
@@ -731,6 +833,31 @@ static void FETCH(f_argb1555)( const struct gl_texture_image *texImage,
 }
 
 
+/* Fetch color texel from 1D, 2D or 3D bgra5551 texture, return 4 GLchans */
+static void FETCH(bgra5551)( const struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLchan *texel )
+{
+   const GLushort *src = USHORT_SRC( texImage, i, j, k );
+   const GLushort s = *src;
+   texel[RCOMP] = UBYTE_TO_CHAN( ((s >>  1) & 0x1f) * 255 / 0x1f );
+   texel[GCOMP] = UBYTE_TO_CHAN( ((s >>  6) & 0x1f) * 255 / 0x1f );
+   texel[BCOMP] = UBYTE_TO_CHAN( ((s >> 11) & 0x1f) * 255 / 0x1f );
+   texel[ACOMP] = UBYTE_TO_CHAN( ((s      ) & 0x01) * 255 );
+}
+
+/* Fetch color texel from 1D, 2D or 3D bgra5551 texture, return 4 GLfloats */
+static void FETCH(f_bgra5551)( const struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort *src = USHORT_SRC( texImage, i, j, k );
+   const GLushort s = *src;
+   texel[RCOMP] = ((s >>  1) & 0x1f) * (1.0F / 31.0F);
+   texel[GCOMP] = ((s >>  6) & 0x1f) * (1.0F / 31.0F);
+   texel[BCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F);
+   texel[ACOMP] = ((s      ) & 0x01);
+}
+
+
 /* Fetch color texel from 1D, 2D or 3D al88 texture, return 4 GLchans */
 static void FETCH(al88)( const struct gl_texture_image *texImage,
                         GLint i, GLint j, GLint k, GLchan *texel )
@@ -754,6 +881,29 @@ static void FETCH(f_al88)( const struct gl_texture_image *texImage,
 }
 
 
+/* Fetch color texel from 1D, 2D or 3D la88 texture, return 4 GLchans */
+static void FETCH(la88)( const struct gl_texture_image *texImage,
+                        GLint i, GLint j, GLint k, GLchan *texel )
+{
+   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 );
+   texel[RCOMP] = 
+   texel[GCOMP] = 
+   texel[BCOMP] = UBYTE_TO_CHAN( src[1] );
+   texel[ACOMP] = UBYTE_TO_CHAN( src[0] );
+}
+
+/* Fetch color texel from 1D, 2D or 3D la88 texture, return 4 GLfloats */
+static void FETCH(f_la88)( const struct gl_texture_image *texImage,
+                           GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 );
+   texel[RCOMP] = 
+   texel[GCOMP] = 
+   texel[BCOMP] = UBYTE_TO_FLOAT( src[1] );
+   texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
+}
+
+
 /* Fetch color texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */
 static void FETCH(rgb332)( const struct gl_texture_image *texImage,
                           GLint i, GLint j, GLint k, GLchan *texel )
@@ -779,6 +929,31 @@ static void FETCH(f_rgb332)( const struct gl_texture_image *texImage,
 }
 
 
+/* Fetch color texel from 1D, 2D or 3D bgr233 texture, return 4 GLchans */
+static void FETCH(bgr233)( const struct gl_texture_image *texImage,
+                          GLint i, GLint j, GLint k, GLchan *texel )
+{
+   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+   const GLubyte s = *src;
+   texel[RCOMP] = UBYTE_TO_CHAN( ((s & 0x07) * 255 / 0x07) );
+   texel[GCOMP] = UBYTE_TO_CHAN( ((s & 0x38) * 255 / 0x38) );
+   texel[BCOMP] = UBYTE_TO_CHAN( ((s & 0xc0) * 255 / 0xc0) );
+   texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch color texel from 1D, 2D or 3D bgr233 texture, return 4 GLfloats */
+static void FETCH(f_bgr233)( const struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+   const GLubyte s = *src;
+   texel[RCOMP] = (s & 0x07) * (1.0F / 7.0F);
+   texel[GCOMP] = (s & 0x38) * (1.0F / 56.0F);
+   texel[BCOMP] = (s & 0xc0) * (1.0F / 192.0F);
+   texel[ACOMP] = CHAN_MAXF;
+}
+
+
 /* Fetch color texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
 static void FETCH(a8)( const struct gl_texture_image *texImage,
                       GLint i, GLint j, GLint k, GLchan *texel )
@@ -848,22 +1023,86 @@ static void FETCH(f_i8)( const struct gl_texture_image *texImage,
 }
 
 
-/* Fetch color texel from 1D, 2D or 3D ci8 texture, return 1 GLchan */
+/* Fetch CI texel from 1D, 2D or 3D ci8 texture, lookup the index in a
+ * color table, and return 4 GLchans.
+ */
 static void FETCH(ci8)( const struct gl_texture_image *texImage,
                        GLint i, GLint j, GLint k, GLchan *texel )
 {
    const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
-   GLchan *index = (GLchan *) texel;
-   *index = UBYTE_TO_CHAN( *src );
+   const GLuint index = *src;
+   const struct gl_color_table *palette;
+   const GLchan *table;
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (ctx->Texture.SharedPalette) {
+      palette = &ctx->Texture.Palette;
+   }
+   else {
+      palette = &texImage->TexObject->Palette;
+   }
+   if (palette->Size == 0)
+      return; /* undefined results */
+   ASSERT(palette->Type != GL_FLOAT);
+   table = (const GLchan *) palette->Table;
+
+   switch (palette->Format) {
+      case GL_ALPHA:
+         texel[RCOMP] =
+         texel[GCOMP] =
+         texel[BCOMP] = 0;
+         texel[ACOMP] = table[index];
+         return;
+      case GL_LUMINANCE:
+         texel[RCOMP] =
+         texel[GCOMP] =
+         texel[BCOMP] = table[index];
+         texel[ACOMP] = CHAN_MAX;
+         break;
+      case GL_INTENSITY:
+         texel[RCOMP] =
+         texel[GCOMP] =
+         texel[BCOMP] =
+         texel[ACOMP] = table[index];
+         return;
+      case GL_LUMINANCE_ALPHA:
+         texel[RCOMP] =
+         texel[GCOMP] =
+         texel[BCOMP] = table[index * 2 + 0];
+         texel[ACOMP] = table[index * 2 + 1];
+         return;
+      case GL_RGB:
+         texel[RCOMP] = table[index * 3 + 0];
+         texel[GCOMP] = table[index * 3 + 1];
+         texel[BCOMP] = table[index * 3 + 2];
+         texel[ACOMP] = CHAN_MAX;
+         return;
+      case GL_RGBA:
+         texel[RCOMP] = table[index * 4 + 0];
+         texel[GCOMP] = table[index * 4 + 1];
+         texel[BCOMP] = table[index * 4 + 2];
+         texel[ACOMP] = table[index * 4 + 3];
+         return;
+      default:
+         _mesa_problem(ctx, "Bad palette format in palette_sample");
+   }
 }
 
 
-/* Fetch color texel from 1D, 2D or 3D ci8 texture, return 1 GLfloat */
+/* Fetch CI texel from 1D, 2D or 3D ci8 texture, lookup the index in a
+ * color table, and return 4 GLfloats.
+ */
 static void FETCH(f_ci8)( const struct gl_texture_image *texImage,
                           GLint i, GLint j, GLint k, GLfloat *texel )
 {
-   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
-   texel[0] = UBYTE_TO_FLOAT( *src );
+   GLchan rgba[4];
+   /* Sample as GLchan */
+   FETCH(ci8)(texImage, i, j, k, rgba);
+   /* and return as floats */
+   texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
+   texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
+   texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
+   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
 }
 
 
@@ -1002,95 +1241,6 @@ static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage,
 
 
 
-/* big-endian */
-
-#if 0
-static void FETCH(abgr8888)( const struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, GLchan *texel )
-{
-   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
-   texel[RCOMP] = UBYTE_TO_CHAN( src[3] );
-   texel[GCOMP] = UBYTE_TO_CHAN( src[2] );
-   texel[BCOMP] = UBYTE_TO_CHAN( src[1] );
-   texel[ACOMP] = UBYTE_TO_CHAN( src[0] );
-}
-
-static void FETCH(bgra8888)( const struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, GLchan *texel )
-{
-   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
-   texel[RCOMP] = UBYTE_TO_CHAN( src[2] );
-   texel[GCOMP] = UBYTE_TO_CHAN( src[1] );
-   texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
-   texel[ACOMP] = UBYTE_TO_CHAN( src[3] );
-}
-
-static void FETCH(bgr888)( const struct gl_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLchan *texel )
-{
-   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 );
-   texel[RCOMP] = UBYTE_TO_CHAN( src[2] );
-   texel[GCOMP] = UBYTE_TO_CHAN( src[1] );
-   texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
-   texel[ACOMP] = CHAN_MAX;
-}
-
-static void FETCH(bgr565)( const struct gl_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLchan *texel )
-{
-   const GLushort *src = USHORT_SRC( texImage, i, j, k );
-   const GLushort s = *src;
-   texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 );
-   texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc );
-   texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 );
-   texel[ACOMP] = CHAN_MAX;
-}
-
-static void FETCH(bgra4444)( const struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, GLchan *texel )
-{
-   const GLushort *src = USHORT_SRC( texImage, i, j, k );
-   const GLushort s = *src;
-   texel[RCOMP] = UBYTE_TO_CHAN( ((s >>  8) & 0xf) * 255 / 0xf );
-   texel[GCOMP] = UBYTE_TO_CHAN( ((s >>  4) & 0xf) * 255 / 0xf );
-   texel[BCOMP] = UBYTE_TO_CHAN( ((s      ) & 0xf) * 255 / 0xf );
-   texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf );
-}
-
-static void FETCH(bgra5551)( const struct gl_texture_image *texImage,
-                            GLint i, GLint j, GLint k, GLchan *texel )
-{
-   const GLushort *src = USHORT_SRC( texImage, i, j, k );
-   const GLushort s = *src;
-   texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f );
-   texel[GCOMP] = UBYTE_TO_CHAN( ((s >>  5) & 0x1f) * 255 / 0x1f );
-   texel[BCOMP] = UBYTE_TO_CHAN( ((s      ) & 0x1f) * 255 / 0x1f );
-   texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 );
-}
-
-static void FETCH(la88)( const struct gl_texture_image *texImage,
-                        GLint i, GLint j, GLint k, GLchan *texel )
-{
-   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 );
-   texel[RCOMP] = UBYTE_TO_CHAN( src[0] );
-   texel[GCOMP] = UBYTE_TO_CHAN( src[0] );
-   texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
-   texel[ACOMP] = UBYTE_TO_CHAN( src[1] );
-}
-
-static void FETCH(bgr233)( const struct gl_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLchan *texel )
-{
-   const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
-   const GLubyte s = *src;
-   texel[RCOMP] = UBYTE_TO_CHAN( ((s     ) & 0xe0) * 255 / 0xe0 );
-   texel[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 );
-   texel[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 );
-   texel[ACOMP] = CHAN_MAX;
-}
-#endif
-
-
 #undef CHAN_SRC
 #undef UBYTE_SRC
 #undef USHORT_SRC
index 1dbab88..355a50b 100644 (file)
@@ -502,7 +502,7 @@ _mesa_set_tex_image(struct gl_texture_object *tObj,
       case GL_TEXTURE_2D:
       case GL_TEXTURE_3D:
          tObj->Image[0][level] = texImage;
-         return;
+         break;
       case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
       case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
       case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
@@ -517,11 +517,13 @@ _mesa_set_tex_image(struct gl_texture_object *tObj,
       case GL_TEXTURE_RECTANGLE_NV:
          ASSERT(level == 0);
          tObj->Image[0][level] = texImage;
-         return;
+         break;
       default:
          _mesa_problem(NULL, "bad target in _mesa_set_tex_image()");
          return;
    }
+   /* Set the 'back' pointer */
+   texImage->TexObject = tObj;
 }
 
 
@@ -757,6 +759,8 @@ _mesa_get_proxy_tex_image(GLcontext *ctx, GLenum target, GLint level)
             return NULL;
          }
          ctx->Texture.Proxy1D->Image[0][level] = texImage;
+         /* Set the 'back' pointer */
+         texImage->TexObject = ctx->Texture.Proxy1D;
       }
       return texImage;
    case GL_PROXY_TEXTURE_2D:
@@ -770,6 +774,8 @@ _mesa_get_proxy_tex_image(GLcontext *ctx, GLenum target, GLint level)
             return NULL;
          }
          ctx->Texture.Proxy2D->Image[0][level] = texImage;
+         /* Set the 'back' pointer */
+         texImage->TexObject = ctx->Texture.Proxy2D;
       }
       return texImage;
    case GL_PROXY_TEXTURE_3D:
@@ -783,6 +789,8 @@ _mesa_get_proxy_tex_image(GLcontext *ctx, GLenum target, GLint level)
             return NULL;
          }
          ctx->Texture.Proxy3D->Image[0][level] = texImage;
+         /* Set the 'back' pointer */
+         texImage->TexObject = ctx->Texture.Proxy3D;
       }
       return texImage;
    case GL_PROXY_TEXTURE_CUBE_MAP:
@@ -796,6 +804,8 @@ _mesa_get_proxy_tex_image(GLcontext *ctx, GLenum target, GLint level)
             return NULL;
          }
          ctx->Texture.ProxyCubeMap->Image[0][level] = texImage;
+         /* Set the 'back' pointer */
+         texImage->TexObject = ctx->Texture.ProxyCubeMap;
       }
       return texImage;
    case GL_PROXY_TEXTURE_RECTANGLE_NV:
@@ -809,6 +819,8 @@ _mesa_get_proxy_tex_image(GLcontext *ctx, GLenum target, GLint level)
             return NULL;
          }
          ctx->Texture.ProxyRect->Image[0][level] = texImage;
+         /* Set the 'back' pointer */
+         texImage->TexObject = ctx->Texture.ProxyRect;
       }
       return texImage;
    default:
@@ -1922,8 +1934,6 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
       return;
    }
 
-
-
    {
       const GLint width = texImage->Width;
       const GLint height = texImage->Height;
@@ -1940,10 +1950,25 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
             if (format == GL_COLOR_INDEX) {
                GLuint indexRow[MAX_WIDTH];
                GLint col;
-               for (col = 0; col < width; col++) {
-                  GLchan indx;
-                  (*texImage->FetchTexelc)(texImage, col, row, img, &indx);
-                  indexRow[col] = indx;
+               /* Can't use FetchTexel here because that returns RGBA */
+               if (texImage->TexFormat->IndexBits == 8) {
+                  const GLubyte *src = (const GLubyte *) texImage->Data;
+                  for (col = 0; col < width; col++) {
+                     indexRow[col] = src[texImage->Width *
+                                        (img * texImage->Height + row) + col];
+                  }
+               }
+               else if (texImage->TexFormat->IndexBits == 16) {
+                  const GLushort *src = (const GLushort *) texImage->Data;
+                  for (col = 0; col < width; col++) {
+                     indexRow[col] = src[texImage->Width *
+                                        (img * texImage->Height + row) + col];
+                  }
+               }
+               else {
+                  _mesa_problem(ctx,
+                                "Color index problem in _mesa_GetTexImage");
+                  return;
                }
                _mesa_pack_index_span(ctx, width, type, dest,
                                      indexRow, &ctx->Pack,
@@ -1954,7 +1979,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
                GLint col;
                for (col = 0; col < width; col++) {
                   (*texImage->FetchTexelf)(texImage, col, row, img,
-                                           (GLvoid *) &depthRow[col]);
+                                           depthRow + col);
                }
                _mesa_pack_depth_span(ctx, width, dest, type,
                                      depthRow, &ctx->Pack);
index 75845b1..f5d58f2 100644 (file)
@@ -671,19 +671,19 @@ _mesa_texstore_rgba(GLcontext *ctx, GLuint dims,
 
 
 /**
- * Store a color index texture image
+ * Store a floating point depth component texture image.
  */
 GLboolean
-_mesa_texstore_color_index(STORE_PARAMS)
+_mesa_texstore_depth_component_float32(STORE_PARAMS)
 {
-   ASSERT(dstFormat == &_mesa_texformat_color_index);
-   ASSERT(dstFormat->TexelBytes == 1 * sizeof(GLchan));
+   ASSERT(dstFormat == &_mesa_texformat_depth_component_float32);
+   ASSERT(dstFormat->TexelBytes == sizeof(GLfloat));
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
-       baseInternalFormat == GL_COLOR_INDEX &&
-       srcFormat == GL_COLOR_INDEX &&
-       srcType == CHAN_TYPE) {
+       baseInternalFormat == GL_DEPTH_COMPONENT &&
+       srcFormat == GL_DEPTH_COMPONENT &&
+       srcType == GL_FLOAT) {
       /* simple memcpy path */
       memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
                      dstRowStride, dstImageStride,
@@ -702,9 +702,8 @@ _mesa_texstore_color_index(STORE_PARAMS)
          for (row = 0; row < srcHeight; row++) {
             const GLvoid *src = _mesa_image_address(srcPacking,
                 srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
-            _mesa_unpack_index_span(ctx, srcWidth, CHAN_TYPE, dstRow,
-                                    srcType, src, srcPacking,
-                                    ctx->_ImageTransferState);
+            _mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) dstRow,
+                                    srcType, src, srcPacking);
             dstRow += dstRowStride;
          }
          dstImage += dstImageStride;
@@ -715,19 +714,19 @@ _mesa_texstore_color_index(STORE_PARAMS)
 
 
 /**
- * Store a floating point depth component texture image.
+ * Store a 16-bit integer depth component texture image.
  */
 GLboolean
-_mesa_texstore_depth_component_float32(STORE_PARAMS)
+_mesa_texstore_depth_component16(STORE_PARAMS)
 {
-   ASSERT(dstFormat == &_mesa_texformat_depth_component_float32);
-   ASSERT(dstFormat->TexelBytes == sizeof(GLfloat));
+   ASSERT(dstFormat == &_mesa_texformat_depth_component16);
+   ASSERT(dstFormat->TexelBytes == sizeof(GLushort));
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
        baseInternalFormat == GL_DEPTH_COMPONENT &&
        srcFormat == GL_DEPTH_COMPONENT &&
-       srcType == GL_FLOAT) {
+       srcType == GL_UNSIGNED_SHORT) {
       /* simple memcpy path */
       memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
                      dstRowStride, dstImageStride,
@@ -740,14 +739,19 @@ _mesa_texstore_depth_component_float32(STORE_PARAMS)
                         + dstZoffset * dstImageStride
                         + dstYoffset * dstRowStride
                         + dstXoffset * dstFormat->TexelBytes;
-      GLint img, row;
+      GLint img, row, col;
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = dstImage;
          for (row = 0; row < srcHeight; row++) {
+            GLfloat depthTemp[MAX_WIDTH];
             const GLvoid *src = _mesa_image_address(srcPacking,
                 srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
-            _mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) dstRow,
+            GLushort *dst16 = (GLushort *) dstRow;
+            _mesa_unpack_depth_span(ctx, srcWidth, depthTemp,
                                     srcType, src, srcPacking);
+            for (col = 0; col < srcWidth; col++) {
+               dst16[col] = (GLushort) (depthTemp[col] * 65535.0F);
+            }
             dstRow += dstRowStride;
          }
          dstImage += dstImageStride;
@@ -758,69 +762,104 @@ _mesa_texstore_depth_component_float32(STORE_PARAMS)
 
 
 /**
- * Store a 16-bit integer depth component texture image.
+ * Store an rgb565 texture image.
  */
 GLboolean
-_mesa_texstore_depth_component16(STORE_PARAMS)
+_mesa_texstore_rgb565(STORE_PARAMS)
 {
-   ASSERT(dstFormat == &_mesa_texformat_depth_component16);
-   ASSERT(dstFormat->TexelBytes == sizeof(GLushort));
+   ASSERT(dstFormat == &_mesa_texformat_rgb565);
+   ASSERT(dstFormat->TexelBytes == 2);
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
-       baseInternalFormat == GL_DEPTH_COMPONENT &&
-       srcFormat == GL_DEPTH_COMPONENT &&
-       srcType == GL_UNSIGNED_SHORT) {
+       baseInternalFormat == GL_RGB &&
+       srcFormat == GL_RGB &&
+       srcType == GL_UNSIGNED_SHORT_5_6_5) {
       /* simple memcpy path */
       memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
                      dstRowStride, dstImageStride,
                      srcWidth, srcHeight, srcDepth, srcFormat, srcType,
                      srcAddr, srcPacking);
    }
+   else if (!ctx->_ImageTransferState &&
+            !srcPacking->SwapBytes &&
+            baseInternalFormat == GL_RGB &&
+            srcFormat == GL_RGB &&
+            srcType == GL_UNSIGNED_BYTE &&
+            dims == 2) {
+      /* do optimized tex store */
+      const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth,
+                                                        srcFormat, srcType);
+      const GLubyte *src = (const GLubyte *)
+         _mesa_image_address(srcPacking, srcAddr, srcWidth, srcHeight,
+                             srcFormat, srcType, 0, 0, 0);
+      GLubyte *dst = (GLubyte *) dstAddr
+                   + dstZoffset * dstImageStride
+                   + dstYoffset * dstRowStride
+                   + dstXoffset * dstFormat->TexelBytes;
+      GLint row, col;
+      for (row = 0; row < srcHeight; row++) {
+         const GLubyte *srcUB = (const GLubyte *) src;
+         GLushort *dstUS = (GLushort *) dst;
+         for (col = 0; col < srcWidth; col++) {
+            dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] );
+            srcUB += 3;
+         }
+         dst += dstRowStride;
+         src += srcRowStride;
+      }
+   }
    else {
       /* general path */
+      const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+                                                 baseInternalFormat,
+                                                 dstFormat->BaseFormat,
+                                                 srcWidth, srcHeight, srcDepth,
+                                                 srcFormat, srcType, srcAddr,
+                                                 srcPacking);
+      const GLchan *src = tempImage;
       GLubyte *dstImage = (GLubyte *) dstAddr
                         + dstZoffset * dstImageStride
                         + dstYoffset * dstRowStride
                         + dstXoffset * dstFormat->TexelBytes;
       GLint img, row, col;
+      if (!tempImage)
+         return GL_FALSE;
+      _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = dstImage;
          for (row = 0; row < srcHeight; row++) {
-            GLfloat depthTemp[MAX_WIDTH];
-            const GLvoid *src = _mesa_image_address(srcPacking,
-                srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
-            GLushort *dst16 = (GLushort *) dstRow;
-            _mesa_unpack_depth_span(ctx, srcWidth, depthTemp,
-                                    srcType, src, srcPacking);
+            GLushort *dstUS = (GLushort *) dstRow;
             for (col = 0; col < srcWidth; col++) {
-               dst16[col] = (GLushort) (depthTemp[col] * 65535.0F);
+               dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]),
+                                            CHAN_TO_UBYTE(src[GCOMP]),
+                                            CHAN_TO_UBYTE(src[BCOMP]) );
+               src += 3;
             }
             dstRow += dstRowStride;
          }
          dstImage += dstImageStride;
       }
+      _mesa_free((void *) tempImage);
    }
    return GL_TRUE;
 }
 
 
-
-
 /**
- * Store an rgb565 texture image.
+ * Store an bgr565 texture image.
  */
 GLboolean
-_mesa_texstore_rgb565(STORE_PARAMS)
+_mesa_texstore_bgr565(STORE_PARAMS)
 {
-   ASSERT(dstFormat == &_mesa_texformat_rgb565);
+   ASSERT(dstFormat == &_mesa_texformat_bgr565);
    ASSERT(dstFormat->TexelBytes == 2);
 
    if (!ctx->_ImageTransferState &&
        !srcPacking->SwapBytes &&
        baseInternalFormat == GL_RGB &&
        srcFormat == GL_RGB &&
-       srcType == GL_UNSIGNED_SHORT_5_6_5) {
+       srcType == GL_UNSIGNED_SHORT_5_6_5_REV) {
       /* simple memcpy path */
       memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
                      dstRowStride, dstImageStride,
@@ -830,7 +869,7 @@ _mesa_texstore_rgb565(STORE_PARAMS)
    else if (!ctx->_ImageTransferState &&
             !srcPacking->SwapBytes &&
             baseInternalFormat == GL_RGB &&
-            srcFormat == GL_RGB &&
+            srcFormat == GL_BGR &&
             srcType == GL_UNSIGNED_BYTE &&
             dims == 2) {
       /* do optimized tex store */
@@ -848,7 +887,7 @@ _mesa_texstore_rgb565(STORE_PARAMS)
          const GLubyte *srcUB = (const GLubyte *) src;
          GLushort *dstUS = (GLushort *) dst;
          for (col = 0; col < srcWidth; col++) {
-            dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] );
+            dstUS[col] = PACK_COLOR_565( srcUB[2], srcUB[1], srcUB[0] );
             srcUB += 3;
          }
          dst += dstRowStride;
@@ -877,9 +916,9 @@ _mesa_texstore_rgb565(STORE_PARAMS)
          for (row = 0; row < srcHeight; row++) {
             GLushort *dstUS = (GLushort *) dstRow;
             for (col = 0; col < srcWidth; col++) {
-               dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]),
+               dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[BCOMP]),
                                             CHAN_TO_UBYTE(src[GCOMP]),
-                                            CHAN_TO_UBYTE(src[BCOMP]) );
+                                            CHAN_TO_UBYTE(src[RCOMP]) );
                src += 3;
             }
             dstRow += dstRowStride;
@@ -952,6 +991,65 @@ _mesa_texstore_rgba8888(STORE_PARAMS)
 
 
 GLboolean
+_mesa_texstore_abgr8888(STORE_PARAMS)
+{
+   const GLuint ui = 1;
+   const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+   ASSERT(dstFormat == &_mesa_texformat_abgr8888);
+   ASSERT(dstFormat->TexelBytes == 4);
+
+   if (!ctx->_ImageTransferState &&
+       !srcPacking->SwapBytes &&
+       baseInternalFormat == GL_RGBA &&
+       srcFormat == GL_ABGR_EXT &&
+       ((srcType == GL_UNSIGNED_INT_8_8_8_8_REV && littleEndian) ||
+        (srcType == GL_UNSIGNED_INT_8_8_8_8 && !littleEndian))) {
+      /* simple memcpy path */
+      memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+                     dstRowStride, dstImageStride,
+                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+                     srcAddr, srcPacking);
+   }
+   else {
+      /* general path */
+      const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+                                                 baseInternalFormat,
+                                                 dstFormat->BaseFormat,
+                                                 srcWidth, srcHeight, srcDepth,
+                                                 srcFormat, srcType, srcAddr,
+                                                 srcPacking);
+      const GLchan *src = tempImage;
+      GLubyte *dstImage = (GLubyte *) dstAddr
+                        + dstZoffset * dstImageStride
+                        + dstYoffset * dstRowStride
+                        + dstXoffset * dstFormat->TexelBytes;
+      GLint img, row, col;
+      if (!tempImage)
+         return GL_FALSE;
+      _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+      for (img = 0; img < srcDepth; img++) {
+         GLubyte *dstRow = dstImage;
+         for (row = 0; row < srcHeight; row++) {
+            GLuint *dstUI = (GLuint *) dstRow;
+            for (col = 0; col < srcWidth; col++) {
+               dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[ACOMP]),
+                                             CHAN_TO_UBYTE(src[BCOMP]),
+                                             CHAN_TO_UBYTE(src[GCOMP]),
+                                             CHAN_TO_UBYTE(src[RCOMP]) );
+               src += 4;
+            }
+            dstRow += dstRowStride;
+         }
+         dstImage += dstImageStride;
+      }
+      _mesa_free((void *) tempImage);
+   }
+   return GL_TRUE;
+}
+
+
+GLboolean
 _mesa_texstore_argb8888(STORE_PARAMS)
 {
    const GLuint ui = 1;
@@ -1011,6 +1109,65 @@ _mesa_texstore_argb8888(STORE_PARAMS)
 }
 
 
+GLboolean
+_mesa_texstore_bgra8888(STORE_PARAMS)
+{
+   const GLuint ui = 1;
+   const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+   ASSERT(dstFormat == &_mesa_texformat_bgra8888);
+   ASSERT(dstFormat->TexelBytes == 4);
+
+   if (!ctx->_ImageTransferState &&
+       !srcPacking->SwapBytes &&
+       baseInternalFormat == GL_RGBA &&
+       srcFormat == GL_BGRA &&
+       ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
+        (srcType == GL_UNSIGNED_INT_8_8_8_8_REV && !littleEndian) ||
+        (srcType == GL_UNSIGNED_INT_8_8_8_8 && littleEndian))) {
+      /* simple memcpy path */
+      memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+                     dstRowStride, dstImageStride,
+                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+                     srcAddr, srcPacking);
+   }
+   else {
+      /* general path */
+      const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+                                                 baseInternalFormat,
+                                                 dstFormat->BaseFormat,
+                                                 srcWidth, srcHeight, srcDepth,
+                                                 srcFormat, srcType, srcAddr,
+                                                 srcPacking);
+      const GLchan *src = tempImage;
+      GLubyte *dstImage = (GLubyte *) dstAddr
+                        + dstZoffset * dstImageStride
+                        + dstYoffset * dstRowStride
+                        + dstXoffset * dstFormat->TexelBytes;
+      GLint img, row, col;
+      if (!tempImage)
+         return GL_FALSE;
+      _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+      for (img = 0; img < srcDepth; img++) {
+         GLubyte *dstRow = dstImage;
+         for (row = 0; row < srcHeight; row++) {
+            GLuint *dstUI = (GLuint *) dstRow;
+            for (col = 0; col < srcWidth; col++) {
+               dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[BCOMP]),
+                                             CHAN_TO_UBYTE(src[GCOMP]),
+                                             CHAN_TO_UBYTE(src[RCOMP]),
+                                             CHAN_TO_UBYTE(src[ACOMP]) );
+               src += 4;
+            }
+            dstRow += dstRowStride;
+         }
+         dstImage += dstImageStride;
+      }
+      _mesa_free((void *) tempImage);
+   }
+   return GL_TRUE;
+}
+
 
 GLboolean
 _mesa_texstore_rgb888(STORE_PARAMS)
@@ -1037,7 +1194,7 @@ _mesa_texstore_rgb888(STORE_PARAMS)
             !srcPacking->SwapBytes &&
             srcFormat == GL_RGBA &&
             srcType == GL_UNSIGNED_BYTE) {
-      /* extract BGR from RGBA */
+      /* extract RGB from RGBA */
       int img, row, col;
       GLubyte *dstImage = (GLubyte *) dstAddr
                         + dstZoffset * dstImageStride
@@ -1117,6 +1274,91 @@ _mesa_texstore_rgb888(STORE_PARAMS)
 
 
 GLboolean
+_mesa_texstore_bgr888(STORE_PARAMS)
+{
+   const GLuint ui = 1;
+   const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+   ASSERT(dstFormat == &_mesa_texformat_bgr888);
+   ASSERT(dstFormat->TexelBytes == 3);
+
+   if (!ctx->_ImageTransferState &&
+       !srcPacking->SwapBytes &&
+       baseInternalFormat == GL_RGB &&
+       srcFormat == GL_RGB &&
+       srcType == GL_UNSIGNED_BYTE &&
+       littleEndian) {
+      /* simple memcpy path */
+      memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+                     dstRowStride, dstImageStride,
+                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+                     srcAddr, srcPacking);
+   }
+   else if (!ctx->_ImageTransferState &&
+            !srcPacking->SwapBytes &&
+            srcFormat == GL_RGBA &&
+            srcType == GL_UNSIGNED_BYTE) {
+      /* extract BGR from RGBA */
+      int img, row, col;
+      GLubyte *dstImage = (GLubyte *) dstAddr
+                        + dstZoffset * dstImageStride
+                        + dstYoffset * dstRowStride
+                        + dstXoffset * dstFormat->TexelBytes;
+      for (img = 0; img < srcDepth; img++) {
+         const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
+                                                 srcWidth, srcFormat, srcType);
+         GLubyte *srcRow = (GLubyte *) _mesa_image_address(srcPacking, srcAddr,
+                           srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
+         GLubyte *dstRow = dstImage;
+         for (row = 0; row < srcHeight; row++) {
+            for (col = 0; col < srcWidth; col++) {
+               dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP];
+               dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP];
+               dstRow[col * 3 + 2] = srcRow[col * 4 + BCOMP];
+            }
+            dstRow += dstRowStride;
+            srcRow += srcRowStride;
+         }
+         dstImage += dstImageStride;
+      }
+   }
+   else {
+      /* general path */
+      const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+                                                 baseInternalFormat,
+                                                 dstFormat->BaseFormat,
+                                                 srcWidth, srcHeight, srcDepth,
+                                                 srcFormat, srcType, srcAddr,
+                                                 srcPacking);
+      const GLchan *src = (const GLubyte *) tempImage;
+      GLubyte *dstImage = (GLubyte *) dstAddr
+                        + dstZoffset * dstImageStride
+                        + dstYoffset * dstRowStride
+                        + dstXoffset * dstFormat->TexelBytes;
+      GLint img, row, col;
+      if (!tempImage)
+         return GL_FALSE;
+      _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+      for (img = 0; img < srcDepth; img++) {
+         GLubyte *dstRow = dstImage;
+         for (row = 0; row < srcHeight; row++) {
+            for (col = 0; col < srcWidth; col++) {
+               dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]);
+               dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]);
+               dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]);
+               src += 3;
+            }
+            dstRow += dstRowStride;
+         }
+         dstImage += dstImageStride;
+      }
+      _mesa_free((void *) tempImage);
+   }
+   return GL_TRUE;
+}
+
+
+GLboolean
 _mesa_texstore_argb4444(STORE_PARAMS)
 {
    const GLuint ui = 1;
@@ -1176,6 +1418,65 @@ _mesa_texstore_argb4444(STORE_PARAMS)
 
 
 GLboolean
+_mesa_texstore_bgra4444(STORE_PARAMS)
+{
+   const GLuint ui = 1;
+   const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+   ASSERT(dstFormat == &_mesa_texformat_bgra4444);
+   ASSERT(dstFormat->TexelBytes == 2);
+
+   if (!ctx->_ImageTransferState &&
+       !srcPacking->SwapBytes &&
+       baseInternalFormat == GL_RGBA &&
+       srcFormat == GL_BGRA &&
+       ((srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV && !littleEndian) ||
+        (srcType == GL_UNSIGNED_SHORT_4_4_4_4 && littleEndian))) {
+      /* simple memcpy path */
+      memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+                     dstRowStride, dstImageStride,
+                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+                     srcAddr, srcPacking);
+   }
+   else {
+      /* general path */
+      const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+                                                 baseInternalFormat,
+                                                 dstFormat->BaseFormat,
+                                                 srcWidth, srcHeight, srcDepth,
+                                                 srcFormat, srcType, srcAddr,
+                                                 srcPacking);
+      const GLchan *src = tempImage;
+      GLubyte *dstImage = (GLubyte *) dstAddr
+                        + dstZoffset * dstImageStride
+                        + dstYoffset * dstRowStride
+                        + dstXoffset * dstFormat->TexelBytes;
+      GLint img, row, col;
+      if (!tempImage)
+         return GL_FALSE;
+      _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+      for (img = 0; img < srcDepth; img++) {
+         GLubyte *dstRow = dstImage;
+         for (row = 0; row < srcHeight; row++) {
+            GLushort *dstUS = (GLushort *) dstRow;
+            for (col = 0; col < srcWidth; col++) {
+               dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[BCOMP]),
+                                             CHAN_TO_UBYTE(src[GCOMP]),
+                                             CHAN_TO_UBYTE(src[RCOMP]),
+                                             CHAN_TO_UBYTE(src[ACOMP]) );
+               src += 4;
+            }
+            dstRow += dstRowStride;
+         }
+         dstImage += dstImageStride;
+      }
+      _mesa_free((void *) tempImage);
+   }
+   return GL_TRUE;
+}
+
+
+GLboolean
 _mesa_texstore_argb1555(STORE_PARAMS)
 {
    const GLuint ui = 1;
@@ -1233,6 +1534,64 @@ _mesa_texstore_argb1555(STORE_PARAMS)
    return GL_TRUE;
 }
 
+GLboolean
+_mesa_texstore_bgra5551(STORE_PARAMS)
+{
+   const GLuint ui = 1;
+   const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+   ASSERT(dstFormat == &_mesa_texformat_bgra5551);
+   ASSERT(dstFormat->TexelBytes == 2);
+
+   if (!ctx->_ImageTransferState &&
+       !srcPacking->SwapBytes &&
+       baseInternalFormat == GL_RGBA &&
+       srcFormat == GL_BGRA &&
+       ((srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV && !littleEndian) ||
+        (srcType == GL_UNSIGNED_SHORT_5_5_5_1 && littleEndian))) {
+      /* simple memcpy path */
+      memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+                     dstRowStride, dstImageStride,
+                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+                     srcAddr, srcPacking);
+   }
+   else {
+      /* general path */
+      const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+                                                 baseInternalFormat,
+                                                 dstFormat->BaseFormat,
+                                                 srcWidth, srcHeight, srcDepth,
+                                                 srcFormat, srcType, srcAddr,
+                                                 srcPacking);
+      const GLchan *src =tempImage;
+      GLubyte *dstImage = (GLubyte *) dstAddr
+                        + dstZoffset * dstImageStride
+                        + dstYoffset * dstRowStride
+                        + dstXoffset * dstFormat->TexelBytes;
+      GLint img, row, col;
+      if (!tempImage)
+         return GL_FALSE;
+      _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+      for (img = 0; img < srcDepth; img++) {
+         GLubyte *dstRow = dstImage;
+         for (row = 0; row < srcHeight; row++) {
+            GLushort *dstUS = (GLushort *) dstRow;
+            for (col = 0; col < srcWidth; col++) {
+               dstUS[col] = PACK_COLOR_5551( CHAN_TO_UBYTE(src[RCOMP]),
+                                             CHAN_TO_UBYTE(src[GCOMP]),
+                                             CHAN_TO_UBYTE(src[BCOMP]),
+                                             CHAN_TO_UBYTE(src[ACOMP]) );
+               src += 4;
+            }
+            dstRow += dstRowStride;
+         }
+         dstImage += dstImageStride;
+      }
+      _mesa_free((void *) tempImage);
+   }
+   return GL_TRUE;
+}
+
 
 GLboolean
 _mesa_texstore_al88(STORE_PARAMS)
@@ -1292,6 +1651,63 @@ _mesa_texstore_al88(STORE_PARAMS)
 
 
 GLboolean
+_mesa_texstore_la88(STORE_PARAMS)
+{
+   const GLuint ui = 1;
+   const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+   ASSERT(dstFormat == &_mesa_texformat_la88);
+   ASSERT(dstFormat->TexelBytes == 2);
+
+   if (!ctx->_ImageTransferState &&
+       !srcPacking->SwapBytes &&
+       baseInternalFormat == GL_LUMINANCE_ALPHA &&
+       srcFormat == GL_LUMINANCE_ALPHA &&
+       srcType == GL_UNSIGNED_BYTE &&
+       !littleEndian) {
+      /* simple memcpy path */
+      memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+                     dstRowStride, dstImageStride,
+                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+                     srcAddr, srcPacking);
+   }
+   else {
+      /* general path */
+      const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+                                                 baseInternalFormat,
+                                                 dstFormat->BaseFormat,
+                                                 srcWidth, srcHeight, srcDepth,
+                                                 srcFormat, srcType, srcAddr,
+                                                 srcPacking);
+      const GLchan *src = tempImage;
+      GLubyte *dstImage = (GLubyte *) dstAddr
+                        + dstZoffset * dstImageStride
+                        + dstYoffset * dstRowStride
+                        + dstXoffset * dstFormat->TexelBytes;
+      GLint img, row, col;
+      if (!tempImage)
+         return GL_FALSE;
+      _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+      for (img = 0; img < srcDepth; img++) {
+         GLubyte *dstRow = dstImage;
+         for (row = 0; row < srcHeight; row++) {
+            GLushort *dstUS = (GLushort *) dstRow;
+            for (col = 0; col < srcWidth; col++) {
+               dstUS[col] = PACK_COLOR_88( CHAN_TO_UBYTE(src[RCOMP]),
+                                           CHAN_TO_UBYTE(src[ACOMP]) );
+               src += 2;
+            }
+            dstRow += dstRowStride;
+         }
+         dstImage += dstImageStride;
+      }
+      _mesa_free((void *) tempImage);
+   }
+   return GL_TRUE;
+}
+
+
+GLboolean
 _mesa_texstore_rgb332(STORE_PARAMS)
 {
    ASSERT(dstFormat == &_mesa_texformat_rgb332);
@@ -1343,6 +1759,58 @@ _mesa_texstore_rgb332(STORE_PARAMS)
 }
 
 
+GLboolean
+_mesa_texstore_bgr233(STORE_PARAMS)
+{
+   ASSERT(dstFormat == &_mesa_texformat_bgr233);
+   ASSERT(dstFormat->TexelBytes == 1);
+
+   if (!ctx->_ImageTransferState &&
+       !srcPacking->SwapBytes &&
+       baseInternalFormat == GL_RGB &&
+       srcFormat == GL_BGR && srcType == GL_UNSIGNED_BYTE_3_3_2) {
+      /* simple memcpy path */
+      memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+                     dstRowStride, dstImageStride,
+                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+                     srcAddr, srcPacking);
+   }
+   else {
+      /* general path */
+      const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+                                                 baseInternalFormat,
+                                                 dstFormat->BaseFormat,
+                                                 srcWidth, srcHeight, srcDepth,
+                                                 srcFormat, srcType, srcAddr,
+                                                 srcPacking);
+      const GLchan *src = tempImage;
+      GLubyte *dstImage = (GLubyte *) dstAddr
+                        + dstZoffset * dstImageStride
+                        + dstYoffset * dstRowStride
+                        + dstXoffset * dstFormat->TexelBytes;
+      GLint img, row, col;
+      if (!tempImage)
+         return GL_FALSE;
+      _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+      for (img = 0; img < srcDepth; img++) {
+         GLubyte *dstRow = dstImage;
+         for (row = 0; row < srcHeight; row++) {
+            for (col = 0; col < srcWidth; col++) {
+               dstRow[col] = PACK_COLOR_233( CHAN_TO_UBYTE(src[BCOMP]),
+                                             CHAN_TO_UBYTE(src[GCOMP]),
+                                             CHAN_TO_UBYTE(src[RCOMP]) );
+               src += 3;
+            }
+            dstRow += dstRowStride;
+         }
+         dstImage += dstImageStride;
+      }
+      _mesa_free((void *) tempImage);
+   }
+   return GL_TRUE;
+}
+
+
 
 /**
  * Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8.
@@ -2300,7 +2768,6 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
    case MESA_FORMAT_ALPHA:
    case MESA_FORMAT_LUMINANCE:
    case MESA_FORMAT_INTENSITY:
-   case MESA_FORMAT_COLOR_INDEX:
       {
          GLuint i, j, k;
          const GLchan *rowA = (const GLchan *) srcRowA;
@@ -2353,7 +2820,9 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
       return;
    /* Begin hardware formats */
    case MESA_FORMAT_RGBA8888:
+   case MESA_FORMAT_ABGR8888:
    case MESA_FORMAT_ARGB8888:
+   case MESA_FORMAT_BGRA8888:
       {
          GLuint i, j, k;
          const GLubyte (*rowA)[4] = (const GLubyte (*)[4]) srcRowA;
@@ -2373,6 +2842,7 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
       }
       return;
    case MESA_FORMAT_RGB888:
+   case MESA_FORMAT_BGR888:
       {
          GLuint i, j, k;
          const GLubyte (*rowA)[3] = (const GLubyte (*)[3]) srcRowA;
@@ -2390,6 +2860,7 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
       }
       return;
    case MESA_FORMAT_RGB565:
+   case MESA_FORMAT_BGR565:
       {
          GLuint i, j, k;
          const GLushort *rowA = (const GLushort *) srcRowA;
@@ -2417,6 +2888,7 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
       }
       return;
    case MESA_FORMAT_ARGB4444:
+   case MESA_FORMAT_BGRA4444:
       {
          GLuint i, j, k;
          const GLushort *rowA = (const GLushort *) srcRowA;
index 4edad03..22f0c7e 100644 (file)
@@ -57,14 +57,22 @@ extern GLboolean _mesa_texstore_rgba(STORE_PARAMS);
 extern GLboolean _mesa_texstore_color_index(STORE_PARAMS);
 extern GLboolean _mesa_texstore_depth_component16(STORE_PARAMS);
 extern GLboolean _mesa_texstore_depth_component_float32(STORE_PARAMS);
-extern GLboolean _mesa_texstore_rgb565(STORE_PARAMS);
 extern GLboolean _mesa_texstore_rgba8888(STORE_PARAMS);
+extern GLboolean _mesa_texstore_abgr8888(STORE_PARAMS);
 extern GLboolean _mesa_texstore_argb8888(STORE_PARAMS);
+extern GLboolean _mesa_texstore_bgra8888(STORE_PARAMS);
 extern GLboolean _mesa_texstore_rgb888(STORE_PARAMS);
+extern GLboolean _mesa_texstore_bgr888(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgb565(STORE_PARAMS);
+extern GLboolean _mesa_texstore_bgr565(STORE_PARAMS);
 extern GLboolean _mesa_texstore_argb4444(STORE_PARAMS);
+extern GLboolean _mesa_texstore_bgra4444(STORE_PARAMS);
 extern GLboolean _mesa_texstore_argb1555(STORE_PARAMS);
+extern GLboolean _mesa_texstore_bgra5551(STORE_PARAMS);
 extern GLboolean _mesa_texstore_al88(STORE_PARAMS);
+extern GLboolean _mesa_texstore_la88(STORE_PARAMS);
 extern GLboolean _mesa_texstore_rgb332(STORE_PARAMS);
+extern GLboolean _mesa_texstore_bgr233(STORE_PARAMS);
 extern GLboolean _mesa_texstore_a8(STORE_PARAMS);
 extern GLboolean _mesa_texstore_ci8(STORE_PARAMS);
 extern GLboolean _mesa_texstore_ycbcr(STORE_PARAMS);
index 6a4b7f7..b2ccb81 100644 (file)
@@ -347,57 +347,6 @@ repeat_remainder(GLint a, GLint b)
 
 
 /*
- * Get texture palette entry.
- */
-static void
-palette_sample(const GLcontext *ctx,
-               const struct gl_texture_object *tObj,
-               GLint index, GLchan rgba[4] )
-{
-   const GLchan *palette;
-   GLenum format;
-
-   if (ctx->Texture.SharedPalette) {
-      ASSERT(ctx->Texture.Palette.Type != GL_FLOAT);
-      palette = (const GLchan *) ctx->Texture.Palette.Table;
-      format = ctx->Texture.Palette.Format;
-   }
-   else {
-      ASSERT(tObj->Palette.Type != GL_FLOAT);
-      palette = (const GLchan *) tObj->Palette.Table;
-      format = tObj->Palette.Format;
-   }
-
-   switch (format) {
-      case GL_ALPHA:
-         rgba[ACOMP] = palette[index];
-         return;
-      case GL_LUMINANCE:
-      case GL_INTENSITY:
-         rgba[RCOMP] = palette[index];
-         return;
-      case GL_LUMINANCE_ALPHA:
-         rgba[RCOMP] = palette[(index << 1) + 0];
-         rgba[ACOMP] = palette[(index << 1) + 1];
-         return;
-      case GL_RGB:
-         rgba[RCOMP] = palette[index * 3 + 0];
-         rgba[GCOMP] = palette[index * 3 + 1];
-         rgba[BCOMP] = palette[index * 3 + 2];
-         return;
-      case GL_RGBA:
-         rgba[RCOMP] = palette[(index << 2) + 0];
-         rgba[GCOMP] = palette[(index << 2) + 1];
-         rgba[BCOMP] = palette[(index << 2) + 2];
-         rgba[ACOMP] = palette[(index << 2) + 3];
-         return;
-      default:
-         _mesa_problem(ctx, "Bad palette format in palette_sample");
-   }
-}
-
-
-/*
  * The lambda[] array values are always monotonic.  Either the whole span
  * will be minified, magnified, or split between the two.  This function
  * determines the subranges in [0, n-1] that are to be minified or magnified.
@@ -519,9 +468,6 @@ sample_1d_nearest(GLcontext *ctx,
    }
    else {
       img->FetchTexelc(img, i, 0, 0, rgba);
-      if (img->Format == GL_COLOR_INDEX) {
-         palette_sample(ctx, tObj, rgba[0], rgba);
-      }
    }
 }
 
@@ -571,18 +517,12 @@ sample_1d_linear(GLcontext *ctx,
       }
       else {
          img->FetchTexelc(img, i0, 0, 0, t0);
-         if (img->Format == GL_COLOR_INDEX) {
-            palette_sample(ctx, tObj, t0[0], t0);
-         }
       }
       if (useBorderColor & I1BIT) {
          COPY_CHAN4(t1, tObj->_BorderChan);
       }
       else {
          img->FetchTexelc(img, i1, 0, 0, t1);
-         if (img->Format == GL_COLOR_INDEX) {
-            palette_sample(ctx, tObj, t1[0], t1);
-         }
       }
 
 #if CHAN_TYPE == GL_FLOAT
@@ -848,9 +788,6 @@ sample_2d_nearest(GLcontext *ctx,
    }
    else {
       img->FetchTexelc(img, i, j, 0, rgba);
-      if (img->Format == GL_COLOR_INDEX) {
-         palette_sample(ctx, tObj, rgba[0], rgba);
-      }
    }
 }
 
@@ -916,36 +853,24 @@ sample_2d_linear(GLcontext *ctx,
       }
       else {
          img->FetchTexelc(img, i0, j0, 0, t00);
-         if (img->Format == GL_COLOR_INDEX) {
-            palette_sample(ctx, tObj, t00[0], t00);
-         }
       }
       if (useBorderColor & (I1BIT | J0BIT)) {
          COPY_CHAN4(t10, tObj->_BorderChan);
       }
       else {
          img->FetchTexelc(img, i1, j0, 0, t10);
-         if (img->Format == GL_COLOR_INDEX) {
-            palette_sample(ctx, tObj, t10[0], t10);
-         }
       }
       if (useBorderColor & (I0BIT | J1BIT)) {
          COPY_CHAN4(t01, tObj->_BorderChan);
       }
       else {
          img->FetchTexelc(img, i0, j1, 0, t01);
-         if (img->Format == GL_COLOR_INDEX) {
-            palette_sample(ctx, tObj, t01[0], t01);
-         }
       }
       if (useBorderColor & (I1BIT | J1BIT)) {
          COPY_CHAN4(t11, tObj->_BorderChan);
       }
       else {
          img->FetchTexelc(img, i1, j1, 0, t11);
-         if (img->Format == GL_COLOR_INDEX) {
-            palette_sample(ctx, tObj, t11[0], t11);
-         }
       }
 #if CHAN_TYPE == GL_FLOAT
       rgba[0] = w00 * t00[0] + w10 * t10[0] + w01 * t01[0] + w11 * t11[0];
@@ -1454,9 +1379,6 @@ sample_3d_nearest(GLcontext *ctx,
    }
    else {
       img->FetchTexelc(img, i, j, k, rgba);
-      if (img->Format == GL_COLOR_INDEX) {
-         palette_sample(ctx, tObj, rgba[0], rgba);
-      }
    }
 }
 
@@ -1537,36 +1459,24 @@ sample_3d_linear(GLcontext *ctx,
       }
       else {
          img->FetchTexelc(img, i0, j0, k0, t000);
-         if (img->Format == GL_COLOR_INDEX) {
-            palette_sample(ctx, tObj, t000[0], t000);
-         }
       }
       if (useBorderColor & (I1BIT | J0BIT | K0BIT)) {
          COPY_CHAN4(t100, tObj->_BorderChan);
       }
       else {
          img->FetchTexelc(img, i1, j0, k0, t100);
-         if (img->Format == GL_COLOR_INDEX) {
-            palette_sample(ctx, tObj, t100[0], t100);
-         }
       }
       if (useBorderColor & (I0BIT | J1BIT | K0BIT)) {
          COPY_CHAN4(t010, tObj->_BorderChan);
       }
       else {
          img->FetchTexelc(img, i0, j1, k0, t010);
-         if (img->Format == GL_COLOR_INDEX) {
-            palette_sample(ctx, tObj, t010[0], t010);
-         }
       }
       if (useBorderColor & (I1BIT | J1BIT | K0BIT)) {
          COPY_CHAN4(t110, tObj->_BorderChan);
       }
       else {
          img->FetchTexelc(img, i1, j1, k0, t110);
-         if (img->Format == GL_COLOR_INDEX) {
-            palette_sample(ctx, tObj, t110[0], t110);
-         }
       }
 
       if (useBorderColor & (I0BIT | J0BIT | K1BIT)) {
@@ -1574,36 +1484,24 @@ sample_3d_linear(GLcontext *ctx,
       }
       else {
          img->FetchTexelc(img, i0, j0, k1, t001);
-         if (img->Format == GL_COLOR_INDEX) {
-            palette_sample(ctx, tObj, t001[0], t001);
-         }
       }
       if (useBorderColor & (I1BIT | J0BIT | K1BIT)) {
          COPY_CHAN4(t101, tObj->_BorderChan);
       }
       else {
          img->FetchTexelc(img, i1, j0, k1, t101);
-         if (img->Format == GL_COLOR_INDEX) {
-            palette_sample(ctx, tObj, t101[0], t101);
-         }
       }
       if (useBorderColor & (I0BIT | J1BIT | K1BIT)) {
          COPY_CHAN4(t011, tObj->_BorderChan);
       }
       else {
          img->FetchTexelc(img, i0, j1, k1, t011);
-         if (img->Format == GL_COLOR_INDEX) {
-            palette_sample(ctx, tObj, t011[0], t011);
-         }
       }
       if (useBorderColor & (I1BIT | J1BIT | K1BIT)) {
          COPY_CHAN4(t111, tObj->_BorderChan);
       }
       else {
          img->FetchTexelc(img, i1, j1, k1, t111);
-         if (img->Format == GL_COLOR_INDEX) {
-            palette_sample(ctx, tObj, t111[0], t111);
-         }
       }
 
 #if CHAN_TYPE == GL_FLOAT
@@ -2171,9 +2069,6 @@ sample_nearest_rect(GLcontext *ctx, GLuint texUnit,
       GLint row, col;
       /* NOTE: we DO NOT use [0, 1] texture coordinates! */
       if (tObj->WrapS == GL_CLAMP) {
-         /* Note: we use width-1, not what the spec says, but it actually
-          * does work correctly.
-          */
          col = IFLOOR( CLAMP(texcoords[i][0], 0.0F, width - 1) );
       }
       else if (tObj->WrapS == GL_CLAMP_TO_EDGE) {