summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2008-01-02 19:31:36 -0700
committerBrian <brian.paul@tungstengraphics.com>2008-01-02 19:31:36 -0700
commitf6b7e2d3bf9af34704e9624246614c1583b655da (patch)
tree559d9051f8bf77dcd71b8f097cdfc91ccdf96fa4 /src
parent54090bd841b302c6d48e7f130dbe07c8fd5a0a96 (diff)
make use of prim bounds box info
Diffstat (limited to 'src')
-rw-r--r--src/mesa/pipe/cell/ppu/cell_context.c5
-rw-r--r--src/mesa/pipe/cell/ppu/cell_render.c5
-rw-r--r--src/mesa/pipe/cell/spu/main.c40
3 files changed, 47 insertions, 3 deletions
diff --git a/src/mesa/pipe/cell/ppu/cell_context.c b/src/mesa/pipe/cell/ppu/cell_context.c
index fb89837a7c..4fcf804d82 100644
--- a/src/mesa/pipe/cell/ppu/cell_context.c
+++ b/src/mesa/pipe/cell/ppu/cell_context.c
@@ -241,6 +241,11 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
draw_set_rasterize_stage(cell->draw, cell->render_stage);
+ cell->prim_buffer.xmin = 1e100;
+ cell->prim_buffer.ymin = 1e100;
+ cell->prim_buffer.xmax = -1e100;
+ cell->prim_buffer.ymax = -1e100;
+
/*
* SPU stuff
*/
diff --git a/src/mesa/pipe/cell/ppu/cell_render.c b/src/mesa/pipe/cell/ppu/cell_render.c
index b97f4ff536..79aa37ea02 100644
--- a/src/mesa/pipe/cell/ppu/cell_render.c
+++ b/src/mesa/pipe/cell/ppu/cell_render.c
@@ -166,6 +166,11 @@ cell_flush_prim_buffer(struct cell_context *cell)
}
cell->prim_buffer.num_verts = 0;
+
+ cell->prim_buffer.xmin = 1e100;
+ cell->prim_buffer.ymin = 1e100;
+ cell->prim_buffer.xmax = -1e100;
+ cell->prim_buffer.ymax = -1e100;
}
diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c
index 5e29d4faaa..94f13029ff 100644
--- a/src/mesa/pipe/cell/spu/main.c
+++ b/src/mesa/pipe/cell/spu/main.c
@@ -87,6 +87,7 @@ get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile,
0 /* rid */);
}
+
void
put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile,
int tag)
@@ -138,6 +139,33 @@ clear_tiles(const struct cell_command_clear_tiles *clear)
}
+/**
+ * Given a rendering command's bounding box (in pixels) compute the
+ * location of the corresponding screen tile bounding box.
+ */
+static INLINE void
+tile_bounding_box(const struct cell_command_render *render,
+ uint *txmin, uint *tymin,
+ uint *box_num_tiles, uint *box_width_tiles)
+{
+ uint txmax, tymax, box_height_tiles;
+
+ *txmin = (uint) render->xmin / TILE_SIZE;
+ *tymin = (uint) render->ymin / TILE_SIZE;
+ txmax = (uint) render->xmax / TILE_SIZE;
+ tymax = (uint) render->ymax / TILE_SIZE;
+ *box_width_tiles = txmax - *txmin + 1;
+ box_height_tiles = tymax - *tymin + 1;
+ *box_num_tiles = *box_width_tiles * box_height_tiles;
+ /*
+ printf("Render bounds: %g, %g ... %g, %g\n",
+ render->xmin, render->ymin, render->xmax, render->ymax);
+ printf("Render tiles: %u, %u .. %u, %u\n", *txmin, *tymin, txmax, tymax);
+ */
+}
+
+
+
static void
render(const struct cell_command_render *render)
{
@@ -167,10 +195,16 @@ render(const struct cell_command_render *render)
0 /* rid */);
wait_on_mask( 1 << tag ); /* XXX temporary */
+ /* find tiles which intersect the prim bounding box */
+ uint txmin, tymin, box_width_tiles, box_num_tiles;
+ tile_bounding_box(render, &txmin, &tymin,
+ &box_num_tiles, &box_width_tiles);
+
+
/* loop over tiles */
- for (i = init.id; i < num_tiles; i += init.num_spus) {
- const uint tx = i % fb.width_tiles;
- const uint ty = i / fb.width_tiles;
+ for (i = init.id; i < box_num_tiles; i += init.num_spus) {
+ const uint tx = txmin + i % box_width_tiles;
+ const uint ty = tymin + i / box_width_tiles;
get_tile(&fb, tx, ty, (uint *) tile, DefaultTag);
wait_on_mask(1 << DefaultTag); /* XXX temporary */