[Mesa-dev] [PATCH 1/2] mesa: fix unpacking of RG88_REV texels

Brian Paul brianp at vmware.com
Wed Nov 30 19:36:04 PST 2011


R should be in the high byte and G in the low byte for this format.
---
 src/mesa/main/format_unpack.c    |    4 ++--
 src/mesa/swrast/s_texfetch_tmp.h |    6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index 0411f5f..4b4ee6b 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -521,8 +521,8 @@ unpack_RG88_REV(const void *src, GLfloat dst[][4], GLuint n)
    const GLushort *s = ((const GLushort *) src);
    GLuint i;
    for (i = 0; i < n; i++) {
-      dst[i][RCOMP] = UBYTE_TO_FLOAT( s[i] & 0xff );
-      dst[i][GCOMP] = UBYTE_TO_FLOAT( s[i] >> 8 );
+      dst[i][RCOMP] = UBYTE_TO_FLOAT( s[i] >> 8 );
+      dst[i][GCOMP] = UBYTE_TO_FLOAT( s[i] & 0xff );
       dst[i][BCOMP] = 0.0;
       dst[i][ACOMP] = 1.0;
    }
diff --git a/src/mesa/swrast/s_texfetch_tmp.h b/src/mesa/swrast/s_texfetch_tmp.h
index 4ee05a5..88711b0 100644
--- a/src/mesa/swrast/s_texfetch_tmp.h
+++ b/src/mesa/swrast/s_texfetch_tmp.h
@@ -1040,8 +1040,8 @@ static void FETCH(f_rg88_rev)( const struct swrast_texture_image *texImage,
                            GLint i, GLint j, GLint k, GLfloat *texel )
 {
    const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   texel[RCOMP] = UBYTE_TO_FLOAT( s & 0xff );
-   texel[GCOMP] = UBYTE_TO_FLOAT( s >> 8 );
+   texel[RCOMP] = UBYTE_TO_FLOAT( s >> 8 );
+   texel[GCOMP] = UBYTE_TO_FLOAT( s & 0xff );
    texel[BCOMP] = 0.0;
    texel[ACOMP] = 1.0;
 }
@@ -1052,7 +1052,7 @@ static void store_texel_rg88_rev(struct swrast_texture_image *texImage,
 {
    const GLubyte *rgba = (const GLubyte *) texel;
    GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   *dst = PACK_COLOR_88(rgba[GCOMP], rgba[RCOMP]);
+   *dst = PACK_COLOR_88(rgba[RCOMP], rgba[GCOMP]);
 }
 #endif
 
-- 
1.7.3.4



More information about the mesa-dev mailing list