Mesa (lp-binning): llvmpipe: get lp_setup_tri building

Keith Whitwell keithw at kemper.freedesktop.org
Fri Oct 9 11:20:18 UTC 2009


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

Author: Keith Whitwell <keithw at vmware.com>
Date:   Fri Oct  9 12:19:49 2009 +0100

llvmpipe: get lp_setup_tri building

---

 src/gallium/drivers/llvmpipe/lp_rast.h      |   14 ++++++++-
 src/gallium/drivers/llvmpipe/lp_rast_tri.c  |   37 ++++++++++++++++-----------
 src/gallium/drivers/llvmpipe/lp_setup.c     |    6 ++--
 src/gallium/drivers/llvmpipe/lp_setup_tri.c |   12 ++++----
 4 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h
index 44cb403..72f8975 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast.h
@@ -77,6 +77,11 @@ struct lp_rast_shader_inputs {
  * plus inputs to run the shader:
  */
 struct lp_rast_triangle {
+   int minx;
+   int maxx;
+   int miny;
+   int maxy;
+
    /* one-pixel sized trivial accept offsets for each plane */
    float ei1;                   
    float ei2;
@@ -97,8 +102,13 @@ struct lp_rast_triangle {
    float dx23;
    float dx31;
 
-   /* XXX: these are only used inside lp_setup_tri.c, don't really
-    * need to bin them:
+   /* edge function values at minx,miny ?? */
+   float c1;
+   float c2;
+   float c3;
+
+   /* XXX: this is only used inside lp_setup_tri.c, don't really
+    * need it here:
     */
    float oneoverarea;
 
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri.c b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
index efc635b..7110afb 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
@@ -158,21 +158,6 @@ void lp_rast_triangle( struct lp_rasterizer *rast,
                        const union lp_rast_cmd_arg arg )
 {
    const struct lp_rast_triangle *tri = arg.triangle;
-   int minx, maxx, miny, maxy;
-
-   /* Clamp to tile dimensions:
-    */
-   minx = MAX2(tri->maxx, rast->x);
-   miny = MAX2(tri->miny, rast->y);
-   maxx = MIN2(tri->maxx, rast->x + TILE_SIZE);
-   maxy = MIN2(tri->maxy, rast->y + TILE_SIZE);
-
-   if (miny == maxy ||
-       minx == maxx) {
-      debug_printf("%s: non-intersecting triangle in bin\n", __FUNCTION__);
-      //assert(0);
-      return;
-   }
 
    const int step = BLOCKSIZE;
 
@@ -191,11 +176,33 @@ void lp_rast_triangle( struct lp_rasterizer *rast,
    float ystep1 = step * tri->dx12;
    float ystep2 = step * tri->dx23;
    float ystep3 = step * tri->dx31;
+
+   /* Clamp to tile dimensions:
+    */
+   int minx = MAX2(tri->maxx, rast->x);
+   int miny = MAX2(tri->miny, rast->y);
+   int maxx = MIN2(tri->maxx, rast->x + TILE_SIZE);
+   int maxy = MIN2(tri->maxy, rast->y + TILE_SIZE);
+
    int x, y;
+   float x0, y0;
+   float c1, c2, c3;
+
+   if (miny == maxy || minx == maxx) {
+      debug_printf("%s: non-intersecting triangle in bin\n", __FUNCTION__);
+      return;
+   }
 
    minx &= ~(step-1);
    miny &= ~(step-1);
 
+   x0 = (float)minx;
+   y0 = (float)miny;
+
+   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;
+
    for (y = miny; y < maxy; y += step)
    {
       float cx1 = c1;
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index c0c294f..56bbee1 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -373,9 +373,9 @@ lp_setup_clear( struct setup_context *setup,
 
 
 void 
-lp_setup_set_tri_state( struct setup_context *setup,
-                        unsigned cull_mode,
-                        boolean ccw_is_frontface)
+lp_setup_set_triangle_state( struct setup_context *setup,
+                             unsigned cull_mode,
+                             boolean ccw_is_frontface)
 {
    setup->ccw_is_frontface = ccw_is_frontface;
    setup->cullmode = cull_mode;
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index f927f9d..5c40225 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -315,9 +315,9 @@ do_triangle_ccw(struct setup_context *setup,
    /* half-edge constants, will be interated over the whole
     * rendertarget.
     */
-   c1 = tri->dy12 * x1 - tri->dx12 * y1;
-   c2 = tri->dy23 * x2 - tri->dx23 * y2;
-   c3 = tri->dy31 * x3 - tri->dx31 * y3;
+   tri->c1 = tri->dy12 * x1 - tri->dx12 * y1;
+   tri->c2 = tri->dy23 * x2 - tri->dx23 * y2;
+   tri->c3 = tri->dy31 * x3 - tri->dx31 * y3;
 
    /* correct for top-left fill convention:
     */
@@ -351,9 +351,9 @@ do_triangle_ccw(struct setup_context *setup,
    minx &= ~(TILESIZE-1);		/* aligned blocks */
    miny &= ~(TILESIZE-1);		/* aligned blocks */
 
-   c1 += tri->dx12 * miny - tri->dy12 * minx;
-   c2 += tri->dx23 * miny - tri->dy23 * minx;
-   c3 += tri->dx31 * miny - tri->dy31 * minx;
+   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;
 
    /* Convert to tile coordinates:
     */




More information about the mesa-commit mailing list