Do a better job of choosing texture formats to avoid image conversions.
authorKeith Whitwell <keith@tungstengraphics.com>
Thu, 21 Sep 2006 10:20:15 +0000 (10:20 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Thu, 21 Sep 2006 10:20:15 +0000 (10:20 +0000)
src/mesa/drivers/dri/i965/brw_tex.c

index 47bd875..8332d86 100644 (file)
 
 static const struct gl_texture_format *
 brwChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
-                        GLenum format, GLenum type )
+                        GLenum srcFormat, GLenum srcType )
 {
    switch ( internalFormat ) {
    case 4:
    case GL_RGBA:
    case GL_COMPRESSED_RGBA:
+      if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV)
+        return &_mesa_texformat_argb4444;
+      else if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV)
+        return &_mesa_texformat_argb1555;
+      else if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
+              (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) ||
+              (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8)) 
+        return &_mesa_texformat_rgba8888_rev;
+      else
+        return &_mesa_texformat_argb8888;
+
    case GL_RGBA8:
    case GL_RGB10_A2:
    case GL_RGBA12:
@@ -73,8 +84,8 @@ brwChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case 3:
    case GL_COMPRESSED_RGB:
    case GL_RGB:
-      if (format == GL_RGB &&
-         type == GL_UNSIGNED_SHORT_5_6_5)
+      if (srcFormat == GL_RGB &&
+         srcType == GL_UNSIGNED_SHORT_5_6_5)
         return &_mesa_texformat_rgb565;
       else
         return &_mesa_texformat_argb8888;
@@ -127,8 +138,8 @@ brwChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
       return &_mesa_texformat_i8;
 
    case GL_YCBCR_MESA:
-      if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
-         type == GL_UNSIGNED_BYTE)
+      if (srcType == GL_UNSIGNED_SHORT_8_8_MESA ||
+         srcType == GL_UNSIGNED_BYTE)
          return &_mesa_texformat_ycbcr;
       else
          return &_mesa_texformat_ycbcr_rev;