Mesa (texformat-rework): swrast: fix RGB, RGBA texturing code
Brian Paul
brianp at kemper.freedesktop.org
Thu Oct 29 02:15:36 UTC 2009
Module: Mesa
Branch: texformat-rework
Commit: 086f9fc0e2aef27f54eda87c733685500555bf20
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=086f9fc0e2aef27f54eda87c733685500555bf20
Author: Brian Paul <brianp at vmware.com>
Date: Wed Oct 28 19:46:26 2009 -0600
swrast: fix RGB, RGBA texturing code
Fix backward component ordering for RGB textures.
Only optimize RGBA texture case if running little endian. This restriction
could be lifted with a little work.
---
src/mesa/swrast/s_triangle.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index f417578..5ecc769 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -159,9 +159,9 @@ _swrast_culltriangle( GLcontext *ctx,
GLint t = FixedToInt(span.intTex[1]) & tmask; \
GLint pos = (t << twidth_log2) + s; \
pos = pos + pos + pos; /* multiply by 3 */ \
- rgb[i][RCOMP] = texture[pos]; \
+ rgb[i][RCOMP] = texture[pos+2]; \
rgb[i][GCOMP] = texture[pos+1]; \
- rgb[i][BCOMP] = texture[pos+2]; \
+ rgb[i][BCOMP] = texture[pos+0]; \
span.intTex[0] += span.intTexStep[0]; \
span.intTex[1] += span.intTexStep[1]; \
} \
@@ -215,9 +215,9 @@ _swrast_culltriangle( GLcontext *ctx,
GLint t = FixedToInt(span.intTex[1]) & tmask; \
GLint pos = (t << twidth_log2) + s; \
pos = pos + pos + pos; /* multiply by 3 */ \
- rgb[i][RCOMP] = texture[pos]; \
+ rgb[i][RCOMP] = texture[pos+2]; \
rgb[i][GCOMP] = texture[pos+1]; \
- rgb[i][BCOMP] = texture[pos+2]; \
+ rgb[i][BCOMP] = texture[pos+0]; \
zRow[i] = z; \
span.array->mask[i] = 1; \
} \
@@ -1101,7 +1101,13 @@ _swrast_choose_triangle( GLcontext *ctx )
#if CHAN_BITS != 8
USE(general_triangle);
#else
- USE(affine_textured_triangle);
+ if (format == MESA_FORMAT_RGBA8888 && !_mesa_little_endian())
+ /* We only handle RGBA8888 correctly on little endian
+ * in the optimized code above.
+ */
+ USE(general_triangle);
+ else
+ USE(affine_textured_triangle);
#endif
}
}
More information about the mesa-commit
mailing list