From a904a7b99043c19493db5c0945b046795a5932b1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 Jan 2010 16:21:31 -0700 Subject: llvmpipe: manually unroll the inputs.step[] setup code Good for a few more fps in some tests. --- src/gallium/drivers/llvmpipe/lp_setup_tri.c | 49 ++++++++++++++++++----------- 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'src/gallium/drivers') diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c index 76ecab76447..dcd849bc856 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c +++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c @@ -362,31 +362,44 @@ do_triangle_ccw(struct setup_context *setup, tri->ei2 = tri->dx23 - tri->dy23 - tri->eo2; tri->ei3 = tri->dx31 - tri->dy31 - tri->eo3; + /* Fill in the inputs.step[][] arrays. + * We've manually unrolled some loops here. + */ { const int xstep1 = -tri->dy12; const int xstep2 = -tri->dy23; const int xstep3 = -tri->dy31; - const int ystep1 = tri->dx12; const int ystep2 = tri->dx23; const int ystep3 = tri->dx31; - - int qx, qy, ix, iy; - int i = 0; - - for (qy = 0; qy < 2; qy++) { - for (qx = 0; qx < 2; qx++) { - for (iy = 0; iy < 2; iy++) { - for (ix = 0; ix < 2; ix++, i++) { - int x = qx * 2 + ix; - int y = qy * 2 + iy; - tri->inputs.step[0][i] = x * xstep1 + y * ystep1; - tri->inputs.step[1][i] = x * xstep2 + y * ystep2; - tri->inputs.step[2][i] = x * xstep3 + y * ystep3; - } - } - } - } + +#define SETUP_STEP(i, x, y) \ + do { \ + tri->inputs.step[0][i] = x * xstep1 + y * ystep1; \ + tri->inputs.step[1][i] = x * xstep2 + y * ystep2; \ + tri->inputs.step[2][i] = x * xstep3 + y * ystep3; \ + } while (0) + + SETUP_STEP(0, 0, 0); + SETUP_STEP(1, 1, 0); + SETUP_STEP(2, 0, 1); + SETUP_STEP(3, 1, 1); + + SETUP_STEP(4, 2, 0); + SETUP_STEP(5, 3, 0); + SETUP_STEP(6, 2, 1); + SETUP_STEP(7, 3, 1); + + SETUP_STEP(8, 0, 2); + SETUP_STEP(9, 1, 2); + SETUP_STEP(10, 0, 3); + SETUP_STEP(11, 1, 3); + + SETUP_STEP(12, 2, 2); + SETUP_STEP(13, 3, 2); + SETUP_STEP(14, 2, 3); + SETUP_STEP(15, 3, 3); +#undef STEP } /* -- cgit v1.2.3