summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2010-09-13 12:03:07 +0100
committerJosé Fonseca <jfonseca@vmware.com>2010-09-13 12:03:35 +0100
commit501d43028e8e551dd36ede00fb85095183c32037 (patch)
treed61b047a3f113786240c17b4cd44f5f18b1451b0
parent91a93257615390f75320c27645167d08b82b46b9 (diff)
llvmpipe: Unbreak rasterization on 64bit.
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup_tri.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index f0c74f8040..3b7fd5d154 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -440,30 +440,28 @@ do_triangle_ccw(struct lp_setup_context *setup,
}
/*
- * __fls: find last set bit in word
- * @word: The word to search
+ * Round to nearest less or equal power of two of the input.
*
- * Undefined if no zero exists, so code should check against ~0UL first.
+ * Undefined if no bit set exists, so code should check against 0 first.
*/
-#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)
-static inline unsigned fls(unsigned word)
+static INLINE uint32_t
+floor_pot(uint32_t n)
{
- asm("bsr %1,%0"
- : "=r" (word)
- : "rm" (word));
- return word;
-}
+ assert(n);
+#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)
+ asm("bsr %1,%0"
+ : "=r" (n)
+ : "rm" (n));
+ return 1 << n;
#else
-static inline unsigned fls(unsigned n)
-{
- n |= (n >> 1);
- n |= (n >> 2);
- n |= (n >> 4);
- n |= (n >> 8);
- n |= (n >> 16);
- return n - (n >> 1);
-}
+ n |= (n >> 1);
+ n |= (n >> 2);
+ n |= (n >> 4);
+ n |= (n >> 8);
+ n |= (n >> 16);
+ return n - (n >> 1);
#endif
+}
boolean
@@ -477,14 +475,14 @@ lp_setup_bin_triangle( struct lp_setup_context *setup,
/* What is the largest power-of-two boundary this triangle crosses:
*/
- int dx = 1 << fls((bbox->x0 ^ bbox->x1) |
- (bbox->y0 ^ bbox->y1));
+ int dx = floor_pot((bbox->x0 ^ bbox->x1) |
+ (bbox->y0 ^ bbox->y1));
/* The largest dimension of the rasterized area of the triangle
- * (aligned to a 4x4 grid), rounded up to the next power of two:
+ * (aligned to a 4x4 grid), rounded down to the nearest power of two:
*/
- int sz = 1 << fls((bbox->x1 - (bbox->x0 & ~3)) |
- (bbox->y1 - (bbox->y0 & ~3)));
+ int sz = floor_pot((bbox->x1 - (bbox->x0 & ~3)) |
+ (bbox->y1 - (bbox->y0 & ~3)));
if (nr_planes == 3) {
if (sz < 4 && dx < 64)