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;
}
+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 )
{
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 );
+ }
+ }
+ }
+}
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 );
}
+/* 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 */
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:
*/
}
-/**
- * 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);
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__);
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);
}
* 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
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) );
}
}
}