llvmpipe: Fix depth mask computation.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 9 Sep 2009 20:17:20 +0000 (21:17 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Wed, 9 Sep 2009 20:48:50 +0000 (21:48 +0100)
Fixes depth test for 24bit depth formats.

src/gallium/drivers/llvmpipe/lp_bld_depth.c

index 2cd6e6b92175cf82b76d10199068637e0c15176b..3f88a14b5d3b941bbcc0a38d5f3fcc764b8e7a87 100644 (file)
@@ -179,12 +179,13 @@ lp_build_depth_test(LLVMBuilderRef builder,
       padding_right = 0;
       for(chan = 0; chan < z_swizzle; ++chan)
          padding_right += format_desc->channel[chan].size;
-      padding_left = format_desc->block.bits - format_desc->channel[z_swizzle].size;
+      padding_left = format_desc->block.bits -
+                     (padding_right + format_desc->channel[z_swizzle].size);
 
       if(padding_left || padding_right) {
-         const long long mask_left = ((long long)1 << (format_desc->block.bits - padding_left)) - 1;
-         const long long mask_right = ((long long)1 << (padding_right)) - 1;
-         z_bitmask = lp_build_int_const_scalar(type, mask_left & mask_right);
+         const unsigned long long mask_left = ((unsigned long long)1 << (format_desc->block.bits - padding_left)) - 1;
+         const unsigned long long mask_right = ((unsigned long long)1 << (padding_right)) - 1;
+         z_bitmask = lp_build_int_const_scalar(type, mask_left ^ mask_right);
       }
 
       if(padding_left)