summaryrefslogtreecommitdiff
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2005-08-25 19:15:01 +0000
committerIan Romanick <idr@us.ibm.com>2005-08-25 19:15:01 +0000
commit8bc0b3f9611f9634d497fe2174246e866920f865 (patch)
tree78f720d0abaf3733d0dafa8e0bd1f0ee69d853f9 /src/mesa/drivers
parent8de9d92acf3e2ec76245c34d90fac65c7bb1994c (diff)
Fix texture format selection. ChooseTextureFormat is supposed to select the
hardware format of the texture, and SetTexImages is supposed to use the format selected by ChooseTextureFormat. However, both routines were making their choices based on the texture's BaseFormat. This is wrong. ChooseTextureFormat uses BaseFormat and SetTexImages uses TexFormat->MesaFormat. Once SetTexImages was fixed to use the right format values, ChooseTextureFormat was cleaned up. It now uses the few available texture formats supported by the i810 in a smarter way. This should improve the quality of LUMINANCE, LUMINANCE_ALPHA, and INTENSITY textures. I tested this by cycling through all the texture formats in demos/texenv and tests/yuvsquare.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/i810/i810tex.c42
-rw-r--r--src/mesa/drivers/dri/i810/i810texstate.c37
2 files changed, 35 insertions, 44 deletions
diff --git a/src/mesa/drivers/dri/i810/i810tex.c b/src/mesa/drivers/dri/i810/i810tex.c
index 0aba8e8aa5..a86d434db0 100644
--- a/src/mesa/drivers/dri/i810/i810tex.c
+++ b/src/mesa/drivers/dri/i810/i810tex.c
@@ -437,10 +437,8 @@ static void i810DeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
/**
* Choose a Mesa texture format to match the requested format.
*
- * \todo
- * Determine why \c _mesa_texformat_al88 doesn't work right for
- * \c GL_LUMINANCE_ALPHA textures. It seems to work fine for \c GL_INTENSITY,
- * but \c GL_LUMINANCE_ALPHA gets some red bands in progs/demos/texenv.
+ * The i810 only supports 5 texture modes that are useful to Mesa. That
+ * makes this routine pretty simple.
*/
static const struct gl_texture_format *
i810ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
@@ -449,11 +447,18 @@ i810ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
switch ( internalFormat ) {
case 4:
case GL_RGBA:
+ case GL_RGBA2:
+ case GL_RGBA4:
+ case GL_RGB5_A1:
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
case GL_COMPRESSED_RGBA:
- if ( format == GL_BGRA ) {
- if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
- return &_mesa_texformat_argb1555;
- }
+ if ( (format == GL_BGRA) && (type == GL_UNSIGNED_SHORT_1_5_5_5_REV)
+ || (format == GL_RGBA) && (type == GL_UNSIGNED_SHORT_5_5_5_1)
+ || (internalFormat == GL_RGB5_A1) ) {
+ return &_mesa_texformat_argb1555;
}
return &_mesa_texformat_argb4444;
@@ -467,18 +472,7 @@ i810ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return &_mesa_texformat_rgb565;
-
- case GL_RGBA2:
- case GL_RGBA4:
- case GL_RGBA8:
- case GL_RGB10_A2:
- case GL_RGBA12:
- case GL_RGBA16:
- return &_mesa_texformat_argb4444;
-
- case GL_RGB5_A1:
- return &_mesa_texformat_argb1555;
+ return &_mesa_texformat_rgb565;
case GL_ALPHA:
case GL_ALPHA4:
@@ -486,8 +480,6 @@ i810ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_ALPHA12:
case GL_ALPHA16:
case GL_COMPRESSED_ALPHA:
- return &_mesa_texformat_al88;
-
case 1:
case GL_LUMINANCE:
case GL_LUMINANCE4:
@@ -495,8 +487,6 @@ i810ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_LUMINANCE12:
case GL_LUMINANCE16:
case GL_COMPRESSED_LUMINANCE:
- return &_mesa_texformat_rgb565;
-
case 2:
case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE4_ALPHA4:
@@ -512,11 +502,7 @@ i810ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_INTENSITY12:
case GL_INTENSITY16:
case GL_COMPRESSED_INTENSITY:
-#if 0
return &_mesa_texformat_al88;
-#else
- return &_mesa_texformat_argb4444;
-#endif
case GL_YCBCR_MESA:
if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
diff --git a/src/mesa/drivers/dri/i810/i810texstate.c b/src/mesa/drivers/dri/i810/i810texstate.c
index e100c565cb..10a15f961f 100644
--- a/src/mesa/drivers/dri/i810/i810texstate.c
+++ b/src/mesa/drivers/dri/i810/i810texstate.c
@@ -25,6 +25,7 @@
#include "glheader.h"
#include "macros.h"
#include "mtypes.h"
+#include "texformat.h"
#include "simple_list.h"
#include "enums.h"
@@ -52,29 +53,33 @@ static void i810SetTexImages( i810ContextPtr imesa,
/* fprintf(stderr, "%s\n", __FUNCTION__); */
- switch (baseImage->Format) {
- case GL_RGB:
- case GL_LUMINANCE:
- t->texelBytes = 2;
- textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_RGB565;
+ t->texelBytes = 2;
+ switch (baseImage->TexFormat->MesaFormat) {
+ case MESA_FORMAT_ARGB1555:
+ textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_ARGB1555;
break;
- case GL_ALPHA:
- case GL_LUMINANCE_ALPHA:
- case GL_INTENSITY:
- case GL_RGBA:
- t->texelBytes = 2;
+ case MESA_FORMAT_ARGB4444:
textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_ARGB4444;
break;
- case GL_COLOR_INDEX:
- textureFormat = MI1_FMT_8CI | MI1_PF_8CI_ARGB4444;
- t->texelBytes = 1;
+ case MESA_FORMAT_RGB565:
+ textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_RGB565;
+ break;
+ case MESA_FORMAT_AL88:
+ textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_AY88;
break;
- case GL_YCBCR_MESA:
- t->texelBytes = 2;
+ case MESA_FORMAT_YCBCR:
textureFormat = MI1_FMT_422 | MI1_PF_422_YCRCB_SWAP_Y
| MI1_COLOR_CONV_ENABLE;
break;
-
+ case MESA_FORMAT_YCBCR_REV:
+ textureFormat = MI1_FMT_422 | MI1_PF_422_YCRCB
+ | MI1_COLOR_CONV_ENABLE;
+ break;
+ case MESA_FORMAT_CI8:
+ textureFormat = MI1_FMT_8CI | MI1_PF_8CI_ARGB4444;
+ t->texelBytes = 1;
+ break;
+
default:
fprintf(stderr, "i810SetTexImages: bad image->Format\n" );
return;