summaryrefslogtreecommitdiff
path: root/xc/lib/GL/mesa
diff options
context:
space:
mode:
authorfxkuehl <fxkuehl>2003-10-25 14:40:54 +0000
committerfxkuehl <fxkuehl>2003-10-25 14:40:54 +0000
commit649709fecaa54b93b9f15c654a55be3829b1a2f8 (patch)
treeaf6575b1076c68f976c94c2d71a88cbac13d0963 /xc/lib/GL/mesa
parentf806a37ba0ad8b43326cb69ee9b84b23f76b3160 (diff)
Improved internal texture format selection in mga, r128, r200 and radeon:
- try to choose a texture format with same color depths as application supplied data in order to avoid loss of color information (mga, r200 and radeon only) - don't override application's choice of internal color depth unless force16bpt is GL_TRUE. For now it is always GL_FALSE, but will be configurable soon
Diffstat (limited to 'xc/lib/GL/mesa')
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgatex.c43
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tex.c85
-rw-r--r--xc/lib/GL/mesa/src/drv/r200/r200_tex.c43
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_tex.c43
4 files changed, 132 insertions, 82 deletions
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatex.c b/xc/lib/GL/mesa/src/drv/mga/mgatex.c
index 36434bad4..3657cb9ed 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgatex.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgatex.c
@@ -163,37 +163,50 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
const GLboolean do32bpt = mmesa->default32BitTextures;
+ const GLboolean force16bpt = GL_FALSE;
+ (void) format;
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 ( 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;
- }
+ switch ( type ) {
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return &_mesa_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return &_mesa_texformat_argb1555;
+ default:
+ return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_argb4444;
}
- 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 ) {
+ switch ( type ) {
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return &_mesa_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return &_mesa_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
return &_mesa_texformat_rgb565;
+ default:
+ return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_rgb565;
}
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+ return !force16bpt ?
+ &_mesa_texformat_rgba8888 : &_mesa_texformat_argb4444;
case GL_RGBA4:
case GL_RGBA2:
@@ -206,7 +219,7 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+ return !force16bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_rgb565;
case GL_RGB5:
case GL_RGB4:
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tex.c b/xc/lib/GL/mesa/src/drv/r128/r128_tex.c
index 3f771dadc..db831e8b8 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_tex.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tex.c
@@ -173,80 +173,91 @@ r128ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
GLenum format, GLenum type )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ const GLboolean do32bpt = rmesa->r128Screen->cpp;
+ const GLboolean force16bpt = GL_FALSE;
(void) format;
(void) type;
switch ( internalFormat ) {
+ /* non-sized formats with alpha */
+ case GL_INTENSITY:
+ case GL_COMPRESSED_INTENSITY:
case GL_ALPHA:
- case GL_ALPHA4:
- case GL_ALPHA8:
- case GL_ALPHA12:
- case GL_ALPHA16:
case GL_COMPRESSED_ALPHA:
case 2:
case GL_LUMINANCE_ALPHA:
+ case GL_COMPRESSED_LUMINANCE_ALPHA:
+ case 4:
+ case GL_RGBA:
+ case GL_COMPRESSED_RGBA:
+ if (do32bpt)
+ return &_mesa_texformat_argb8888;
+ else
+ return &_mesa_texformat_argb4444;
+
+ /* 16-bit formats with alpha */
+ case GL_INTENSITY4:
+ case GL_ALPHA4:
case GL_LUMINANCE4_ALPHA4:
+ case GL_RGBA2:
+ case GL_RGBA4:
+ return &_mesa_texformat_argb4444;
+
+ /* 32-bit formats with alpha */
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
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:
- case 4:
- case GL_RGBA:
- case GL_COMPRESSED_RGBA:
- case GL_RGBA2:
case GL_RGB5_A1:
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- if (rmesa->r128Screen->cpp == 4)
+ if (!force16bpt)
return &_mesa_texformat_argb8888;
else
return &_mesa_texformat_argb4444;
- case GL_RGBA4:
- return &_mesa_texformat_argb4444;
+ /* non-sized formats without alpha */
+ case 1:
+ case GL_LUMINANCE:
+ case GL_COMPRESSED_LUMINANCE:
case 3:
case GL_RGB:
case GL_COMPRESSED_RGB:
- case GL_R3_G3_B2:
- case GL_RGB4:
- case GL_RGB5:
- case GL_RGB8:
- case GL_RGB10:
- case GL_RGB12:
- case GL_RGB16:
- if (rmesa->r128Screen->cpp == 4)
+ if (do32bpt)
return &_mesa_texformat_argb8888;
else
return &_mesa_texformat_rgb565;
- case 1:
- case GL_LUMINANCE:
+ /* 16-bit formats without alpha */
case GL_LUMINANCE4:
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ return &_mesa_texformat_rgb565;
+
+ /* 32-bit formats without alpha */
case GL_LUMINANCE8:
case GL_LUMINANCE12:
case GL_LUMINANCE16:
- case GL_COMPRESSED_LUMINANCE:
- if (rmesa->r128Screen->cpp == 4)
- return &_mesa_texformat_argb8888; /* inefficient but accurate */
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ if (!force16bpt)
+ return &_mesa_texformat_argb8888;
else
return &_mesa_texformat_rgb565;
- case GL_INTENSITY4:
- return &_mesa_texformat_argb4444;
- case GL_INTENSITY:
- case GL_INTENSITY8:
- case GL_INTENSITY12:
- case GL_INTENSITY16:
- case GL_COMPRESSED_INTENSITY:
- if (rmesa->r128Screen->cpp == 4)
- return &_mesa_texformat_argb8888; /* inefficient but accurate */
- else
- return &_mesa_texformat_argb4444;
-
+ /* color-indexed formats */
case GL_COLOR_INDEX:
case GL_COLOR_INDEX1_EXT:
case GL_COLOR_INDEX2_EXT:
diff --git a/xc/lib/GL/mesa/src/drv/r200/r200_tex.c b/xc/lib/GL/mesa/src/drv/r200/r200_tex.c
index 8554a5fdc..02110a361 100644
--- a/xc/lib/GL/mesa/src/drv/r200/r200_tex.c
+++ b/xc/lib/GL/mesa/src/drv/r200/r200_tex.c
@@ -296,37 +296,50 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
{
r200ContextPtr rmesa = R200_CONTEXT(ctx);
const GLboolean do32bpt = rmesa->default32BitTextures;
+ const GLboolean force16bpt = GL_FALSE;
+ (void) format;
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 ( 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;
- }
+ switch ( type ) {
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return &_mesa_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return &_mesa_texformat_argb1555;
+ default:
+ return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_argb4444;
}
- return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_argb4444;
case 3:
case GL_RGB:
case GL_COMPRESSED_RGB:
- if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
+ switch ( type ) {
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return &_mesa_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return &_mesa_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
return &_mesa_texformat_rgb565;
+ default:
+ return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_rgb565;
}
- return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_rgb565;
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_argb4444;
+ return !force16bpt ?
+ &_mesa_texformat_rgba8888 : &_mesa_texformat_argb4444;
case GL_RGBA4:
case GL_RGBA2:
@@ -339,7 +352,7 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_rgb565;
+ return !force16bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_rgb565;
case GL_RGB5:
case GL_RGB4:
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_tex.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_tex.c
index 5858b0e78..b97200519 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_tex.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_tex.c
@@ -261,37 +261,50 @@ radeonChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
const GLboolean do32bpt = rmesa->default32BitTextures;
+ const GLboolean force16bpt = GL_FALSE;
+ (void) format;
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 ( 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;
- }
+ switch ( type ) {
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return &_mesa_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return &_mesa_texformat_argb1555;
+ default:
+ return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_argb4444;
}
- return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_argb4444;
case 3:
case GL_RGB:
case GL_COMPRESSED_RGB:
- if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
+ switch ( type ) {
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return &_mesa_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return &_mesa_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
return &_mesa_texformat_rgb565;
+ default:
+ return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_rgb565;
}
- return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_rgb565;
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_argb4444;
+ return !force16bpt ?
+ &_mesa_texformat_rgba8888 : &_mesa_texformat_argb4444;
case GL_RGBA4:
case GL_RGBA2:
@@ -304,7 +317,7 @@ radeonChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_rgb565;
+ return !force16bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_rgb565;
case GL_RGB5:
case GL_RGB4: