Mesa (lp-binning): llvmpipe: pre-multiply some constants by fixed_one

Keith Whitwell keithw at kemper.freedesktop.org
Mon Oct 19 15:42:14 UTC 2009


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

Author: Keith Whitwell <keithw at vmware.com>
Date:   Mon Oct 19 14:55:05 2009 +0100

llvmpipe: pre-multiply some constants by fixed_one

---

 src/gallium/drivers/llvmpipe/lp_rast_tri.c  |   26 +++++-------
 src/gallium/drivers/llvmpipe/lp_setup_tri.c |   56 +++++++++++++++-----------
 2 files changed, 43 insertions(+), 39 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri.c b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
index c63aa22..17ebce4 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
@@ -66,13 +66,13 @@ do_quad( const struct lp_rast_triangle *tri,
 	 int x, int y,
 	 int c1, int c2, int c3 )
 {
-   const int xstep1 = -tri->dy12 * FIXED_ONE;
-   const int xstep2 = -tri->dy23 * FIXED_ONE;
-   const int xstep3 = -tri->dy31 * FIXED_ONE;
+   const int xstep1 = -tri->dy12 ;
+   const int xstep2 = -tri->dy23 ;
+   const int xstep3 = -tri->dy31 ;
 
-   const int ystep1 = tri->dx12 * FIXED_ONE;
-   const int ystep2 = tri->dx23 * FIXED_ONE;
-   const int ystep3 = tri->dx31 * FIXED_ONE;
+   const int ystep1 = tri->dx12 ;
+   const int ystep2 = tri->dx23 ;
+   const int ystep3 = tri->dx31 ;
 
    unsigned mask = 0;
 
@@ -110,7 +110,7 @@ do_block( struct lp_rasterizer *rast,
           int c2,
           int c3 )
 {
-   const int step = 2 * FIXED_ONE;
+   const int step = 2 ;
 
    const int xstep1 = -step * tri->dy12;
    const int xstep2 = -step * tri->dy23;
@@ -157,7 +157,7 @@ void lp_rast_triangle( struct lp_rasterizer *rast,
 {
    const struct lp_rast_triangle *tri = arg.triangle;
 
-   const int step = BLOCKSIZE * FIXED_ONE;
+   const int step = BLOCKSIZE;
 
    int ei1 = tri->ei1 * step;
    int ei2 = tri->ei2 * step;
@@ -183,7 +183,6 @@ void lp_rast_triangle( struct lp_rasterizer *rast,
    int maxy = MIN2(tri->maxy, rast->y + TILE_SIZE);
 
    int x, y;
-   int x0, y0;
    int c1, c2, c3;
 
    debug_printf("%s\n", __FUNCTION__);
@@ -196,12 +195,9 @@ void lp_rast_triangle( struct lp_rasterizer *rast,
    minx &= ~(BLOCKSIZE-1);
    miny &= ~(BLOCKSIZE-1);
 
-   x0 = minx << FIXED_ORDER;
-   y0 = miny << FIXED_ORDER;
-
-   c1 = tri->c1 + tri->dx12 * y0 - tri->dy12 * x0;
-   c2 = tri->c2 + tri->dx23 * y0 - tri->dy23 * x0;
-   c3 = tri->c3 + tri->dx31 * y0 - tri->dy31 * x0;
+   c1 = tri->c1 + tri->dx12 * miny - tri->dy12 * minx;
+   c2 = tri->c2 + tri->dx23 * miny - tri->dy23 * minx;
+   c3 = tri->c3 + tri->dx31 * miny - tri->dy31 * minx;
 
    for (y = miny; y < maxy; y += BLOCKSIZE)
    {
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index 44386a2..6c9f75e 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -323,6 +323,14 @@ do_triangle_ccw(struct setup_context *setup,
    if (tri->dy23 < 0 || (tri->dy23 == 0 && tri->dx23 > 0)) tri->c2++;
    if (tri->dy31 < 0 || (tri->dy31 == 0 && tri->dx31 > 0)) tri->c3++;
 
+   tri->dy12 *= FIXED_ONE;
+   tri->dy23 *= FIXED_ONE;
+   tri->dy31 *= FIXED_ONE;
+
+   tri->dx12 *= FIXED_ONE;
+   tri->dx23 *= FIXED_ONE;
+   tri->dx31 *= FIXED_ONE;
+
    /* find trivial reject offsets for each edge for a single-pixel
     * sized block.  These will be scaled up at each recursive level to
     * match the active blocksize.  Scaling in this way works best if
@@ -363,30 +371,30 @@ do_triangle_ccw(struct setup_context *setup,
    else 
    {
       int c1 = (tri->c1 + 
-                tri->dx12 * miny * TILESIZE * FIXED_ONE - 
-                tri->dy12 * minx * TILESIZE * FIXED_ONE);
+                tri->dx12 * miny * TILESIZE - 
+                tri->dy12 * minx * TILESIZE);
       int c2 = (tri->c2 + 
-                tri->dx23 * miny * TILESIZE * FIXED_ONE -
-                tri->dy23 * minx * TILESIZE * FIXED_ONE);
+                tri->dx23 * miny * TILESIZE -
+                tri->dy23 * minx * TILESIZE);
       int c3 = (tri->c3 +
-                tri->dx31 * miny * TILESIZE * FIXED_ONE -
-                tri->dy31 * minx * TILESIZE * FIXED_ONE);
+                tri->dx31 * miny * TILESIZE -
+                tri->dy31 * minx * TILESIZE);
 
-      int ei1 = tri->ei1 << (FIXED_ORDER + TILE_ORDER);
-      int ei2 = tri->ei2 << (FIXED_ORDER + TILE_ORDER);
-      int ei3 = tri->ei3 << (FIXED_ORDER + TILE_ORDER);
+      int ei1 = tri->ei1 << TILE_ORDER;
+      int ei2 = tri->ei2 << TILE_ORDER;
+      int ei3 = tri->ei3 << TILE_ORDER;
 
-      int eo1 = tri->eo1 << (FIXED_ORDER + TILE_ORDER);
-      int eo2 = tri->eo2 << (FIXED_ORDER + TILE_ORDER);
-      int eo3 = tri->eo3 << (FIXED_ORDER + TILE_ORDER);
+      int eo1 = tri->eo1 << TILE_ORDER;
+      int eo2 = tri->eo2 << TILE_ORDER;
+      int eo3 = tri->eo3 << TILE_ORDER;
 
-      int xstep1 = -(tri->dy12 << (FIXED_ORDER + TILE_ORDER));
-      int xstep2 = -(tri->dy23 << (FIXED_ORDER + TILE_ORDER));
-      int xstep3 = -(tri->dy31 << (FIXED_ORDER + TILE_ORDER));
+      int xstep1 = -(tri->dy12 << TILE_ORDER);
+      int xstep2 = -(tri->dy23 << TILE_ORDER);
+      int xstep3 = -(tri->dy31 << TILE_ORDER);
 
-      int ystep1 = tri->dx12 << (FIXED_ORDER + TILE_ORDER);
-      int ystep2 = tri->dx23 << (FIXED_ORDER + TILE_ORDER);
-      int ystep3 = tri->dx31 << (FIXED_ORDER + TILE_ORDER);
+      int ystep1 = tri->dx12 << TILE_ORDER;
+      int ystep2 = tri->dx23 << TILE_ORDER;
+      int ystep3 = tri->dx31 << TILE_ORDER;
       int x, y;
 
 
@@ -406,16 +414,16 @@ do_triangle_ccw(struct setup_context *setup,
 	 {
             assert(cx1 == 
                    tri->c1 + 
-                   tri->dx12 * y * TILESIZE * FIXED_ONE - 
-                   tri->dy12 * x * TILESIZE * FIXED_ONE);
+                   tri->dx12 * y * TILESIZE - 
+                   tri->dy12 * x * TILESIZE);
             assert(cx2 ==
                    tri->c2 + 
-                   tri->dx23 * y * TILESIZE * FIXED_ONE - 
-                   tri->dy23 * x * TILESIZE * FIXED_ONE);
+                   tri->dx23 * y * TILESIZE - 
+                   tri->dy23 * x * TILESIZE);
             assert(cx3 == 
                    tri->c3 +
-                   tri->dx31 * y * TILESIZE * FIXED_ONE -
-                   tri->dy31 * x * TILESIZE * FIXED_ONE);
+                   tri->dx31 * y * TILESIZE -
+                   tri->dy31 * x * TILESIZE);
 
 	    if (cx1 + eo1 < 0 || 
 		cx2 + eo2 < 0 ||




More information about the mesa-commit mailing list