summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-12-04 15:59:25 -0700
committerBrian Paul <[email protected]>2009-12-04 15:59:25 -0700
commit8a23105fa016ec4368f407ca64e7763f110da4e5 (patch)
tree33f40653b67ab101fec1224f1c5397b0b55da2c7 /src/gallium
parent2c8d5c66ce2ddc0b7182e4844690736fc4c47212 (diff)
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].
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bin.c70
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bin.h32
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.c5
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.h1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c120
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup_context.h4
6 files changed, 130 insertions, 102 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bin.c b/src/gallium/drivers/llvmpipe/lp_bin.c
index 1f05416b3ee..160a8d865ba 100644
--- a/src/gallium/drivers/llvmpipe/lp_bin.c
+++ b/src/gallium/drivers/llvmpipe/lp_bin.c
@@ -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;
@@ -108,6 +108,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 )
{
struct cmd_block *block = MALLOC_STRUCT(cmd_block);
@@ -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 );
+ }
+ }
+ }
+}
diff --git a/src/gallium/drivers/llvmpipe/lp_bin.h b/src/gallium/drivers/llvmpipe/lp_bin.h
index 4d12b932745..fcbb975ad64 100644
--- a/src/gallium/drivers/llvmpipe/lp_bin.h
+++ b/src/gallium/drivers/llvmpipe/lp_bin.h
@@ -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 */
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index 87e3bfcd3f5..642f1b90795 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -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 );
}
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h
index e623eafc9ad..e77c77b7762 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast.h
@@ -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 );
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index e561e8e9b6a..4935d5b5407 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -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) );
}
}
}
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h
index 8478bb9014c..9b47b595c62 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h
@@ -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;