llvmpipe: fix arguments order given to vec_andc
authorOded Gabbay <oded.gabbay@gmail.com>
Sun, 17 Jan 2016 12:25:32 +0000 (14:25 +0200)
committerOded Gabbay <oded.gabbay@gmail.com>
Sun, 17 Jan 2016 19:07:27 +0000 (21:07 +0200)
This patch fixes a classic "confuse the enemy" bug.

_mm_andnot_si128 (SSE) and vec_andc (VMX) do the same operation, but the
arguments are opposite.

_mm_andnot_si128 performs "r = (~a) & b" while
vec_andc performs "r = a & (~b)"

To make sure this error won't return in another place, I added a wrapper
function, vec_andnot_si128, in u_pwr8.h, which makes the swap inside.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/util/u_pwr8.h
src/gallium/drivers/llvmpipe/lp_setup_tri.c

index 1eca6d6df2c071c4bd37949441b57ddf7974d4e5..ffd9f92314246edee87e7f1377706a87426152bc 100644 (file)
@@ -153,6 +153,12 @@ vec_mullo_epi32 (__m128i a, __m128i b)
    return v;
 }
 
+static inline __m128i
+vec_andnot_si128 (__m128i a, __m128i b)
+{
+   return vec_andc (b, a);
+}
+
 static inline void
 transpose4_epi32(const __m128i * restrict a,
                  const __m128i * restrict b,
index aa241761586b717548e320470028dead6acbb89a..907129dbd1be59e1e7e961f489fa8015196c2834 100644 (file)
@@ -556,7 +556,7 @@ do_triangle_ccw(struct lp_setup_context *setup,
 
       /* Calculate trivial reject values:
        */
-      eo = vec_sub_epi32(vec_andc(dcdy_neg_mask, dcdy),
+      eo = vec_sub_epi32(vec_andnot_si128(dcdy_neg_mask, dcdy),
                          vec_and(dcdx_neg_mask, dcdx));
 
       /* ei = _mm_sub_epi32(_mm_sub_epi32(dcdy, dcdx), eo); */