llvmpipe: use union lp_cmd_rast_arg directly, rather than through a pointer

The union itself consists of pointers.  We don't need to be passing
pointer to pointers.
This commit is contained in:
Keith Whitwell 2009-10-09 11:29:01 +01:00
parent 415b271b51
commit 4cdd10cb4b
6 changed files with 98 additions and 67 deletions

View File

@ -87,9 +87,9 @@ void lp_rast_start_tile( struct lp_rasterizer *rast,
} }
void lp_rast_clear_color( 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] && if (clear_color[0] == clear_color[1] &&
clear_color[1] == clear_color[2] && 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, 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; unsigned i, j;
for (i = 0; i < TILE_SIZE; i++) for (i = 0; i < TILE_SIZE; i++)
for (j = 0; j < TILE_SIZE; j++) 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, 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 */ /* call u_tile func to load colors from surface */
} }
void lp_rast_load_zstencil( struct lp_rasterizer *rast, 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 */ /* 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: /* Within a tile:
*/ */
void lp_rast_set_state( struct lp_rasterizer *rast, 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, void lp_rast_shade_tile( struct lp_rasterizer *rast,
const union lp_rast_cmd_arg *arg, const union lp_rast_cmd_arg arg )
const struct lp_rast_shader_inputs *inputs )
{ {
const struct lp_rast_shader_inputs *inputs = arg.shade_tile;
const unsigned masks[4] = {~0, ~0, ~0, ~0}; const unsigned masks[4] = {~0, ~0, ~0, ~0};
unsigned x, y; unsigned x, y;

View File

@ -134,34 +134,70 @@ union lp_rast_cmd_arg {
const struct lp_rast_shader_inputs *shade_tile; const struct lp_rast_shader_inputs *shade_tile;
const struct lp_rast_triangle *triangle; const struct lp_rast_triangle *triangle;
const struct lp_rast_state *set_state; const struct lp_rast_state *set_state;
const uint8_t clear_color[4]; uint8_t clear_color[4];
unsigned clear_zstencil; 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: /* Binnable Commands:
*/ */
void lp_rast_clear_color( struct lp_rasterizer *, 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 *, 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 *, 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 *, 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 *, 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 *, 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 *, void lp_rast_shade_tile( struct lp_rasterizer *,
const union lp_rast_cmd_arg *, const union lp_rast_cmd_arg );
const struct lp_rast_shader_inputs *);
/* End of tile: /* End of tile:

View File

@ -155,9 +155,9 @@ do_block( struct lp_rasterizer *rast,
* for this triangle: * for this triangle:
*/ */
void lp_rast_triangle( struct lp_rasterizer *rast, 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; int minx, maxx, miny, maxy;
/* Clamp to tile dimensions: /* Clamp to tile dimensions:

View File

@ -143,7 +143,7 @@ static void reset_context( struct setup_context *setup )
*/ */
static void bin_everywhere( struct setup_context *setup, static void bin_everywhere( struct setup_context *setup,
lp_rast_cmd cmd, lp_rast_cmd cmd,
const union lp_rast_cmd_arg *arg ) const union lp_rast_cmd_arg arg )
{ {
unsigned i, j; unsigned i, j;
for (i = 0; i < setup->tiles_x; i++) 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) if (setup->clear.flags & PIPE_CLEAR_COLOR)
bin_everywhere( setup, bin_everywhere( setup,
lp_rast_clear_color, lp_rast_clear_color,
&setup->clear.color ); setup->clear.color );
else 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->fb.zsbuf) {
if (setup->clear.flags & PIPE_CLEAR_DEPTHSTENCIL) if (setup->clear.flags & PIPE_CLEAR_DEPTHSTENCIL)
bin_everywhere( setup, bin_everywhere( setup,
lp_rast_clear_zstencil, lp_rast_clear_zstencil,
&setup->clear.zstencil ); setup->clear.zstencil );
else 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 stencil,
unsigned flags ) 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) { if (setup->state == SETUP_ACTIVE) {
/* Add the clear to existing bins. In the unusual case where /* Add the clear to existing bins. In the unusual case where
* both color and depth-stencilare being cleared, we could * both color and depth-stencilare being cleared, we could
* discard the currently binned scene and start again, but I * discard the currently binned scene and start again, but I
* don't see that as being a common usage. * don't see that as being a common usage.
*/ */
if (flags & PIPE_CLEAR_COLOR) { if (flags & PIPE_CLEAR_COLOR)
union lp_rast_cmd_arg *arg = get_data( &setup->data, sizeof *arg ); bin_everywhere( setup,
lp_rast_clear_color,
setup->clear.color );
util_pack_color(color, if (setup->clear.flags & PIPE_CLEAR_DEPTHSTENCIL)
setup->fb.cbuf->format, bin_everywhere( setup,
&arg->clear_color ); lp_rast_clear_zstencil,
setup->clear.zstencil );
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 );
arg->clear_zstencil =
util_pack_z_stencil(setup->fb.zsbuf->format,
depth,
stencil);
bin_everywhere(setup, lp_rast_clear_zstencil, arg );
}
} }
else { else {
/* Put ourselves into the 'pre-clear' state, specifically to try /* 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 ); set_state( setup, SETUP_CLEARED );
setup->clear.flags |= flags; 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);
}
} }
} }

View File

@ -45,11 +45,11 @@
/* switch to a non-pointer value for this: /* 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 { struct cmd_block {
lp_rast_cmd cmd[CMD_BLOCK_MAX]; 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; unsigned count;
struct cmd_block *next; 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, static INLINE void bin_command( struct cmd_block_list *list,
lp_rast_cmd cmd, lp_rast_cmd cmd,
const union lp_rast_cmd_arg *arg ) union lp_rast_cmd_arg arg )
{ {
if (list->tail->count == CMD_BLOCK_MAX) { if (list->tail->count == CMD_BLOCK_MAX) {
lp_setup_new_cmd_block( list ); lp_setup_new_cmd_block( list );

View 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, /* 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: /* 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 else
{ {
@ -412,12 +416,15 @@ do_triangle_ccw(struct setup_context *setup,
cx3 + ei3 > 0) cx3 + ei3 > 0)
{ {
/* shade whole tile */ /* 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 else
{ {
/* shade partial tile */ /* 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: /* Iterate cx values across the region:
@ -481,7 +488,7 @@ static void triangle_nop( struct setup_context *setup,
void void
lp_setup_choose_triangle( struct setup_context *setup ) lp_setup_choose_triangle( struct setup_context *setup )
{ {
switch (setup->cull_mode) { switch (setup->cullmode) {
case PIPE_WINDING_NONE: case PIPE_WINDING_NONE:
setup->triangle = triangle_both; setup->triangle = triangle_both;
break; break;