diff options
author | Jason Ekstrand <[email protected]> | 2014-08-22 13:39:23 -0700 |
---|---|---|
committer | Iago Toral Quiroga <[email protected]> | 2015-01-12 11:20:27 +0100 |
commit | ec0bfba49668875462dfd75f4824f48018e82efe (patch) | |
tree | 2ff2261e86b7928f710977a2a61444621a090e6e /src/mesa/swrast/s_texfetch_tmp.h | |
parent | 7d1b08ac44cf2531b0df39f52ead93ad216ea233 (diff) |
mesa: Fix packing/unpacking of MESA_FORMAT_R5G6B5_UNORM
Aparently, the packing/unpacking functions for these formats have differed
from the format description in formats.h. Instead of fixing this, people
simply left a comment saying it was broken. Let's actually fix it for
real.
v2 by Samuel Iglesias <[email protected]>:
- Fix comment in formats.h
Signed-off-by: Jason Ekstrand <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src/mesa/swrast/s_texfetch_tmp.h')
-rw-r--r-- | src/mesa/swrast/s_texfetch_tmp.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/mesa/swrast/s_texfetch_tmp.h b/src/mesa/swrast/s_texfetch_tmp.h index 7ff30f6b4ae..23db48d969e 100644 --- a/src/mesa/swrast/s_texfetch_tmp.h +++ b/src/mesa/swrast/s_texfetch_tmp.h @@ -417,10 +417,10 @@ FETCH(R5G6B5_UNORM)(const struct swrast_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */ - texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) ); - texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 3) & 0xfc) | ((s >> 9) & 0x3) ); - texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) ); + const GLushort s = *src; + texel[RCOMP] = ((s ) & 0x1f) * (1.0F / 31.0F); + texel[GCOMP] = ((s >> 5 ) & 0x3f) * (1.0F / 63.0F); + texel[BCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F); texel[ACOMP] = 1.0F; } |