llvmpipe: use union lp_cmd_rast_arg directly, rather than through a pointer
authorKeith Whitwell <keithw@vmware.com>
Fri, 9 Oct 2009 10:29:01 +0000 (11:29 +0100)
committerKeith Whitwell <keithw@vmware.com>
Fri, 9 Oct 2009 10:29:01 +0000 (11:29 +0100)
The union itself consists of pointers.  We don't need to be passing
pointer to pointers.

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_setup.c
src/gallium/drivers/llvmpipe/lp_setup_context.h
src/gallium/drivers/llvmpipe/lp_setup_tri.c

index 9825099c945d7a3a2c07de9bc9eff0484a9348b1..de15ddbb2e4b258348b940ea76024701c8637203 100644 (file)
@@ -87,9 +87,9 @@ void lp_rast_start_tile( struct lp_rasterizer *rast,
 }
 
 void lp_rast_clear_color( struct lp_rasterizer *rast,
-                          const union lp_rast_cmd_arg *arg )
+                          const union lp_rast_cmd_arg arg )
 {
-   const uint8_t *clear_color = arg->clear_color;
+   const uint8_t *clear_color = arg.clear_color;
    
    if (clear_color[0] == clear_color[1] &&
        clear_color[1] == clear_color[2] &&
@@ -106,25 +106,24 @@ void lp_rast_clear_color( struct lp_rasterizer *rast,
 }
 
 void lp_rast_clear_zstencil( struct lp_rasterizer *rast,
-                             const union lp_rast_cmd_arg *arg)
+                             const union lp_rast_cmd_arg arg)
 {
-   const unsigned clear_zstencil = arg->clear_zstencil;
    unsigned i, j;
    
    for (i = 0; i < TILE_SIZE; i++)
       for (j = 0; j < TILE_SIZE; j++)
-        rast->tile.depth[i*TILE_SIZE + j] = clear_zstencil;
+        rast->tile.depth[i*TILE_SIZE + j] = arg.clear_zstencil;
 }
 
 
 void lp_rast_load_color( struct lp_rasterizer *rast,
-                         const union lp_rast_cmd_arg *arg)
+                         const union lp_rast_cmd_arg arg)
 {
    /* call u_tile func to load colors from surface */
 }
 
 void lp_rast_load_zstencil( struct lp_rasterizer *rast,
-                            const union lp_rast_cmd_arg *arg )
+                            const union lp_rast_cmd_arg arg )
 {
    /* call u_tile func to load depth (and stencil?) from surface */
 }
@@ -132,17 +131,17 @@ void lp_rast_load_zstencil( struct lp_rasterizer *rast,
 /* Within a tile:
  */
 void lp_rast_set_state( struct lp_rasterizer *rast,
-                        const union lp_rast_cmd_arg *arg )
+                        const union lp_rast_cmd_arg arg )
 {
-   rast->shader_state = arg->set_state;
+   rast->shader_state = arg.set_state;
 
 }
 
 
 void lp_rast_shade_tile( struct lp_rasterizer *rast,
-                         const union lp_rast_cmd_arg *arg,
-                        const struct lp_rast_shader_inputs *inputs )
+                         const union lp_rast_cmd_arg arg )
 {
+   const struct lp_rast_shader_inputs *inputs = arg.shade_tile;
    const unsigned masks[4] = {~0, ~0, ~0, ~0};
    unsigned x, y;
 
index aa50fba5a604f02bdd780c58b58eca4f191ea31a..44cb4032dad3db83b0ba93c432dab7b81ef4c667 100644 (file)
@@ -134,34 +134,70 @@ union lp_rast_cmd_arg {
    const struct lp_rast_shader_inputs *shade_tile;
    const struct lp_rast_triangle *triangle;
    const struct lp_rast_state *set_state;
-   const uint8_t clear_color[4];
+   uint8_t clear_color[4];
    unsigned clear_zstencil;
 };
 
+/* Cast wrappers.  Hopefully these compile to noops!
+ */
+static INLINE const union lp_rast_cmd_arg
+lp_rast_arg_inputs( const struct lp_rast_shader_inputs *shade_tile )
+{
+   union lp_rast_cmd_arg arg;
+   arg.shade_tile = shade_tile;
+   return arg;
+}
+
+static INLINE const union lp_rast_cmd_arg
+lp_rast_arg_triangle( const struct lp_rast_triangle *triangle )
+{
+   union lp_rast_cmd_arg arg;
+   arg.triangle = triangle;
+   return arg;
+}
+
+static INLINE const union lp_rast_cmd_arg
+lp_rast_arg_state( const struct lp_rast_state *state )
+{
+   union lp_rast_cmd_arg arg;
+   arg.set_state = state;
+   return arg;
+}
+
+static INLINE const union lp_rast_cmd_arg
+lp_rast_arg_null( void )
+{
+   union lp_rast_cmd_arg arg;
+   arg.set_state = NULL;
+   return arg;
+}
+
+
+
+
 
 /* Binnable Commands:
  */
 void lp_rast_clear_color( struct lp_rasterizer *, 
-                          const union lp_rast_cmd_arg *);
+                          const union lp_rast_cmd_arg );
 
 void lp_rast_clear_zstencil( struct lp_rasterizer *, 
-                             const union lp_rast_cmd_arg *);
+                             const union lp_rast_cmd_arg );
 
 void lp_rast_load_color( struct lp_rasterizer *, 
-                         const union lp_rast_cmd_arg *);
+                         const union lp_rast_cmd_arg );
 
 void lp_rast_load_zstencil( struct lp_rasterizer *, 
-                            const union lp_rast_cmd_arg *);
+                            const union lp_rast_cmd_arg );
 
 void lp_rast_set_state( struct lp_rasterizer *, 
-                        const union lp_rast_cmd_arg );
+                        const union lp_rast_cmd_arg );
 
 void lp_rast_triangle( struct lp_rasterizer *, 
-                       const union lp_rast_cmd_arg );
+                       const union lp_rast_cmd_arg );
 
 void lp_rast_shade_tile( struct lp_rasterizer *,
-                         const union lp_rast_cmd_arg *,
-                         const struct lp_rast_shader_inputs *);
+                         const union lp_rast_cmd_arg );
 
 
 /* End of tile:
index 8cd3fcc360bb3f9167e9c111796d9f17fbd97d81..efc635bffea946f3905858615b555e149c52dfab 100644 (file)
@@ -155,9 +155,9 @@ do_block( struct lp_rasterizer *rast,
  * for this triangle:
  */
 void lp_rast_triangle( struct lp_rasterizer *rast,
-                       const union lp_rast_cmd_arg *arg )
+                       const union lp_rast_cmd_arg arg )
 {
-   const struct lp_rast_triangle *tri = arg->triangle;
+   const struct lp_rast_triangle *tri = arg.triangle;
    int minx, maxx, miny, maxy;
 
    /* Clamp to tile dimensions:
index 13b40f14942a83da1af66e1a94fd1d769ff3e531..c0c294fbe3f8fb9a1649ac279daa36c30895d5b7 100644 (file)
@@ -143,7 +143,7 @@ static void reset_context( struct setup_context *setup )
  */
 static void bin_everywhere( struct setup_context *setup,
                             lp_rast_cmd cmd,
-                            const union lp_rast_cmd_arg *arg )
+                            const union lp_rast_cmd_arg arg )
 {
    unsigned i, j;
    for (i = 0; i < setup->tiles_x; i++)
@@ -232,18 +232,18 @@ begin_binning( struct setup_context *setup )
       if (setup->clear.flags & PIPE_CLEAR_COLOR)
          bin_everywhere( setup, 
                          lp_rast_clear_color, 
-                         &setup->clear.color );
+                         setup->clear.color );
       else
-         bin_everywhere( setup, lp_rast_load_color, NULL );
+         bin_everywhere( setup, lp_rast_load_color, lp_rast_arg_null() );
    }
 
    if (setup->fb.zsbuf) {
       if (setup->clear.flags & PIPE_CLEAR_DEPTHSTENCIL)
          bin_everywhere( setup, 
                          lp_rast_clear_zstencil, 
-                         &setup->clear.zstencil );
+                         setup->clear.zstencil );
       else
-         bin_everywhere( setup, lp_rast_load_zstencil, NULL );
+         bin_everywhere( setup, lp_rast_load_zstencil, lp_rast_arg_null() );
    }
 }
 
@@ -329,32 +329,34 @@ lp_setup_clear( struct setup_context *setup,
                 unsigned stencil,
                 unsigned flags )
 {
+   if (flags & PIPE_CLEAR_COLOR) {
+      util_pack_color(color, 
+                      setup->fb.cbuf->format, 
+                      &setup->clear.color.clear_color );
+   }
+
+   if (flags & PIPE_CLEAR_DEPTHSTENCIL) {
+      setup->clear.zstencil.clear_zstencil = 
+         util_pack_z_stencil(setup->fb.zsbuf->format, 
+                             depth,
+                             stencil);
+   }
+
    if (setup->state == SETUP_ACTIVE) {
       /* Add the clear to existing bins.  In the unusual case where
        * both color and depth-stencilare being cleared, we could
        * discard the currently binned scene and start again, but I
        * don't see that as being a common usage.
        */
-      if (flags & PIPE_CLEAR_COLOR) {
-        union lp_rast_cmd_arg *arg = get_data( &setup->data, sizeof *arg );
-
-         util_pack_color(color, 
-                         setup->fb.cbuf->format, 
-                         &arg->clear_color );
-
-         bin_everywhere(setup, lp_rast_clear_color, arg );
-      }
-
-      if (flags & PIPE_CLEAR_DEPTHSTENCIL) {
-        union lp_rast_cmd_arg *arg = get_data( &setup->data, sizeof *arg );
+      if (flags & PIPE_CLEAR_COLOR)
+         bin_everywhere( setup, 
+                         lp_rast_clear_color, 
+                         setup->clear.color );
 
-         arg->clear_zstencil = 
-            util_pack_z_stencil(setup->fb.zsbuf->format, 
-                                depth,
-                                stencil);
-         
-         bin_everywhere(setup, lp_rast_clear_zstencil, arg );
-      }
+      if (setup->clear.flags & PIPE_CLEAR_DEPTHSTENCIL)
+         bin_everywhere( setup, 
+                         lp_rast_clear_zstencil, 
+                         setup->clear.zstencil );
    }
    else {
       /* Put ourselves into the 'pre-clear' state, specifically to try
@@ -365,19 +367,6 @@ lp_setup_clear( struct setup_context *setup,
       set_state( setup, SETUP_CLEARED );
 
       setup->clear.flags |= flags;
-
-      if (flags & PIPE_CLEAR_COLOR) {
-         util_pack_color(color, 
-                         setup->fb.cbuf->format, 
-                         &setup->clear.color.clear_color );
-      }
-
-      if (flags & PIPE_CLEAR_DEPTHSTENCIL) {
-         setup->clear.zstencil.clear_zstencil = 
-            util_pack_z_stencil(setup->fb.zsbuf->format, 
-                                depth,
-                                stencil);
-      }
    }
 }
 
index 9411f14cfbb232e74dc2849bb81c369750be4d0d..b29fec8ef059811337c5658864fee1cc8ea8c432 100644 (file)
 
 /* switch to a non-pointer value for this:
  */
-typedef void (*lp_rast_cmd)( struct lp_rasterizer *, const union lp_rast_cmd_arg );
+typedef void (*lp_rast_cmd)( struct lp_rasterizer *, const union lp_rast_cmd_arg );
 
 struct cmd_block {
    lp_rast_cmd cmd[CMD_BLOCK_MAX];
-   const union lp_rast_cmd_arg *arg[CMD_BLOCK_MAX];
+   union lp_rast_cmd_arg arg[CMD_BLOCK_MAX];
    unsigned count;
    struct cmd_block *next;
 };
@@ -152,7 +152,7 @@ static INLINE void *get_data( struct data_block_list *list,
  */
 static INLINE void bin_command( struct cmd_block_list *list,
                                 lp_rast_cmd cmd,
-                                const union lp_rast_cmd_arg *arg )
+                                union lp_rast_cmd_arg arg )
 {
    if (list->tail->count == CMD_BLOCK_MAX) {
       lp_setup_new_cmd_block( list );
index d3b8ce94345a040a69242cf6b625f41ff005da69..f927f9df9159d6455388aafb6fd3df90ef57534e 100644 (file)
@@ -230,7 +230,10 @@ static inline float subpixel_snap( float a )
 }
 
 
-
+static INLINE void bin_triangle( struct cmd_block_list *list,
+                                 const struct lp_rast_triangle arg )
+{
+}
 
 
 /* to avoid having to allocate power-of-four, square render targets,
@@ -363,7 +366,8 @@ do_triangle_ccw(struct setup_context *setup,
    {
       /* Triangle is contained in a single tile:
        */
-      bin_command( &setup->tile[minx][miny], lp_rast_triangle, tri );
+      bin_command( &setup->tile[minx][miny], lp_rast_triangle, 
+                   lp_rast_arg_triangle(tri) );
    }
    else 
    {
@@ -412,12 +416,15 @@ do_triangle_ccw(struct setup_context *setup,
                     cx3 + ei3 > 0) 
            {
                /* shade whole tile */
-               bin_command( &setup->tile[x][y], lp_rast_shade_tile, &tri->inputs );
+               bin_command( &setup->tile[x][y], lp_rast_shade_tile,
+                            lp_rast_arg_inputs(&tri->inputs) );
            }
            else 
            {
                /* shade partial tile */
-              bin_command( &setup->tile[x][y], lp_rast_triangle, tri );
+              bin_command( &setup->tile[x][y], 
+                            lp_rast_triangle, 
+                            lp_rast_arg_triangle(tri) );
            }
 
            /* Iterate cx values across the region:
@@ -481,7 +488,7 @@ static void triangle_nop( struct setup_context *setup,
 void 
 lp_setup_choose_triangle( struct setup_context *setup )
 {
-   switch (setup->cull_mode) {
+   switch (setup->cullmode) {
    case PIPE_WINDING_NONE:
       setup->triangle = triangle_both;
       break;