[Mesa-dev] [PATCH] mesa/main: Fix unpack_R5G6B5_UNORM.
Iago Toral Quiroga
itoral at igalia.com
Tue Oct 7 03:04:07 PDT 2014
There is a comment warning about the fact that this is not doing what we
expect, so fix it. This should be doing the same as unpack_B5G6R5_UNORM
but swapping B and R.
---
Jason started some work to auto-generate the format_pack.c and
format_unpack.c files which I think has this fixed. I am continuing his
work on this at the moment, but I guess it might make sense to fix this in
the current code too while that work is on-going.
No piglit regressions observed.
src/mesa/main/format_unpack.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index d5628a9..11b028c 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -207,16 +207,12 @@ unpack_B5G6R5_UNORM(const void *src, GLfloat dst[][4], GLuint n)
static void
unpack_R5G6B5_UNORM(const void *src, GLfloat dst[][4], GLuint n)
{
- /* Warning: this function does not match the current Mesa definition
- * of MESA_FORMAT_R5G6B5_UNORM.
- */
const GLushort *s = ((const GLushort *) src);
GLuint i;
for (i = 0; i < n; i++) {
- GLuint t = (s[i] >> 8) | (s[i] << 8); /* byte swap */
- dst[i][RCOMP] = UBYTE_TO_FLOAT( ((t >> 8) & 0xf8) | ((t >> 13) & 0x7) );
- dst[i][GCOMP] = UBYTE_TO_FLOAT( ((t >> 3) & 0xfc) | ((t >> 9) & 0x3) );
- dst[i][BCOMP] = UBYTE_TO_FLOAT( ((t << 3) & 0xf8) | ((t >> 2) & 0x7) );
+ dst[i][RCOMP] = ((s[i] ) & 0x1f) * (1.0F / 31.0F);
+ dst[i][GCOMP] = ((s[i] >> 5 ) & 0x3f) * (1.0F / 63.0F);
+ dst[i][BCOMP] = ((s[i] >> 11) & 0x1f) * (1.0F / 31.0F);
dst[i][ACOMP] = 1.0F;
}
}
--
1.9.1
More information about the mesa-dev
mailing list