util: Fix 24 to 32 bit expansion binary arithmetic expression.
authorJosé Fonseca <jfonseca@vmware.com>
Tue, 2 Jun 2009 18:46:06 +0000 (11:46 -0700)
committerJosé Fonseca <jfonseca@vmware.com>
Tue, 2 Jun 2009 18:46:06 +0000 (11:46 -0700)
When approaching y = x * 0xffffffff / 0xffffff with bit arithmetic, the
8 least significant bits of y should come from the
8 most significant bits of x.

src/gallium/auxiliary/util/u_tile.c

index f0a5a339eb3452fefad6ea4343c273a3d29e51f5..9becd9fea430bf716066a7d300ecfa46b1a54a55 100644 (file)
@@ -1126,7 +1126,7 @@ pipe_get_tile_z(struct pipe_transfer *pt,
          for (i = 0; i < h; i++) {
             for (j = 0; j < w; j++) {
                /* convert 24-bit Z to 32-bit Z */
-               pDest[j] = (ptrc[j] << 8) | (ptrc[j] & 0xff);
+               pDest[j] = (ptrc[j] << 8) | ((ptrc[j] >> 16) & 0xff);
             }
             pDest += dstStride;
             ptrc += pt->stride/4;