#include "lp_debug.h"
#include "lp_perf.h"
#include "lp_rast_priv.h"
-#include "lp_tile_soa.h"
-
-
-
/**
* Shade all pixels in a 4x4 block.
block_full_4(task, tri, x + ix, y + iy);
}
-#if !defined(PIPE_ARCH_SSE)
-
static INLINE unsigned
-build_mask_linear(int c, int dcdx, int dcdy)
+build_mask_linear(int64_t c, int64_t dcdx, int64_t dcdy)
{
- int mask = 0;
-
- int c0 = c;
- int c1 = c0 + dcdy;
- int c2 = c1 + dcdy;
- int c3 = c2 + dcdy;
-
- mask |= ((c0 + 0 * dcdx) >> 31) & (1 << 0);
- mask |= ((c0 + 1 * dcdx) >> 31) & (1 << 1);
- mask |= ((c0 + 2 * dcdx) >> 31) & (1 << 2);
- mask |= ((c0 + 3 * dcdx) >> 31) & (1 << 3);
- mask |= ((c1 + 0 * dcdx) >> 31) & (1 << 4);
- mask |= ((c1 + 1 * dcdx) >> 31) & (1 << 5);
- mask |= ((c1 + 2 * dcdx) >> 31) & (1 << 6);
- mask |= ((c1 + 3 * dcdx) >> 31) & (1 << 7);
- mask |= ((c2 + 0 * dcdx) >> 31) & (1 << 8);
- mask |= ((c2 + 1 * dcdx) >> 31) & (1 << 9);
- mask |= ((c2 + 2 * dcdx) >> 31) & (1 << 10);
- mask |= ((c2 + 3 * dcdx) >> 31) & (1 << 11);
- mask |= ((c3 + 0 * dcdx) >> 31) & (1 << 12);
- mask |= ((c3 + 1 * dcdx) >> 31) & (1 << 13);
- mask |= ((c3 + 2 * dcdx) >> 31) & (1 << 14);
- mask |= ((c3 + 3 * dcdx) >> 31) & (1 << 15);
+ unsigned mask = 0;
+
+ int64_t c0 = c;
+ int64_t c1 = c0 + dcdy;
+ int64_t c2 = c1 + dcdy;
+ int64_t c3 = c2 + dcdy;
+
+ mask |= ((c0 + 0 * dcdx) >> FIXED_SHIFT) & (1 << 0);
+ mask |= ((c0 + 1 * dcdx) >> FIXED_SHIFT) & (1 << 1);
+ mask |= ((c0 + 2 * dcdx) >> FIXED_SHIFT) & (1 << 2);
+ mask |= ((c0 + 3 * dcdx) >> FIXED_SHIFT) & (1 << 3);
+ mask |= ((c1 + 0 * dcdx) >> FIXED_SHIFT) & (1 << 4);
+ mask |= ((c1 + 1 * dcdx) >> FIXED_SHIFT) & (1 << 5);
+ mask |= ((c1 + 2 * dcdx) >> FIXED_SHIFT) & (1 << 6);
+ mask |= ((c1 + 3 * dcdx) >> FIXED_SHIFT) & (1 << 7);
+ mask |= ((c2 + 0 * dcdx) >> FIXED_SHIFT) & (1 << 8);
+ mask |= ((c2 + 1 * dcdx) >> FIXED_SHIFT) & (1 << 9);
+ mask |= ((c2 + 2 * dcdx) >> FIXED_SHIFT) & (1 << 10);
+ mask |= ((c2 + 3 * dcdx) >> FIXED_SHIFT) & (1 << 11);
+ mask |= ((c3 + 0 * dcdx) >> FIXED_SHIFT) & (1 << 12);
+ mask |= ((c3 + 1 * dcdx) >> FIXED_SHIFT) & (1 << 13);
+ mask |= ((c3 + 2 * dcdx) >> FIXED_SHIFT) & (1 << 14);
+ mask |= ((c3 + 3 * dcdx) >> FIXED_SHIFT) & (1 << 15);
return mask;
}
static INLINE void
-build_masks(int c,
- int cdiff,
- int dcdx,
- int dcdy,
+build_masks(int64_t c,
+ int64_t cdiff,
+ int64_t dcdx,
+ int64_t dcdy,
unsigned *outmask,
unsigned *partmask)
{
lp_rast_triangle_3(task, arg2);
}
+void
+lp_rast_triangle_3_4(struct lp_rasterizer_task *task,
+ const union lp_rast_cmd_arg arg)
+{
+ lp_rast_triangle_3_16(task, arg);
+}
+
void
lp_rast_triangle_4_16(struct lp_rasterizer_task *task,
const union lp_rast_cmd_arg arg)
union lp_rast_cmd_arg arg2;
arg2.triangle.tri = arg.triangle.tri;
arg2.triangle.plane_mask = (1<<4)-1;
- lp_rast_triangle_3(task, arg2);
+ lp_rast_triangle_4(task, arg2);
}
+#if !defined(PIPE_ARCH_SSE)
+
void
-lp_rast_triangle_3_4(struct lp_rasterizer_task *task,
+lp_rast_triangle_32_3_16(struct lp_rasterizer_task *task,
+ const union lp_rast_cmd_arg arg)
+{
+ union lp_rast_cmd_arg arg2;
+ arg2.triangle.tri = arg.triangle.tri;
+ arg2.triangle.plane_mask = (1<<3)-1;
+ lp_rast_triangle_32_3(task, arg2);
+}
+
+void
+lp_rast_triangle_32_4_16(struct lp_rasterizer_task *task,
+ const union lp_rast_cmd_arg arg)
+{
+ union lp_rast_cmd_arg arg2;
+ arg2.triangle.tri = arg.triangle.tri;
+ arg2.triangle.plane_mask = (1<<4)-1;
+ lp_rast_triangle_32_4(task, arg2);
+}
+
+void
+lp_rast_triangle_32_3_4(struct lp_rasterizer_task *task,
const union lp_rast_cmd_arg arg)
{
- lp_rast_triangle_3_16(task, arg);
+ lp_rast_triangle_32_3_16(task, arg);
}
#else
static INLINE void
-build_masks(int c,
- int cdiff,
- int dcdx,
- int dcdy,
- unsigned *outmask,
- unsigned *partmask)
+build_masks_32(int c,
+ int cdiff,
+ int dcdx,
+ int dcdy,
+ unsigned *outmask,
+ unsigned *partmask)
{
__m128i cstep0 = _mm_setr_epi32(c, c+dcdx, c+dcdx*2, c+dcdx*3);
__m128i xdcdy = _mm_set1_epi32(dcdy);
static INLINE unsigned
-build_mask_linear(int c, int dcdx, int dcdy)
+build_mask_linear_32(int c, int dcdx, int dcdy)
{
__m128i cstep0 = _mm_setr_epi32(c, c+dcdx, c+dcdx*2, c+dcdx*3);
__m128i xdcdy = _mm_set1_epi32(dcdy);
return _mm_movemask_epi8(result);
}
-#endif
-
-
-
-
-#define TAG(x) x##_1
-#define NR_PLANES 1
-#include "lp_rast_tri_tmp.h"
-
-#define TAG(x) x##_2
-#define NR_PLANES 2
-#include "lp_rast_tri_tmp.h"
-
-#define TAG(x) x##_3
-#define NR_PLANES 3
-/*#define TRI_4 lp_rast_triangle_3_4*/
-/*#define TRI_16 lp_rast_triangle_3_16*/
-#include "lp_rast_tri_tmp.h"
-
-#define TAG(x) x##_4
-#define NR_PLANES 4
-#define TRI_16 lp_rast_triangle_4_16
-#include "lp_rast_tri_tmp.h"
-
-#define TAG(x) x##_5
-#define NR_PLANES 5
-#include "lp_rast_tri_tmp.h"
-
-#define TAG(x) x##_6
-#define NR_PLANES 6
-#include "lp_rast_tri_tmp.h"
-
-#define TAG(x) x##_7
-#define NR_PLANES 7
-#include "lp_rast_tri_tmp.h"
-
-#define TAG(x) x##_8
-#define NR_PLANES 8
-#include "lp_rast_tri_tmp.h"
-
-
-static INLINE void
-transpose4_epi32(const __m128i * restrict a,
- const __m128i * restrict b,
- const __m128i * restrict c,
- const __m128i * restrict d,
- __m128i * restrict o,
- __m128i * restrict p,
- __m128i * restrict q,
- __m128i * restrict r)
-{
- __m128i t0 = _mm_unpacklo_epi32(*a, *b);
- __m128i t1 = _mm_unpacklo_epi32(*c, *d);
- __m128i t2 = _mm_unpackhi_epi32(*a, *b);
- __m128i t3 = _mm_unpackhi_epi32(*c, *d);
-
- *o = _mm_unpacklo_epi64(t0, t1);
- *p = _mm_unpackhi_epi64(t0, t1);
- *q = _mm_unpacklo_epi64(t2, t3);
- *r = _mm_unpackhi_epi64(t2, t3);
-}
-
-
-#define SCALAR_EPI32(m, i) _mm_shuffle_epi32((m), _MM_SHUFFLE(i,i,i,i))
#define NR_PLANES 3
-/* Provide an SSE2 implementation of _mm_mullo_epi32() in terms of
- * _mm_mul_epu32().
- *
- * I suspect this works fine for us because one of our operands is
- * always positive, but not sure that this can be used for general
- * signed integer multiplication.
- *
- * This seems close enough to the speed of SSE4 and the real
- * _mm_mullo_epi32() intrinsic as to not justify adding an sse4
- * dependency at this point.
- */
-static INLINE __m128i mm_mullo_epi32(const __m128i a, const __m128i b)
-{
- __m128i a4 = _mm_srli_si128(a, 4); /* shift by one dword */
- __m128i b4 = _mm_srli_si128(b, 4); /* shift by one dword */
- __m128i ba = _mm_mul_epu32(b, a); /* multply dwords 0, 2 */
- __m128i b4a4 = _mm_mul_epu32(b4, a4); /* multiply dwords 1, 3 */
-
- /* Interleave the results, either with shuffles or (slightly
- * faster) direct bit operations:
- */
-#if 0
- __m128i ba8 = _mm_shuffle_epi32(ba, 8);
- __m128i b4a48 = _mm_shuffle_epi32(b4a4, 8);
- __m128i result = _mm_unpacklo_epi32(ba8, b4a48);
-#else
- __m128i mask = _mm_setr_epi32(~0,0,~0,0);
- __m128i ba_mask = _mm_and_si128(ba, mask);
- __m128i b4a4_mask = _mm_and_si128(b4a4, mask);
- __m128i b4a4_mask_shift = _mm_slli_si128(b4a4_mask, 4);
- __m128i result = _mm_or_si128(ba_mask, b4a4_mask_shift);
-#endif
-
- return result;
-}
void
-lp_rast_triangle_3_16(struct lp_rasterizer_task *task,
+lp_rast_triangle_32_3_16(struct lp_rasterizer_task *task,
const union lp_rast_cmd_arg arg)
{
const struct lp_rast_triangle *tri = arg.triangle.tri;
- const struct lp_rast_plane *plane = tri->plane;
+ const struct lp_rast_plane *plane = GET_PLANES(tri);
int x = (arg.triangle.plane_mask & 0xff) + task->x;
int y = (arg.triangle.plane_mask >> 8) + task->y;
unsigned i, j;
struct { unsigned mask:16; unsigned i:8; unsigned j:8; } out[16];
unsigned nr = 0;
- __m128i p0 = _mm_loadu_si128((__m128i *)&plane[0]); /* c, dcdx, dcdy, eo */
- __m128i p1 = _mm_loadu_si128((__m128i *)&plane[1]); /* c, dcdx, dcdy, eo */
- __m128i p2 = _mm_loadu_si128((__m128i *)&plane[2]); /* c, dcdx, dcdy, eo */
+ __m128i p0 = lp_plane_to_m128i(&plane[0]); /* c, dcdx, dcdy, eo */
+ __m128i p1 = lp_plane_to_m128i(&plane[1]); /* c, dcdx, dcdy, eo */
+ __m128i p2 = lp_plane_to_m128i(&plane[2]); /* c, dcdx, dcdy, eo */
__m128i zero = _mm_setzero_si128();
__m128i c;
c = _mm_add_epi32(c, mm_mullo_epi32(dcdy, _mm_set1_epi32(y)));
rej4 = _mm_slli_epi32(rej4, 2);
+ /* Adjust so we can just check the sign bit (< 0 comparison), instead of having to do a less efficient <= 0 comparison */
+ c = _mm_sub_epi32(c, _mm_set1_epi32(1));
+ rej4 = _mm_add_epi32(rej4, _mm_set1_epi32(1));
+
dcdx2 = _mm_add_epi32(dcdx, dcdx);
dcdx3 = _mm_add_epi32(dcdx2, dcdx);
void
-lp_rast_triangle_3_4(struct lp_rasterizer_task *task,
+lp_rast_triangle_32_3_4(struct lp_rasterizer_task *task,
const union lp_rast_cmd_arg arg)
{
const struct lp_rast_triangle *tri = arg.triangle.tri;
- const struct lp_rast_plane *plane = tri->plane;
- int x = (arg.triangle.plane_mask & 0xff) + task->x;
- int y = (arg.triangle.plane_mask >> 8) + task->y;
+ const struct lp_rast_plane *plane = GET_PLANES(tri);
+ unsigned x = (arg.triangle.plane_mask & 0xff) + task->x;
+ unsigned y = (arg.triangle.plane_mask >> 8) + task->y;
- __m128i p0 = _mm_loadu_si128((__m128i *)&plane[0]); /* c, dcdx, dcdy, eo */
- __m128i p1 = _mm_loadu_si128((__m128i *)&plane[1]); /* c, dcdx, dcdy, eo */
- __m128i p2 = _mm_loadu_si128((__m128i *)&plane[2]); /* c, dcdx, dcdy, eo */
+ __m128i p0 = lp_plane_to_m128i(&plane[0]); /* c, dcdx, dcdy, eo */
+ __m128i p1 = lp_plane_to_m128i(&plane[1]); /* c, dcdx, dcdy, eo */
+ __m128i p2 = lp_plane_to_m128i(&plane[2]); /* c, dcdx, dcdy, eo */
__m128i zero = _mm_setzero_si128();
__m128i c;
__m128i span_1; /* 0,dcdx,2dcdx,3dcdx for plane 1 */
__m128i span_2; /* 0,dcdx,2dcdx,3dcdx for plane 2 */
__m128i unused;
-
+
transpose4_epi32(&p0, &p1, &p2, &zero,
&c, &dcdx, &dcdy, &unused);
c = _mm_add_epi32(c, mm_mullo_epi32(dcdx, _mm_set1_epi32(x)));
c = _mm_add_epi32(c, mm_mullo_epi32(dcdy, _mm_set1_epi32(y)));
+ /* Adjust so we can just check the sign bit (< 0 comparison), instead of having to do a less efficient <= 0 comparison */
+ c = _mm_sub_epi32(c, _mm_set1_epi32(1));
+
dcdx2 = _mm_add_epi32(dcdx, dcdx);
dcdx3 = _mm_add_epi32(dcdx2, dcdx);
0xffff & ~mask);
}
}
+
+#undef NR_PLANES
+#endif
+
+
+#define BUILD_MASKS(c, cdiff, dcdx, dcdy, omask, pmask) build_masks(c, cdiff, dcdx, dcdy, omask, pmask)
+#define BUILD_MASK_LINEAR(c, dcdx, dcdy) build_mask_linear(c, dcdx, dcdy)
+
+#define TAG(x) x##_1
+#define NR_PLANES 1
+#include "lp_rast_tri_tmp.h"
+
+#define TAG(x) x##_2
+#define NR_PLANES 2
+#include "lp_rast_tri_tmp.h"
+
+#define TAG(x) x##_3
+#define NR_PLANES 3
+/*#define TRI_4 lp_rast_triangle_3_4*/
+/*#define TRI_16 lp_rast_triangle_3_16*/
+#include "lp_rast_tri_tmp.h"
+
+#define TAG(x) x##_4
+#define NR_PLANES 4
+/*#define TRI_16 lp_rast_triangle_4_16*/
+#include "lp_rast_tri_tmp.h"
+
+#define TAG(x) x##_5
+#define NR_PLANES 5
+#include "lp_rast_tri_tmp.h"
+
+#define TAG(x) x##_6
+#define NR_PLANES 6
+#include "lp_rast_tri_tmp.h"
+
+#define TAG(x) x##_7
+#define NR_PLANES 7
+#include "lp_rast_tri_tmp.h"
+
+#define TAG(x) x##_8
+#define NR_PLANES 8
+#include "lp_rast_tri_tmp.h"
+
+#ifdef PIPE_ARCH_SSE
+#undef BUILD_MASKS
+#undef BUILD_MASK_LINEAR
+#define BUILD_MASKS(c, cdiff, dcdx, dcdy, omask, pmask) build_masks_32((int)c, (int)cdiff, dcdx, dcdy, omask, pmask)
+#define BUILD_MASK_LINEAR(c, dcdx, dcdy) build_mask_linear_32((int)c, dcdx, dcdy)
+#endif
+
+#define TAG(x) x##_32_1
+#define NR_PLANES 1
+#include "lp_rast_tri_tmp.h"
+
+#define TAG(x) x##_32_2
+#define NR_PLANES 2
+#include "lp_rast_tri_tmp.h"
+
+#define TAG(x) x##_32_3
+#define NR_PLANES 3
+/*#define TRI_4 lp_rast_triangle_3_4*/
+/*#define TRI_16 lp_rast_triangle_3_16*/
+#include "lp_rast_tri_tmp.h"
+
+#define TAG(x) x##_32_4
+#define NR_PLANES 4
+#ifdef PIPE_ARCH_SSE
+#define TRI_16 lp_rast_triangle_32_4_16
+#endif
+#include "lp_rast_tri_tmp.h"
+
+#define TAG(x) x##_32_5
+#define NR_PLANES 5
+#include "lp_rast_tri_tmp.h"
+
+#define TAG(x) x##_32_6
+#define NR_PLANES 6
+#include "lp_rast_tri_tmp.h"
+
+#define TAG(x) x##_32_7
+#define NR_PLANES 7
+#include "lp_rast_tri_tmp.h"
+
+#define TAG(x) x##_32_8
+#define NR_PLANES 8
+#include "lp_rast_tri_tmp.h"
+