llvmpipe: get lp_setup_tri building
authorKeith Whitwell <keithw@vmware.com>
Fri, 9 Oct 2009 11:19:49 +0000 (12:19 +0100)
committerKeith Whitwell <keithw@vmware.com>
Fri, 9 Oct 2009 11:19:49 +0000 (12:19 +0100)
src/gallium/drivers/llvmpipe/lp_rast.h
src/gallium/drivers/llvmpipe/lp_rast_tri.c
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_setup_tri.c

index 44cb4032dad3db83b0ba93c432dab7b81ef4c667..72f897503d690c4d7bd90359324134abff8c1c9b 100644 (file)
@@ -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;
 
index efc635bffea946f3905858615b555e149c52dfab..7110afb9d57b1a31007c34110c016535f2855b18 100644 (file)
@@ -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;
index c0c294fbe3f8fb9a1649ac279daa36c30895d5b7..56bbee1f7cbb9804992ac415b319d80ea337af46 100644 (file)
@@ -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;
index f927f9df9159d6455388aafb6fd3df90ef57534e..5c402259df0213645c6ace1db2265dad630dc087 100644 (file)
@@ -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:
     */