diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2005-01-25 15:27:21 +0000 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2005-01-25 15:27:21 +0000 |
commit | 2de70eebbc28b0e4f05bb5b6c8b708c33e9a39f1 (patch) | |
tree | a10b9bb7467f0a3a29f674bd425100191a4ef287 | |
parent | 7c7c0321b069f680baf64e159a773493b515327e (diff) |
make better choices for hardware texture formats
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_tex.c | 226 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_texstate.c | 3 |
2 files changed, 146 insertions, 83 deletions
diff --git a/src/mesa/drivers/dri/unichrome/via_tex.c b/src/mesa/drivers/dri/unichrome/via_tex.c index 3ed1a53088..a8d1a8494e 100644 --- a/src/mesa/drivers/dri/unichrome/via_tex.c +++ b/src/mesa/drivers/dri/unichrome/via_tex.c @@ -93,6 +93,8 @@ static void viaTexImage1D(GLcontext *ctx, GLenum target, GLint level, pixels, packing, texObj, texImage); if (VIA_DEBUG) fprintf(stderr, "viaTexImage1D - out\n"); } + + static void viaTexSubImage1D(GLcontext *ctx, GLenum target, GLint level, @@ -224,87 +226,139 @@ static GLboolean viaIsTextureResident(GLcontext *ctx, return t && t->bufAddr; } + + static const struct gl_texture_format * -viaChooseTexFormat(GLcontext *ctx, GLint internalFormat, - GLenum format, GLenum type) +viaChooseTexFormat( GLcontext *ctx, GLint internalFormat, + GLenum format, GLenum type ) { - viaContextPtr vmesa = VIA_CONTEXT(ctx); - (void)format; - (void)type; - if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); - if (VIA_DEBUG) fprintf(stderr, "internalFormat:%d format:%d\n", internalFormat, format); - switch (internalFormat) { - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - return &_mesa_texformat_l8; - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - return &_mesa_texformat_al88; - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - if (VIA_DEBUG) fprintf(stderr, "2 &_mesa_texformat_arg565\n"); - return &_mesa_texformat_rgb565; - case 3: - case GL_RGB: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - if (vmesa->viaScreen->bitsPerPixel == 0x20) { - if (VIA_DEBUG) fprintf(stderr,"3 argb8888\n"); + viaContextPtr vmesa = VIA_CONTEXT(ctx); + const GLboolean do32bpt = ( vmesa->viaScreen->bitsPerPixel == 32 +/* && vmesa->viaScreen->textureSize > 4*1024*1024 */ + ); + +/* fprintf(stderr, "do32bpt: %d bpp %d textureSize %d\n", do32bpt, */ +/* vmesa->viaScreen->bitsPerPixel, */ +/* vmesa->viaScreen->textureSize); */ + + switch ( internalFormat ) { + case 4: + case GL_RGBA: + case GL_COMPRESSED_RGBA: + if ( format == GL_BGRA ) { + if ( type == GL_UNSIGNED_INT_8_8_8_8_REV ) { return &_mesa_texformat_argb8888; - } - else { - if (VIA_DEBUG) fprintf(stderr,"3 rgb565\n"); - return &_mesa_texformat_rgb565; - } - case 4: - if (vmesa->viaScreen->bitsPerPixel == 0x20) { - if (VIA_DEBUG) fprintf(stderr, "4 &_mesa_texformat_argb8888\n"); - return &_mesa_texformat_argb8888; - } - else { - if (VIA_DEBUG) fprintf(stderr, "4 &_mesa_texformat_argb4444\n"); - return &_mesa_texformat_argb4444; - } - case GL_RGBA2: - case GL_RGBA4: - if (VIA_DEBUG) fprintf(stderr, "GL_RGBA4 &_mesa_texformat_argb4444\n"); - return &_mesa_texformat_argb4444; - - case GL_RGB5_A1: - if (VIA_DEBUG) fprintf(stderr, "GL_RGB5_A1 &_mesa_texformat_argb1555\n"); - return &_mesa_texformat_argb1555; - case GL_RGBA: - case GL_RGBA8: - case GL_RGBA12: - case GL_RGBA16: - case GL_RGB10_A2: - if (VIA_DEBUG) fprintf(stderr, "GL_RGBA &_mesa_texformat_argb8888\n"); - return &_mesa_texformat_argb8888; - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - return &_mesa_texformat_a8; - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - return &_mesa_texformat_i8; + } + else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) { + return &_mesa_texformat_argb4444; + } + else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) { + return &_mesa_texformat_argb1555; + } + } + return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444; + + case 3: + case GL_RGB: + case GL_COMPRESSED_RGB: + if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) { + return &_mesa_texformat_rgb565; + } + return do32bpt ? &_mesa_texformat_rgb888 : &_mesa_texformat_rgb565; + + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444; + + case GL_RGBA4: + case GL_RGBA2: + return &_mesa_texformat_argb4444; + + case GL_RGB5_A1: + return &_mesa_texformat_argb1555; + + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565; + + case GL_RGB5: + case GL_RGB4: + case GL_R3_G3_B2: + return &_mesa_texformat_rgb565; + + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + case GL_COMPRESSED_ALPHA: + return &_mesa_texformat_a8; + + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + case GL_COMPRESSED_LUMINANCE: + return &_mesa_texformat_l8; + + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + case GL_COMPRESSED_LUMINANCE_ALPHA: + return &_mesa_texformat_al88; + + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + case GL_COMPRESSED_INTENSITY: + return &_mesa_texformat_i8; + + case GL_YCBCR_MESA: + if (type == GL_UNSIGNED_SHORT_8_8_MESA || + type == GL_UNSIGNED_BYTE) + return &_mesa_texformat_ycbcr; + else + return &_mesa_texformat_ycbcr_rev; + + case GL_COMPRESSED_RGB_FXT1_3DFX: + return &_mesa_texformat_rgb_fxt1; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return &_mesa_texformat_rgba_fxt1; + + case GL_RGB_S3TC: + case GL_RGB4_S3TC: + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + return &_mesa_texformat_rgb_dxt1; + + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + return &_mesa_texformat_rgba_dxt1; + + case GL_RGBA_S3TC: + case GL_RGBA4_S3TC: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + return &_mesa_texformat_rgba_dxt3; + + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + return &_mesa_texformat_rgba_dxt5; + + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + return &_mesa_texformat_depth_component16; case GL_COLOR_INDEX: case GL_COLOR_INDEX1_EXT: case GL_COLOR_INDEX2_EXT: @@ -313,11 +367,17 @@ viaChooseTexFormat(GLcontext *ctx, GLint internalFormat, case GL_COLOR_INDEX12_EXT: case GL_COLOR_INDEX16_EXT: return &_mesa_texformat_ci8; - default: - _mesa_problem(ctx, "unexpected format in viaChooseTextureFormat"); - return NULL; - } -} + + default: + fprintf(stderr, "unexpected texture format %s in %s\n", + _mesa_lookup_enum_by_nr(internalFormat), + __FUNCTION__); + return NULL; + } + + return NULL; /* never get here */ +} + void viaInitTextureFuncs(struct dd_function_table * functions) { diff --git a/src/mesa/drivers/dri/unichrome/via_texstate.c b/src/mesa/drivers/dri/unichrome/via_texstate.c index 51a27ef118..94902bc2f0 100644 --- a/src/mesa/drivers/dri/unichrome/via_texstate.c +++ b/src/mesa/drivers/dri/unichrome/via_texstate.c @@ -192,6 +192,9 @@ static void viaSetTexImages(viaContextPtr vmesa, case MESA_FORMAT_ARGB1555: texFormat = HC_HTXnFM_ARGB1555; break; + case MESA_FORMAT_RGB888: + texFormat = HC_HTXnFM_ARGB0888; + break; case MESA_FORMAT_L8: texFormat = HC_HTXnFM_L8; break; |