llvmpipe: more lp_rasterizer_task parameter passing
authorBrian Paul <brianp@vmware.com>
Wed, 24 Feb 2010 20:53:30 +0000 (13:53 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 24 Feb 2010 20:54:25 +0000 (13:54 -0700)
src/gallium/drivers/llvmpipe/lp_rast.c
src/gallium/drivers/llvmpipe/lp_rast.h
src/gallium/drivers/llvmpipe/lp_rast_tri.c
src/gallium/drivers/llvmpipe/lp_scene.h

index 159ef0d55d7094a95fa64bb29a909af93fd7530a..07817efd748c25319b3a6728d72bb09f9e9d54c1 100644 (file)
@@ -156,14 +156,13 @@ lp_rast_end( struct lp_rasterizer *rast )
  * \param y  window Y position of the tile, in pixels
  */
 static void
-lp_rast_start_tile( struct lp_rasterizer *rast,
-                    unsigned thread_index,
-                    unsigned x, unsigned y )
+lp_rast_start_tile(struct lp_rasterizer_task *task,
+                   unsigned x, unsigned y)
 {
    LP_DBG(DEBUG_RAST, "%s %d,%d\n", __FUNCTION__, x, y);
 
-   rast->tasks[thread_index].x = x;
-   rast->tasks[thread_index].y = y;
+   task->x = x;
+   task->y = y;
 }
 
 
@@ -171,12 +170,13 @@ lp_rast_start_tile( struct lp_rasterizer *rast,
  * Clear the rasterizer's current color tile.
  * This is a bin command called during bin processing.
  */
-void lp_rast_clear_color( struct lp_rasterizer *rast,
-                          unsigned thread_index,
-                          const union lp_rast_cmd_arg arg )
+void
+lp_rast_clear_color(struct lp_rasterizer_task *task,
+                    const union lp_rast_cmd_arg arg)
 {
+   struct lp_rasterizer *rast = task->rast;
    const uint8_t *clear_color = arg.clear_color;
-   uint8_t **color_tile = rast->tasks[thread_index].tile.color;
+   uint8_t **color_tile = task->tile.color;
    unsigned i;
 
    LP_DBG(DEBUG_RAST, "%s 0x%x,0x%x,0x%x,0x%x\n", __FUNCTION__, 
@@ -225,11 +225,11 @@ void lp_rast_clear_color( struct lp_rasterizer *rast,
  * Clear the rasterizer's current z/stencil tile.
  * This is a bin command called during bin processing.
  */
-void lp_rast_clear_zstencil( struct lp_rasterizer *rast,
-                             unsigned thread_index,
-                             const union lp_rast_cmd_arg arg)
+void
+lp_rast_clear_zstencil(struct lp_rasterizer_task *task,
+                       const union lp_rast_cmd_arg arg)
 {
-   struct lp_rasterizer_task *task = &rast->tasks[thread_index];
+   struct lp_rasterizer *rast = task->rast;
    const unsigned tile_x = task->x;
    const unsigned tile_y = task->y;
    const unsigned height = TILE_SIZE/TILE_VECTOR_HEIGHT;
@@ -288,13 +288,12 @@ void lp_rast_clear_zstencil( struct lp_rasterizer *rast,
  * Load tile color from the framebuffer surface.
  * This is a bin command called during bin processing.
  */
-void lp_rast_load_color( struct lp_rasterizer *rast,
-                         unsigned thread_index,
-                         const union lp_rast_cmd_arg arg)
+void
+lp_rast_load_color(struct lp_rasterizer_task *task,
+                   const union lp_rast_cmd_arg arg)
 {
-   struct lp_rasterizer_task *task = &rast->tasks[thread_index];
-   const unsigned x = task->x;
-   const unsigned y = task->y;
+   struct lp_rasterizer *rast = task->rast;
+   const unsigned x = task->x, y = task->y;
    unsigned i;
 
    LP_DBG(DEBUG_RAST, "%s at %u, %u\n", __FUNCTION__, x, y);
@@ -304,10 +303,7 @@ void lp_rast_load_color( struct lp_rasterizer *rast,
       int w = TILE_SIZE;
       int h = TILE_SIZE;
 
-      if (x >= transfer->width)
-        continue;
-
-      if (y >= transfer->height)
+      if (x >= transfer->width || y >= transfer->height)
         continue;
 
       assert(w >= 0);
@@ -327,16 +323,16 @@ void lp_rast_load_color( struct lp_rasterizer *rast,
 }
 
 
-void lp_rast_set_state( struct lp_rasterizer *rast,
-                        unsigned thread_index,
-                        const union lp_rast_cmd_arg arg )
+void
+lp_rast_set_state(struct lp_rasterizer_task *task,
+                  const union lp_rast_cmd_arg arg)
 {
    const struct lp_rast_state *state = arg.set_state;
 
    LP_DBG(DEBUG_RAST, "%s %p\n", __FUNCTION__, (void *) state);
 
    /* just set the current state pointer for this rasterizer */
-   rast->tasks[thread_index].current_state = state;
+   task->current_state = state;
 }
 
 
@@ -346,16 +342,15 @@ void lp_rast_set_state( struct lp_rasterizer *rast,
  * completely contained inside a triangle.
  * This is a bin command called during bin processing.
  */
-void lp_rast_shade_tile( struct lp_rasterizer *rast,
-                         unsigned thread_index,
-                         const union lp_rast_cmd_arg arg )
+void
+lp_rast_shade_tile(struct lp_rasterizer_task *task,
+                   const union lp_rast_cmd_arg arg)
 {
-   struct lp_rasterizer_task *task = &rast->tasks[thread_index];
+   struct lp_rasterizer *rast = task->rast;
    const struct lp_rast_state *state = task->current_state;
    struct lp_rast_tile *tile = &task->tile;
    const struct lp_rast_shader_inputs *inputs = arg.shade_tile;
-   const unsigned tile_x = task->x;
-   const unsigned tile_y = task->y;
+   const unsigned tile_x = task->x, tile_y = task->y;
    unsigned x, y;
 
    LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
@@ -514,12 +509,11 @@ outline_subtiles(uint8_t *tile)
 /**
  * Write the rasterizer's color tile to the framebuffer.
  */
-static void lp_rast_store_color( struct lp_rasterizer *rast,
-                                 unsigned thread_index)
+static void
+lp_rast_store_color(struct lp_rasterizer_task *task)
 {
-   struct lp_rasterizer_task *task = &rast->tasks[thread_index];
-   const unsigned x = task->x;
-   const unsigned y = task->y;
+   struct lp_rasterizer *rast = task->rast;
+   const unsigned x = task->x, y = task->y;
    unsigned i;
 
    for (i = 0; i < rast->state.fb.nr_cbufs; i++) {
@@ -534,7 +528,7 @@ static void lp_rast_store_color( struct lp_rasterizer *rast,
         continue;
 
       LP_DBG(DEBUG_RAST, "%s [%u] %d,%d %dx%d\n", __FUNCTION__,
-            thread_index, x, y, w, h);
+            task->thread_index, x, y, w, h);
 
       if (LP_DEBUG & DEBUG_SHOW_SUBTILES)
          outline_subtiles(task->tile.color[i]);
@@ -557,13 +551,14 @@ static void lp_rast_store_color( struct lp_rasterizer *rast,
  * Write the rasterizer's tiles to the framebuffer.
  */
 static void
-lp_rast_end_tile( struct lp_rasterizer *rast,
-                  unsigned thread_index )
+lp_rast_end_tile(struct lp_rasterizer_task *task)
 {
+   struct lp_rasterizer *rast = task->rast;
+
    LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
 
    if (rast->state.write_color)
-      lp_rast_store_color(rast, thread_index);
+      lp_rast_store_color(task);
 }
 
 
@@ -571,9 +566,9 @@ lp_rast_end_tile( struct lp_rasterizer *rast,
  * Signal on a fence.  This is called during bin execution/rasterization.
  * Called per thread.
  */
-void lp_rast_fence( struct lp_rasterizer *rast,
-                    unsigned thread_index,
-                    const union lp_rast_cmd_arg arg )
+void
+lp_rast_fence(struct lp_rasterizer_task *task,
+              const union lp_rast_cmd_arg arg)
 {
    struct lp_fence *fence = arg.fence;
 
@@ -617,25 +612,24 @@ release_scene( struct lp_rasterizer *rast,
  * Called per thread.
  */
 static void
-rasterize_bin( struct lp_rasterizer *rast,
-               unsigned thread_index,
-               const struct cmd_bin *bin,
-               int x, int y)
+rasterize_bin(struct lp_rasterizer_task *task,
+              const struct cmd_bin *bin,
+              int x, int y)
 {
    const struct cmd_block_list *commands = &bin->commands;
    struct cmd_block *block;
    unsigned k;
 
-   lp_rast_start_tile( rast, thread_index, x, y );
+   lp_rast_start_tile( task, x, y );
 
    /* simply execute each of the commands in the block list */
    for (block = commands->head; block; block = block->next) {
       for (k = 0; k < block->count; k++) {
-         block->cmd[k]( rast, thread_index, block->arg[k] );
+         block->cmd[k]( task, block->arg[k] );
       }
    }
 
-   lp_rast_end_tile( rast, thread_index );
+   lp_rast_end_tile( task );
 }
 
 
@@ -719,10 +713,9 @@ is_empty_bin( const struct cmd_bin *bin )
  * Called per thread.
  */
 static void
-rasterize_scene( struct lp_rasterizer *rast,
-                unsigned thread_index,
+rasterize_scene(struct lp_rasterizer_task *task,
                 struct lp_scene *scene,
-                bool write_depth )
+                bool write_depth)
 {
    /* loop over scene bins, rasterize each */
 #if 0
@@ -730,9 +723,8 @@ rasterize_scene( struct lp_rasterizer *rast,
       unsigned i, j;
       for (i = 0; i < scene->tiles_x; i++) {
          for (j = 0; j < scene->tiles_y; j++) {
-            struct cmd_bin *bin = lp_get_bin(scene, i, j);
-            rasterize_bin( rast, thread_index,
-                           bin, i * TILE_SIZE, j * TILE_SIZE );
+            struct cmd_bin *bin = lp_scene_get_bin(scene, i, j);
+            rasterize_bin(task, bin, i * TILE_SIZE, j * TILE_SIZE);
          }
       }
    }
@@ -744,7 +736,7 @@ rasterize_scene( struct lp_rasterizer *rast,
       assert(scene);
       while ((bin = lp_scene_bin_iter_next(scene, &x, &y))) {
          if (!is_empty_bin( bin ))
-            rasterize_bin( rast, thread_index, bin, x * TILE_SIZE, y * TILE_SIZE);
+            rasterize_bin(task, bin, x * TILE_SIZE, y * TILE_SIZE);
       }
    }
 #endif
@@ -788,7 +780,7 @@ lp_rasterize_scene( struct lp_rasterizer *rast,
                      fb->zsbuf != NULL && write_depth );
 
       lp_scene_bin_iter_begin( scene );
-      rasterize_scene( rast, 0, scene, write_depth );
+      rasterize_scene( &rast->tasks[0], scene, write_depth );
 
       release_scene( rast, scene );
 
@@ -862,10 +854,9 @@ static PIPE_THREAD_ROUTINE( thread_func, init_data )
       /* do work */
       if (debug)
          debug_printf("thread %d doing work\n", task->thread_index);
-      rasterize_scene(rast, 
-                    task->thread_index,
-                     rast->curr_scene, 
-                    rast->curr_scene->write_depth);
+      rasterize_scene(task,
+                      rast->curr_scene, 
+                      rast->curr_scene->write_depth);
       
       /* wait for all threads to finish with this scene */
       pipe_barrier_wait( &rast->barrier );
index 875f18e0c0c2fd8c9d571babf9feeb3630d6825a..1ed27001914f8148e4cfc840e711e2bd66467774 100644 (file)
@@ -53,6 +53,9 @@ struct pipe_screen;
 #define FIXED_ONE (1<<FIXED_ORDER)
 
 
+struct lp_rasterizer_task;
+
+
 /**
  * Rasterization state.
  * Objects of this type are put into the shared data bin and pointed
@@ -201,32 +204,25 @@ lp_rast_arg_null( void )
  * the bins are executed.
  */
 
-void lp_rast_clear_color( struct lp_rasterizer *, 
-                          unsigned thread_index,
+void lp_rast_clear_color( struct lp_rasterizer_task *, 
                           const union lp_rast_cmd_arg );
 
-void lp_rast_clear_zstencil( struct lp_rasterizer *, 
-                             unsigned thread_index,
+void lp_rast_clear_zstencil( struct lp_rasterizer_task *, 
                              const union lp_rast_cmd_arg );
 
-void lp_rast_load_color( struct lp_rasterizer *, 
-                         unsigned thread_index,
+void lp_rast_load_color( struct lp_rasterizer_task *, 
                          const union lp_rast_cmd_arg );
 
-void lp_rast_set_state( struct lp_rasterizer *, 
-                        unsigned thread_index,
+void lp_rast_set_state( struct lp_rasterizer_task *, 
                         const union lp_rast_cmd_arg );
 
-void lp_rast_triangle( struct lp_rasterizer *, 
-                       unsigned thread_index,
+void lp_rast_triangle( struct lp_rasterizer_task *, 
                        const union lp_rast_cmd_arg );
 
-void lp_rast_shade_tile( struct lp_rasterizer *,
-                         unsigned thread_index,
+void lp_rast_shade_tile( struct lp_rasterizer_task *,
                          const union lp_rast_cmd_arg );
 
-void lp_rast_fence( struct lp_rasterizer *,
-                    unsigned thread_index,
+void lp_rast_fence( struct lp_rasterizer_task *,
                     const union lp_rast_cmd_arg );
 
 #endif
index 90325aedb898eac7e88059bca9ba69e2ceca81b9..a5f0d14c95dfd22f9f3a836ec8353501c166497f 100644 (file)
@@ -89,11 +89,11 @@ static const int pos_table16[16][2] = {
  * Shade all pixels in a 4x4 block.
  */
 static void
-block_full_4( struct lp_rasterizer_task *rast_task,
-              const struct lp_rast_triangle *tri,
-              int x, int y )
+block_full_4(struct lp_rasterizer_task *task,
+             const struct lp_rast_triangle *tri,
+             int x, int y)
 {
-   lp_rast_shade_quads_all(rast_task, &tri->inputs, x, y);
+   lp_rast_shade_quads_all(task, &tri->inputs, x, y);
 }
 
 
@@ -101,16 +101,16 @@ block_full_4( struct lp_rasterizer_task *rast_task,
  * Shade all pixels in a 16x16 block.
  */
 static void
-block_full_16( struct lp_rasterizer_task *rast_task,
-               const struct lp_rast_triangle *tri,
-               int x, int y )
+block_full_16(struct lp_rasterizer_task *task,
+              const struct lp_rast_triangle *tri,
+              int x, int y)
 {
    unsigned ix, iy;
    assert(x % 16 == 0);
    assert(y % 16 == 0);
    for (iy = 0; iy < 16; iy += 4)
       for (ix = 0; ix < 16; ix += 4)
-        block_full_4(rast_task, tri, x + ix, y + iy);
+        block_full_4(task, tri, x + ix, y + iy);
 }
 
 
@@ -120,20 +120,15 @@ block_full_16( struct lp_rasterizer_task *rast_task,
  * will be done as part of the fragment shader.
  */
 static void
-do_block_4( struct lp_rasterizer_task *rast_task,
-           const struct lp_rast_triangle *tri,
-           int x, int y,
-           int c1,
-           int c2,
-           int c3 )
+do_block_4(struct lp_rasterizer_task *task,
+           const struct lp_rast_triangle *tri,
+           int x, int y,
+           int c1, int c2, int c3)
 {
    assert(x >= 0);
    assert(y >= 0);
 
-   lp_rast_shade_quads(rast_task,
-                       &tri->inputs, 
-                       x, y,
-                       -c1, -c2, -c3);
+   lp_rast_shade_quads(task, &tri->inputs, x, y, -c1, -c2, -c3);
 }
 
 
@@ -142,12 +137,10 @@ do_block_4( struct lp_rasterizer_task *rast_task,
  * of the triangle's bounds.
  */
 static void
-do_block_16( struct lp_rasterizer_task *rast_task,
-             const struct lp_rast_triangle *tri,
-             int x, int y,
-             int c0,
-             int c1,
-             int c2 )
+do_block_16(struct lp_rasterizer_task *task,
+            const struct lp_rast_triangle *tri,
+            int x, int y,
+            int c0, int c1, int c2)
 {
    unsigned mask = 0;
    int eo[3];
@@ -194,7 +187,7 @@ do_block_16( struct lp_rasterizer_task *rast_task,
        * the triangle.  It's a little faster to do it in the jit code.
        */
       LP_COUNT(nr_non_empty_4);
-      do_block_4(rast_task, tri, px, py, cx1, cx2, cx3);
+      do_block_4(task, tri, px, py, cx1, cx2, cx3);
    }
 }
 
@@ -204,15 +197,11 @@ do_block_16( struct lp_rasterizer_task *rast_task,
  * for this triangle.
  */
 void
-lp_rast_triangle( struct lp_rasterizer *rast,
-                  unsigned thread_index,
-                  const union lp_rast_cmd_arg arg )
+lp_rast_triangle(struct lp_rasterizer_task *task,
+                 const union lp_rast_cmd_arg arg)
 {
-   struct lp_rasterizer_task *rast_task = &rast->tasks[thread_index];
    const struct lp_rast_triangle *tri = arg.triangle;
-
-   int x = rast_task->x;
-   int y = rast_task->y;
+   const int x = task->x, y = task->y;
    int ei[3], eo[3], c[3];
    unsigned outmask, inmask, partial_mask;
    unsigned i, j;
@@ -273,7 +262,7 @@ lp_rast_triangle( struct lp_rasterizer *rast,
       partial_mask &= ~(1 << i);
 
       LP_COUNT(nr_partially_covered_16);
-      do_block_16(rast_task, tri, px, py, cx1, cx2, cx3);
+      do_block_16(task, tri, px, py, cx1, cx2, cx3);
    }
 
    /* Iterate over fulls: 
@@ -286,6 +275,6 @@ lp_rast_triangle( struct lp_rasterizer *rast,
       inmask &= ~(1 << i);
 
       LP_COUNT(nr_fully_covered_16);
-      block_full_16(rast_task, tri, px, py);
+      block_full_16(task, tri, px, py);
    }
 }
index fb478cc2eb58ea50b678731836381309797445f3..8d725cd4375a7d40ec1698c17ffa13354a653bb1 100644 (file)
@@ -56,8 +56,7 @@
 
 /* switch to a non-pointer value for this:
  */
-typedef void (*lp_rast_cmd)( struct lp_rasterizer *,
-                             unsigned thread_index,
+typedef void (*lp_rast_cmd)( struct lp_rasterizer_task *,
                              const union lp_rast_cmd_arg );
 
 struct cmd_block {