summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/r300/r300_tex.c
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2006-09-20 19:11:56 +0000
committerRoland Scheidegger <[email protected]>2006-09-20 19:11:56 +0000
commit62d4dfbfe3f7c452f3c182bfdb9270a2f20e3f2d (patch)
tree2d4798e3555cc39f4ba82fb2293b3d2a3f664658 /src/mesa/drivers/dri/r300/r300_tex.c
parent46c3bd29be4970a8b0c1c358aae0f1d7c05bc9f4 (diff)
try to use a 8888 texture format which will result in only a memcopy in mesa's texstore functions whenever possible for r200 and r300. r200 can use hw formats argb8888, rgba8888 and abgr8888 (or the opposite on big endian), r300 can use argb8888, bgra8888, rgba8888 and abgr8888 regardless of endian, as it supports free component swizzling.
Diffstat (limited to 'src/mesa/drivers/dri/r300/r300_tex.c')
-rw-r--r--src/mesa/drivers/dri/r300/r300_tex.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_tex.c b/src/mesa/drivers/dri/r300/r300_tex.c
index efa072c2651..6348ba1982a 100644
--- a/src/mesa/drivers/dri/r300/r300_tex.c
+++ b/src/mesa/drivers/dri/r300/r300_tex.c
@@ -297,6 +297,38 @@ static r300TexObjPtr r300AllocTexObj(struct gl_texture_object *texObj)
return t;
}
+/* try to find a format which will only need a memcopy */
+static const struct gl_texture_format *r300Choose8888TexFormat( GLenum srcFormat,
+ GLenum srcType )
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
+ (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian)) {
+ return &_mesa_texformat_rgba8888;
+ }
+ else if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
+ (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) ||
+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian)) {
+ return &_mesa_texformat_rgba8888_rev;
+ }
+ else if (srcFormat == GL_BGRA &&
+ ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
+ srcType == GL_UNSIGNED_INT_8_8_8_8)) {
+ return &_mesa_texformat_argb8888_rev;
+ }
+ else if (srcFormat == GL_BGRA &&
+ ((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
+ srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
+ return &_mesa_texformat_argb8888;
+ }
+ else return _dri_texformat_argb8888;
+}
+
static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
GLint
internalFormat,
@@ -335,7 +367,7 @@ static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
return _dri_texformat_argb1555;
default:
- return do32bpt ? _dri_texformat_rgba8888 :
+ return do32bpt ? r300Choose8888TexFormat(format, type) :
_dri_texformat_argb4444;
}
@@ -353,7 +385,7 @@ static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
case GL_UNSIGNED_SHORT_5_6_5_REV:
return _dri_texformat_rgb565;
default:
- return do32bpt ? _dri_texformat_rgba8888 :
+ return do32bpt ? _dri_texformat_argb8888 :
_dri_texformat_rgb565;
}
@@ -362,7 +394,7 @@ static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
case GL_RGBA12:
case GL_RGBA16:
return !force16bpt ?
- _dri_texformat_rgba8888 : _dri_texformat_argb4444;
+ r300Choose8888TexFormat(format, type) : _dri_texformat_argb4444;
case GL_RGBA4:
case GL_RGBA2:
@@ -375,7 +407,7 @@ static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return !force16bpt ? _dri_texformat_rgba8888 :
+ return !force16bpt ? _dri_texformat_argb8888 :
_dri_texformat_rgb565;
case GL_RGB5: