summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/r300/r300_tex.c
diff options
context:
space:
mode:
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 efa072c265..6348ba1982 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: