From cac5974bf9385f8c9bd46f9c90bfa8144f0c33d6 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 21 Sep 2006 10:20:15 +0000 Subject: Do a better job of choosing texture formats to avoid image conversions. --- src/mesa/drivers/dri/i965/brw_tex.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/brw_tex.c b/src/mesa/drivers/dri/i965/brw_tex.c index 47bd875bb06..8332d869e1d 100644 --- a/src/mesa/drivers/dri/i965/brw_tex.c +++ b/src/mesa/drivers/dri/i965/brw_tex.c @@ -49,12 +49,23 @@ 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; -- cgit v1.2.3