Merge commit 'origin/gallium-master-merge'
[mesa.git] / src / mesa / main / texformat.c
index db3525666a269e3e63a0f20390780e74c7656dd1..16d05cc7d0702e55697e15da1966ea5ce8d4b819 100644 (file)
@@ -896,6 +896,30 @@ const struct gl_texture_format _mesa_texformat_rgb565_rev = {
    store_texel_rgb565_rev              /* StoreTexel */
 };
 
+const struct gl_texture_format _mesa_texformat_rgba4444 = {
+   MESA_FORMAT_RGBA4444,               /* MesaFormat */
+   GL_RGBA,                            /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   4,                                  /* RedBits */
+   4,                                  /* GreenBits */
+   4,                                  /* BlueBits */
+   4,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
+   2,                                  /* TexelBytes */
+   _mesa_texstore_rgba4444,            /* StoreTexImageFunc */
+   fetch_texel_1d_rgba4444,            /* FetchTexel1D */
+   fetch_texel_2d_rgba4444,            /* FetchTexel2D */
+   fetch_texel_3d_rgba4444,            /* FetchTexel3D */
+   NULL,                               /* FetchTexel1Df */
+   NULL,                               /* FetchTexel2Df */
+   NULL,                               /* FetchTexel3Df */
+   store_texel_rgba4444                        /* StoreTexel */
+};
+
 const struct gl_texture_format _mesa_texformat_argb4444 = {
    MESA_FORMAT_ARGB4444,               /* MesaFormat */
    GL_RGBA,                            /* BaseFormat */
@@ -944,6 +968,30 @@ const struct gl_texture_format _mesa_texformat_argb4444_rev = {
    store_texel_argb4444_rev            /* StoreTexel */
 };
 
+const struct gl_texture_format _mesa_texformat_rgba5551 = {
+   MESA_FORMAT_RGBA5551,               /* MesaFormat */
+   GL_RGBA,                            /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   5,                                  /* RedBits */
+   5,                                  /* GreenBits */
+   5,                                  /* BlueBits */
+   1,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
+   2,                                  /* TexelBytes */
+   _mesa_texstore_rgba5551,            /* StoreTexImageFunc */
+   fetch_texel_1d_rgba5551,            /* FetchTexel1D */
+   fetch_texel_2d_rgba5551,            /* FetchTexel2D */
+   fetch_texel_3d_rgba5551,            /* FetchTexel3D */
+   NULL,                               /* FetchTexel1Df */
+   NULL,                               /* FetchTexel2Df */
+   NULL,                               /* FetchTexel3Df */
+   store_texel_rgba5551                        /* StoreTexel */
+};
+
 const struct gl_texture_format _mesa_texformat_argb1555 = {
    MESA_FORMAT_ARGB1555,               /* MesaFormat */
    GL_RGBA,                            /* BaseFormat */
@@ -1458,41 +1506,39 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       }
    }
 
-   if (ctx->Extensions.ARB_texture_compression) {
-      switch (internalFormat) {
-         case GL_COMPRESSED_ALPHA_ARB:
-            return &_mesa_texformat_alpha;
-         case GL_COMPRESSED_LUMINANCE_ARB:
-            return &_mesa_texformat_luminance;
-         case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
-            return &_mesa_texformat_luminance_alpha;
-         case GL_COMPRESSED_INTENSITY_ARB:
-            return &_mesa_texformat_intensity;
-         case GL_COMPRESSED_RGB_ARB:
+   switch (internalFormat) {
+      case GL_COMPRESSED_ALPHA_ARB:
+         return &_mesa_texformat_alpha;
+      case GL_COMPRESSED_LUMINANCE_ARB:
+         return &_mesa_texformat_luminance;
+      case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
+         return &_mesa_texformat_luminance_alpha;
+      case GL_COMPRESSED_INTENSITY_ARB:
+         return &_mesa_texformat_intensity;
+      case GL_COMPRESSED_RGB_ARB:
 #if FEATURE_texture_fxt1
-            if (ctx->Extensions.TDFX_texture_compression_FXT1)
-               return &_mesa_texformat_rgb_fxt1;
+         if (ctx->Extensions.TDFX_texture_compression_FXT1)
+            return &_mesa_texformat_rgb_fxt1;
 #endif
 #if FEATURE_texture_s3tc
-            if (ctx->Extensions.EXT_texture_compression_s3tc ||
-                ctx->Extensions.S3_s3tc)
-               return &_mesa_texformat_rgb_dxt1;
+         if (ctx->Extensions.EXT_texture_compression_s3tc ||
+             ctx->Extensions.S3_s3tc)
+            return &_mesa_texformat_rgb_dxt1;
 #endif
-            return &_mesa_texformat_rgb;
-         case GL_COMPRESSED_RGBA_ARB:
+         return &_mesa_texformat_rgb;
+      case GL_COMPRESSED_RGBA_ARB:
 #if FEATURE_texture_fxt1
-            if (ctx->Extensions.TDFX_texture_compression_FXT1)
-               return &_mesa_texformat_rgba_fxt1;
+         if (ctx->Extensions.TDFX_texture_compression_FXT1)
+            return &_mesa_texformat_rgba_fxt1;
 #endif
 #if FEATURE_texture_s3tc
-            if (ctx->Extensions.EXT_texture_compression_s3tc ||
-                ctx->Extensions.S3_s3tc)
-               return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */
+         if (ctx->Extensions.EXT_texture_compression_s3tc ||
+             ctx->Extensions.S3_s3tc)
+            return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */
 #endif
-            return &_mesa_texformat_rgba;
-         default:
-            ; /* fallthrough */
-      }
+         return &_mesa_texformat_rgba;
+      default:
+         ; /* fallthrough */
    }
 
    if (ctx->Extensions.MESA_ycbcr_texture) {
@@ -1685,7 +1731,7 @@ _mesa_format_to_type_and_comps(const struct gl_texture_format *format,
    case MESA_FORMAT_ARGB1555:
    case MESA_FORMAT_ARGB1555_REV:
       *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV;
-      *comps = 3;
+      *comps = 4;
       return;
 
    case MESA_FORMAT_AL88: