summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-01-03 09:56:48 -0700
committerBrian <[email protected]>2008-01-03 09:56:48 -0700
commit5e00ae3fea51afd5de14d559f693645837b3903b (patch)
treea6599207463fdba5ea45fb81403d7d2284d54d29 /src
parent3ffef8de825f843ed504a8177fd08af9196be696 (diff)
Cell: initial work for getting/putting Z tiles
Diffstat (limited to 'src')
-rw-r--r--src/mesa/pipe/cell/spu/main.c47
-rw-r--r--src/mesa/pipe/cell/spu/main.h7
-rw-r--r--src/mesa/pipe/cell/spu/tri.c8
3 files changed, 39 insertions, 23 deletions
diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c
index bdb814e5d89..9580281971a 100644
--- a/src/mesa/pipe/cell/spu/main.c
+++ b/src/mesa/pipe/cell/spu/main.c
@@ -49,7 +49,8 @@ volatile struct cell_init_info init;
struct framebuffer fb;
-uint tile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB;
+uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB;
+uint ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB;
int DefaultTag;
@@ -66,11 +67,13 @@ wait_on_mask(unsigned tag)
void
get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile,
- int tag)
+ int tag, int zBuf)
{
- uint offset = ty * fb->width_tiles + tx;
- uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4;
- ubyte *src = (ubyte *) fb->color_start + offset * bytesPerTile;
+ const uint offset = ty * fb->width_tiles + tx;
+ const uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4;
+ const ubyte *src = zBuf ? fb->depth_start : fb->color_start;
+
+ src += offset * bytesPerTile;
assert(tx < fb->width_tiles);
assert(ty < fb->height_tiles);
@@ -90,11 +93,13 @@ get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile,
void
put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile,
- int tag)
+ int tag, int zBuf)
{
- uint offset = ty * fb->width_tiles + tx;
- uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4;
- ubyte *dst = (ubyte *) fb->color_start + offset * bytesPerTile;
+ const uint offset = ty * fb->width_tiles + tx;
+ const uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4;
+ ubyte *dst = zBuf ? fb->depth_start : fb->color_start;
+
+ dst += offset * bytesPerTile;
assert(tx < fb->width_tiles);
assert(ty < fb->height_tiles);
@@ -117,12 +122,12 @@ static void
clear_tiles(const struct cell_command_clear_tiles *clear)
{
uint num_tiles = fb.width_tiles * fb.height_tiles;
- uint i;
- uint tile[TILE_SIZE * TILE_SIZE] ALIGN16_ATTRIB;
+ uint i, j;
int tag = init.id;
- for (i = 0; i < TILE_SIZE * TILE_SIZE; i++)
- tile[i] = clear->value;
+ for (i = 0; i < TILE_SIZE; i++)
+ for (j = 0; j < TILE_SIZE; j++)
+ ctile[i][j] = clear->value;
/*
printf("SPU: %s num=%d w=%d h=%d\n",
@@ -132,7 +137,7 @@ clear_tiles(const struct cell_command_clear_tiles *clear)
for (i = init.id; i < num_tiles; i += init.num_spus) {
uint tx = i % fb.width_tiles;
uint ty = i / fb.width_tiles;
- put_tile(&fb, tx, ty, tile, tag);
+ put_tile(&fb, tx, ty, (uint *) ctile, tag, 0);
/* XXX we don't want this here, but it fixes bad tile results */
wait_on_mask(1 << tag);
}
@@ -219,9 +224,14 @@ render(const struct cell_command_render *render)
assert(tx < fb.width_tiles);
assert(ty < fb.height_tiles);
- get_tile(&fb, tx, ty, (uint *) tile, tag);
+ get_tile(&fb, tx, ty, (uint *) ctile, tag, 0);
wait_on_mask(1 << tag); /* XXX temporary */
+ if (fb.depth_format == PIPE_FORMAT_Z32_UNORM) {
+ get_tile(&fb, tx, ty, (uint *) ztile, tag+1, 1);
+ wait_on_mask(1 << (tag+1)); /* XXX temporary */
+ }
+
assert(render->prim_type == PIPE_PRIM_TRIANGLES);
/* loop over tris */
@@ -252,8 +262,13 @@ render(const struct cell_command_render *render)
tri_draw(&prim, tx, ty);
}
- put_tile(&fb, tx, ty, (uint *) tile, tag);
+ put_tile(&fb, tx, ty, (uint *) ctile, tag, 0);
wait_on_mask(1 << tag); /* XXX temp */
+
+ if (fb.depth_format == PIPE_FORMAT_Z32_UNORM) {
+ put_tile(&fb, tx, ty, (uint *) ztile, tag+1, 1);
+ wait_on_mask(1 << (tag+1)); /* XXX temporary */
+ }
}
}
diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h
index 60a565bfa77..c22679c5d99 100644
--- a/src/mesa/pipe/cell/spu/main.h
+++ b/src/mesa/pipe/cell/spu/main.h
@@ -49,7 +49,8 @@ struct framebuffer {
extern struct framebuffer fb;
-extern uint tile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB;
+extern uint ctile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB;
+extern uint ztile[TILE_SIZE][TILE_SIZE] ALIGN16_ATTRIB;
extern int DefaultTag;
@@ -59,11 +60,11 @@ wait_on_mask(unsigned tag);
void
get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile,
- int tag);
+ int tag, int zBuf);
void
put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile,
- int tag);
+ int tag, int zBuf);
#endif /* MAIN_H */
diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c
index f58cc4b0249..36599297b98 100644
--- a/src/mesa/pipe/cell/spu/tri.c
+++ b/src/mesa/pipe/cell/spu/tri.c
@@ -267,13 +267,13 @@ emit_quad( struct setup_stage *setup, int x, int y, unsigned mask )
eval_coeff(setup, 1, (float) x, (float) y, colors);
if (mask & MASK_TOP_LEFT)
- tile[iy][ix] = pack_color(colors[QUAD_TOP_LEFT]);
+ ctile[iy][ix] = pack_color(colors[QUAD_TOP_LEFT]);
if (mask & MASK_TOP_RIGHT)
- tile[iy][ix+1] = pack_color(colors[QUAD_TOP_RIGHT]);
+ ctile[iy][ix+1] = pack_color(colors[QUAD_TOP_RIGHT]);
if (mask & MASK_BOTTOM_LEFT)
- tile[iy+1][ix] = pack_color(colors[QUAD_BOTTOM_LEFT]);
+ ctile[iy+1][ix] = pack_color(colors[QUAD_BOTTOM_LEFT]);
if (mask & MASK_BOTTOM_RIGHT)
- tile[iy+1][ix+1] = pack_color(colors[QUAD_BOTTOM_RIGHT]);
+ ctile[iy+1][ix+1] = pack_color(colors[QUAD_BOTTOM_RIGHT]);
#endif
}