mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 04:20:18 +01:00
llvmpipe: still more bin code reorganization
Move tiles_x,y fields from setup state into bin state. Move more bin-adding commands into lp_bin.[ch].
This commit is contained in:
parent
2c8d5c66ce
commit
8a23105fa0
6 changed files with 130 additions and 102 deletions
|
|
@ -45,14 +45,14 @@ lp_init_bins(struct lp_bins *bins)
|
|||
|
||||
|
||||
void
|
||||
lp_reset_bins(struct lp_bins *bins, unsigned tiles_x, unsigned tiles_y)
|
||||
lp_reset_bins(struct lp_bins *bins )
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
/* Free all but last binner command lists:
|
||||
*/
|
||||
for (i = 0; i < tiles_x; i++) {
|
||||
for (j = 0; j < tiles_y; j++) {
|
||||
for (i = 0; i < bins->tiles_x; i++) {
|
||||
for (j = 0; j < bins->tiles_y; j++) {
|
||||
struct cmd_bin *bin = lp_get_bin(bins, i, j);
|
||||
struct cmd_block_list *list = &bin->commands;
|
||||
struct cmd_block *block;
|
||||
|
|
@ -107,6 +107,14 @@ lp_free_bin_data(struct lp_bins *bins)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
lp_bin_set_num_bins( struct lp_bins *bins,
|
||||
unsigned tiles_x, unsigned tiles_y )
|
||||
{
|
||||
bins->tiles_x = tiles_x;
|
||||
bins->tiles_y = tiles_y;
|
||||
}
|
||||
|
||||
void
|
||||
lp_bin_new_cmd_block( struct cmd_block_list *list )
|
||||
{
|
||||
|
|
@ -127,3 +135,59 @@ lp_bin_new_data_block( struct data_block_list *list )
|
|||
block->next = NULL;
|
||||
block->used = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return last command in the bin
|
||||
*/
|
||||
static lp_rast_cmd
|
||||
lp_get_last_command( const struct cmd_bin *bin )
|
||||
{
|
||||
const struct cmd_block *tail = bin->commands.tail;
|
||||
const unsigned i = tail->count;
|
||||
if (i > 0)
|
||||
return tail->cmd[i - 1];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace the arg of the last command in the bin.
|
||||
*/
|
||||
static void
|
||||
lp_replace_last_command_arg( struct cmd_bin *bin,
|
||||
const union lp_rast_cmd_arg arg )
|
||||
{
|
||||
struct cmd_block *tail = bin->commands.tail;
|
||||
const unsigned i = tail->count;
|
||||
assert(i > 0);
|
||||
tail->arg[i - 1] = arg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Put a state-change command into all bins.
|
||||
* If we find that the last command in a bin was also a state-change
|
||||
* command, we can simply replace that one with the new one.
|
||||
*/
|
||||
void
|
||||
lp_bin_state_command( struct lp_bins *bins,
|
||||
lp_rast_cmd cmd,
|
||||
const union lp_rast_cmd_arg arg )
|
||||
{
|
||||
unsigned i, j;
|
||||
for (i = 0; i < bins->tiles_x; i++) {
|
||||
for (j = 0; j < bins->tiles_y; j++) {
|
||||
struct cmd_bin *bin = lp_get_bin(bins, i, j);
|
||||
lp_rast_cmd last_cmd = lp_get_last_command(bin);
|
||||
if (last_cmd == cmd) {
|
||||
lp_replace_last_command_arg(bin, arg);
|
||||
}
|
||||
else {
|
||||
lp_bin_command( bins, i, j, cmd, arg );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,16 +104,26 @@ struct data_block_list {
|
|||
struct lp_bins {
|
||||
struct cmd_bin tile[TILES_X][TILES_Y];
|
||||
struct data_block_list data;
|
||||
|
||||
/**
|
||||
* Number of active tiles in each dimension.
|
||||
* This basically the framebuffer size divided by tile size
|
||||
*/
|
||||
unsigned tiles_x, tiles_y;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void lp_init_bins(struct lp_bins *bins);
|
||||
|
||||
void lp_reset_bins(struct lp_bins *bins, unsigned tiles_x, unsigned tiles_y);
|
||||
void lp_reset_bins(struct lp_bins *bins );
|
||||
|
||||
void lp_free_bin_data(struct lp_bins *bins);
|
||||
|
||||
void
|
||||
lp_bin_set_num_bins( struct lp_bins *bins,
|
||||
unsigned tiles_x, unsigned tiles_y );
|
||||
|
||||
void lp_bin_new_data_block( struct data_block_list *list );
|
||||
|
||||
void lp_bin_new_cmd_block( struct cmd_block_list *list );
|
||||
|
|
@ -209,4 +219,24 @@ lp_bin_command( struct lp_bins *bins,
|
|||
}
|
||||
|
||||
|
||||
/* Add a command to all active bins.
|
||||
*/
|
||||
static INLINE void
|
||||
lp_bin_everywhere( struct lp_bins *bins,
|
||||
lp_rast_cmd cmd,
|
||||
const union lp_rast_cmd_arg arg )
|
||||
{
|
||||
unsigned i, j;
|
||||
for (i = 0; i < bins->tiles_x; i++)
|
||||
for (j = 0; j < bins->tiles_y; j++)
|
||||
lp_bin_command( bins, i, j, cmd, arg );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
lp_bin_state_command( struct lp_bins *bins,
|
||||
lp_rast_cmd cmd,
|
||||
const union lp_rast_cmd_arg arg );
|
||||
|
||||
|
||||
#endif /* LP_BIN_H */
|
||||
|
|
|
|||
|
|
@ -502,7 +502,6 @@ rasterize_bin( struct lp_rasterizer *rast,
|
|||
void
|
||||
lp_rasterize_bins( struct lp_rasterizer *rast,
|
||||
struct lp_bins *bins,
|
||||
unsigned tiles_x, unsigned tiles_y,
|
||||
const struct pipe_framebuffer_state *fb,
|
||||
bool write_depth )
|
||||
{
|
||||
|
|
@ -519,8 +518,8 @@ lp_rasterize_bins( struct lp_rasterizer *rast,
|
|||
fb->height );
|
||||
|
||||
/* loop over tile bins, rasterize each */
|
||||
for (i = 0; i < tiles_x; i++) {
|
||||
for (j = 0; j < tiles_y; j++) {
|
||||
for (i = 0; i < bins->tiles_x; i++) {
|
||||
for (j = 0; j < bins->tiles_y; j++) {
|
||||
struct cmd_bin *bin = lp_get_bin(bins, i, j);
|
||||
rasterize_bin( rast, bin, i * TILE_SIZE, j * TILE_SIZE );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,7 +136,6 @@ void lp_rast_destroy( struct lp_rasterizer * );
|
|||
|
||||
void lp_rasterize_bins( struct lp_rasterizer *rast,
|
||||
struct lp_bins *bins,
|
||||
unsigned tiles_x, unsigned tiles_y,
|
||||
const struct pipe_framebuffer_state *fb,
|
||||
bool write_depth );
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ static void reset_context( struct setup_context *setup )
|
|||
setup->fs.stored = NULL;
|
||||
setup->dirty = ~0;
|
||||
|
||||
lp_reset_bins(&setup->bins, setup->tiles_x, setup->tiles_y);
|
||||
lp_reset_bins( &setup->bins );
|
||||
|
||||
/* Reset some state:
|
||||
*/
|
||||
|
|
@ -103,82 +103,13 @@ static void reset_context( struct setup_context *setup )
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return last command in the bin
|
||||
*/
|
||||
static lp_rast_cmd
|
||||
lp_get_last_command( const struct cmd_bin *bin )
|
||||
{
|
||||
const struct cmd_block *tail = bin->commands.tail;
|
||||
const unsigned i = tail->count;
|
||||
if (i > 0)
|
||||
return tail->cmd[i - 1];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace the arg of the last command in the bin.
|
||||
*/
|
||||
static void
|
||||
lp_replace_last_command_arg( struct cmd_bin *bin,
|
||||
const union lp_rast_cmd_arg arg )
|
||||
{
|
||||
struct cmd_block *tail = bin->commands.tail;
|
||||
const unsigned i = tail->count;
|
||||
assert(i > 0);
|
||||
tail->arg[i - 1] = arg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Add a command to all active bins.
|
||||
*/
|
||||
static void bin_everywhere( struct setup_context *setup,
|
||||
lp_rast_cmd cmd,
|
||||
const union lp_rast_cmd_arg arg )
|
||||
{
|
||||
unsigned i, j;
|
||||
for (i = 0; i < setup->tiles_x; i++)
|
||||
for (j = 0; j < setup->tiles_y; j++)
|
||||
lp_bin_command( &setup->bins, i, j, cmd, arg );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Put a state-change command into all bins.
|
||||
* If we find that the last command in a bin was also a state-change
|
||||
* command, we can simply replace that one with the new one.
|
||||
*/
|
||||
static void
|
||||
bin_state_command( struct setup_context *setup,
|
||||
lp_rast_cmd cmd,
|
||||
const union lp_rast_cmd_arg arg )
|
||||
{
|
||||
unsigned i, j;
|
||||
for (i = 0; i < setup->tiles_x; i++) {
|
||||
for (j = 0; j < setup->tiles_y; j++) {
|
||||
struct cmd_bin *bin = &setup->bins.tile[i][j];
|
||||
lp_rast_cmd last_cmd = lp_get_last_command(bin);
|
||||
if (last_cmd == cmd) {
|
||||
lp_replace_last_command_arg(bin, arg);
|
||||
}
|
||||
else {
|
||||
lp_bin_command( &setup->bins, i, j, cmd, arg );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Rasterize all tile's bins */
|
||||
static void
|
||||
rasterize_bins( struct setup_context *setup,
|
||||
boolean write_depth )
|
||||
{
|
||||
lp_rasterize_bins(setup->rast,
|
||||
&setup->bins, setup->tiles_x, setup->tiles_y,
|
||||
&setup->bins,
|
||||
setup->fb,
|
||||
write_depth);
|
||||
|
||||
|
|
@ -196,20 +127,24 @@ begin_binning( struct setup_context *setup )
|
|||
|
||||
if (setup->fb->cbufs[0]) {
|
||||
if (setup->clear.flags & PIPE_CLEAR_COLOR)
|
||||
bin_everywhere( setup,
|
||||
lp_rast_clear_color,
|
||||
setup->clear.color );
|
||||
lp_bin_everywhere( &setup->bins,
|
||||
lp_rast_clear_color,
|
||||
setup->clear.color );
|
||||
else
|
||||
bin_everywhere( setup, lp_rast_load_color, lp_rast_arg_null() );
|
||||
lp_bin_everywhere( &setup->bins,
|
||||
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 );
|
||||
lp_bin_everywhere( &setup->bins,
|
||||
lp_rast_clear_zstencil,
|
||||
setup->clear.zstencil );
|
||||
else
|
||||
bin_everywhere( setup, lp_rast_load_zstencil, lp_rast_arg_null() );
|
||||
lp_bin_everywhere( &setup->bins,
|
||||
lp_rast_load_zstencil,
|
||||
lp_rast_arg_null() );
|
||||
}
|
||||
|
||||
LP_DBG(DEBUG_SETUP, "%s done\n", __FUNCTION__);
|
||||
|
|
@ -280,13 +215,18 @@ void
|
|||
lp_setup_bind_framebuffer( struct setup_context *setup,
|
||||
const struct pipe_framebuffer_state *fb )
|
||||
{
|
||||
unsigned tiles_x, tiles_y;
|
||||
|
||||
LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
|
||||
|
||||
set_state( setup, SETUP_FLUSHED );
|
||||
|
||||
setup->fb = fb;
|
||||
setup->tiles_x = align(setup->fb->width, TILE_SIZE) / TILE_SIZE;
|
||||
setup->tiles_y = align(setup->fb->height, TILE_SIZE) / TILE_SIZE;
|
||||
|
||||
tiles_x = align(setup->fb->width, TILE_SIZE) / TILE_SIZE;
|
||||
tiles_y = align(setup->fb->height, TILE_SIZE) / TILE_SIZE;
|
||||
|
||||
lp_bin_set_num_bins(&setup->bins, tiles_x, tiles_y);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -321,14 +261,14 @@ lp_setup_clear( struct setup_context *setup,
|
|||
* don't see that as being a common usage.
|
||||
*/
|
||||
if (flags & PIPE_CLEAR_COLOR)
|
||||
bin_everywhere( setup,
|
||||
lp_rast_clear_color,
|
||||
setup->clear.color );
|
||||
lp_bin_everywhere( &setup->bins,
|
||||
lp_rast_clear_color,
|
||||
setup->clear.color );
|
||||
|
||||
if (setup->clear.flags & PIPE_CLEAR_DEPTHSTENCIL)
|
||||
bin_everywhere( setup,
|
||||
lp_rast_clear_zstencil,
|
||||
setup->clear.zstencil );
|
||||
lp_bin_everywhere( &setup->bins,
|
||||
lp_rast_clear_zstencil,
|
||||
setup->clear.zstencil );
|
||||
}
|
||||
else {
|
||||
/* Put ourselves into the 'pre-clear' state, specifically to try
|
||||
|
|
@ -545,9 +485,9 @@ lp_setup_update_shader_state( struct setup_context *setup )
|
|||
setup->fs.stored = stored;
|
||||
|
||||
/* put the state-set command into all bins */
|
||||
bin_state_command( setup,
|
||||
lp_rast_set_state,
|
||||
lp_rast_arg_state(setup->fs.stored) );
|
||||
lp_bin_state_command( &setup->bins,
|
||||
lp_rast_set_state,
|
||||
lp_rast_arg_state(setup->fs.stored) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,10 +57,6 @@ struct setup_context {
|
|||
|
||||
struct lp_bins bins;
|
||||
|
||||
/* size of framebuffer, in tiles */
|
||||
unsigned tiles_x;
|
||||
unsigned tiles_y;
|
||||
|
||||
boolean ccw_is_frontface;
|
||||
unsigned cullmode;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue