llvmpipe: build list of 4x4 blocks to be shaded
authorKeith Whitwell <keithw@vmware.com>
Tue, 20 Oct 2009 07:56:58 +0000 (08:56 +0100)
committerKeith Whitwell <keithw@vmware.com>
Tue, 20 Oct 2009 07:56:58 +0000 (08:56 +0100)
src/gallium/drivers/llvmpipe/lp_rast_tri.c

index 567e22316822e6dde0af7d8f7c65d4089e86a890..12ac840ef24c3075328a111209d3d433b9163f7e 100644 (file)
 
 #define BLOCKSIZE 4
 
-
+static struct {
+   int x;
+   int y;
+   unsigned mask;
+} blocks[256];
+static int nr_blocks;
 
 /* Render a 4x4 unmasked block:
  */
 static void block_full_4( struct lp_rasterizer *rast,
-                        const struct lp_rast_triangle *tri,
                         int x, int y )
 {
-   unsigned mask = ~0;
-
-   lp_rast_shade_quads(rast, &tri->inputs, x, y, mask);
+   blocks[nr_blocks].x = x;
+   blocks[nr_blocks].y = y;
+   blocks[nr_blocks].mask = ~0;
+   nr_blocks++;
 }
 
 
 static void block_full_16( struct lp_rasterizer *rast,
-                        const struct lp_rast_triangle *tri,
                         int x, int y )
 {
-   unsigned mask = ~0;
    unsigned ix, iy;
 
    for (iy = 0; iy < 16; iy+=4) 
       for (ix = 0; ix < 16; ix+=4) 
-        lp_rast_shade_quads(rast, &tri->inputs, x + ix, y + iy , mask);
+        block_full_4(rast, x + ix, y + iy);
 }
 
 
@@ -87,8 +90,12 @@ do_block_4( struct lp_rasterizer *rast,
    /* As we do trivial reject already, masks should rarely be all
     * zero:
     */
-   if (mask)
-      lp_rast_shade_quads(rast, &tri->inputs, x, y, mask );
+   if (mask) {
+      blocks[nr_blocks].x = x;
+      blocks[nr_blocks].y = y;
+      blocks[nr_blocks].mask = mask;
+      nr_blocks++;
+   }
 }
 
 static void
@@ -126,7 +133,7 @@ do_block_16( struct lp_rasterizer *rast,
                  cx2 + ei2 > 0 &&
                  cx3 + ei3 > 0)
         {
-           block_full_4(rast, tri, x+ix, y+iy); /* trivial accept */
+           block_full_4(rast, x+ix, y+iy); /* trivial accept */
         }
         else
         {
@@ -162,6 +169,7 @@ void lp_rast_triangle( struct lp_rasterizer *rast,
 
    debug_printf("%s\n", __FUNCTION__);
 
+   nr_blocks = 0;
 
    for (iy = 0; iy < 64; iy+=16) 
    {
@@ -180,7 +188,7 @@ void lp_rast_triangle( struct lp_rasterizer *rast,
                  cx2 + ei2 > 0 &&
                  cx3 + ei3 > 0)
         {
-           block_full_16(rast, tri, x+ix, y+iy); /* trivial accept */
+           block_full_16(rast, x+ix, y+iy); /* trivial accept */
         }
         else
         {
@@ -188,5 +196,11 @@ void lp_rast_triangle( struct lp_rasterizer *rast,
         }
       }
    }
+
+   for (i = 0; i < nr_blocks; i++) 
+      lp_rast_shade_quads(rast, &tri->inputs, 
+                         blocks[i].x,
+                         blocks[i].y,
+                         blocks[i].mask);
 }