# Mesa (lp-binning): llvmpipe: simplify mask computation

Brian Paul brianp at kemper.freedesktop.org
Wed Dec 2 14:16:09 PST 2009

Module: Mesa
Branch: lp-binning
Commit: 9c486774913f66c6496cd43cfd9dbd992c28d8cb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9c486774913f66c6496cd43cfd9dbd992c28d8cb

Author: Brian Paul <brianp at vmware.com>
Date:   Tue Dec  1 16:24:16 2009 -0700

Make this a little easier to understand.

---

src/gallium/drivers/llvmpipe/lp_rast_tri.c |   10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri.c b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
index 9543b86..f6cb628 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
@@ -89,10 +89,12 @@ do_block_4( struct lp_rasterizer *rast,
assert(x % 4 == 0);
assert(y % 4 == 0);

-   for (i = 0; i < 16; i++)
-      mask |= (~(((c1 + tri->step[0][i]) |
-		  (c2 + tri->step[1][i]) |
-		  (c3 + tri->step[2][i])) >> 31)) & (1 << i);
+   for (i = 0; i < 16; i++) {
+      int any_negative = ((c1 + tri->step[0][i]) |
+                          (c2 + tri->step[1][i]) |
+                          (c3 + tri->step[2][i])) >> 31;
+      mask |= (~any_negative) & (1 << i);
+   }

/* As we do trivial reject already, masks should rarely be all zero:
*/