Cell: re-enable bounding boxes

The geometry bounding box is used to restrict rasterization to just those
tiles that are relevant.
Note another dummy field had to be added to the cell_command_render struct.
Apparently, every 4th word in a struct is susceptible to corruption in some
circumstances.  Might be a compiler bug.
This commit is contained in:
Brian 2008-01-28 12:46:05 -07:00
parent 1cc0b0dda7
commit 043fc00a60
3 changed files with 24 additions and 12 deletions

View file

@ -122,7 +122,7 @@ struct cell_command_render
uint dummy; /* XXX this dummy field works around a compiler bug */
uint num_indexes;
uint vertex_buf; /**< which cell->buffer[] contains the vertex data */
float xmin, ymin, xmax, ymax;
float xmin, dummy2, ymin, xmax, ymax; /* XXX another dummy field */
boolean inline_verts;
} ALIGN16_ATTRIB;

View file

@ -180,6 +180,10 @@ cell_vbuf_draw(struct vbuf_render *vbr,
if (v[1] > ymax)
ymax = v[1];
}
#if 0
printf("PPU Bounds %g, %g .. %g, %g\n", xmin, ymin, xmax, ymax);
fflush(stdout);
#endif
if (cvbr->prim != PIPE_PRIM_TRIANGLES)
return; /* only render tris for now */

View file

@ -200,7 +200,7 @@ tile_bounding_box(const struct cell_command_render *render,
uint *txmin, uint *tymin,
uint *box_num_tiles, uint *box_width_tiles)
{
#if 1
#if 0
/* Debug: full-window bounding box */
uint txmax = spu.fb.width_tiles - 1;
uint tymax = spu.fb.height_tiles - 1;
@ -223,13 +223,24 @@ tile_bounding_box(const struct cell_command_render *render,
*box_num_tiles = *box_width_tiles * box_height_tiles;
#endif
#if 0
printf("Render bounds: %g, %g ... %g, %g\n",
printf("SPU %u: bounds: %g, %g ... %g, %g\n", spu.init.id,
render->xmin, render->ymin, render->xmax, render->ymax);
printf("Render tiles: %u, %u .. %u, %u\n", *txmin, *tymin, txmax, tymax);
printf("SPU %u: tiles: %u, %u .. %u, %u\n",
spu.init.id, *txmin, *tymin, txmax, tymax);
ASSERT(render->xmin <= render->xmax);
ASSERT(render->ymin <= render->ymax);
#endif
}
/** Check if the tile at (tx,ty) belongs to this SPU */
static INLINE boolean
my_tile(uint tx, uint ty)
{
return (spu.fb.width_tiles * ty + tx) % spu.init.num_spus == spu.init.id;
}
/**
* Render primitives
* \param pos_incr returns value indicating how may words to skip after
@ -295,15 +306,9 @@ cmd_render(const struct cell_command_render *render, uint *pos_incr)
** find tiles which intersect the prim bounding box
**/
uint txmin, tymin, box_width_tiles, box_num_tiles;
#if 0
tile_bounding_box(render, &txmin, &tymin,
&box_num_tiles, &box_width_tiles);
#else
txmin = 0;
tymin = 0;
box_num_tiles = spu.fb.width_tiles * spu.fb.height_tiles;
box_width_tiles = spu.fb.width_tiles;
#endif
/* make sure any pending clears have completed */
wait_on_mask(1 << TAG_SURFACE_CLEAR); /* XXX temporary */
@ -312,13 +317,16 @@ cmd_render(const struct cell_command_render *render, uint *pos_incr)
/**
** loop over tiles, rendering tris
**/
for (i = spu.init.id; i < box_num_tiles; i += spu.init.num_spus) {
for (i = 0; i < box_num_tiles; i++) {
const uint tx = txmin + i % box_width_tiles;
const uint ty = tymin + i / box_width_tiles;
ASSERT(tx < spu.fb.width_tiles);
ASSERT(ty < spu.fb.height_tiles);
if (!my_tile(tx, ty))
continue;
/* Start fetching color/z tiles. We'll wait for completion when
* we need read/write to them later in triangle rasterization.
*/