mesa: fix rgtc snorm decoding
authorRoland Scheidegger <sroland@vmware.com>
Mon, 22 Jul 2013 19:02:56 +0000 (21:02 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Wed, 24 Jul 2013 13:58:00 +0000 (15:58 +0200)
The codeword must be unsigned (otherwise will shift in 1's from above when
merging low/high parts so some texels decode wrong).
This also affects gallium's util/u_format_rgtc.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Zack Rusin <zackr@vmware.com>
src/mesa/main/texcompress_rgtc_tmp.h

index 277d69b1798683df6f6ffb6669e50143c5db5d38..5fa9de630b6f7ff9ce399124ecc270bc7977a25e 100644 (file)
@@ -37,9 +37,9 @@ static void TAG(fetch_texel_rgtc)(unsigned srcRowStride, const TYPE *pixdata,
    const TYPE alpha0 = blksrc[0];
    const TYPE alpha1 = blksrc[1];
    const char bit_pos = ((j&3) * 4 + (i&3)) * 3;
-   const TYPE acodelow = blksrc[2 + bit_pos / 8];
-   const TYPE acodehigh = (3 + bit_pos / 8) < 8 ? blksrc[3 + bit_pos / 8] : 0;
-   const TYPE code = (acodelow >> (bit_pos & 0x7) |
+   const unsigned char acodelow = blksrc[2 + bit_pos / 8];
+   const unsigned char acodehigh = (3 + bit_pos / 8) < 8 ? blksrc[3 + bit_pos / 8] : 0;
+   const unsigned char code = (acodelow >> (bit_pos & 0x7) |
       (acodehigh  << (8 - (bit_pos & 0x7)))) & 0x7;
 
    if (code == 0)