#include "spu_tile.h"
#include "pipe/cell/common.h"
#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
/*
static boolean Debug = TRUE;
-volatile struct cell_init_info init;
-
-struct framebuffer fb;
-
+struct spu_global spu;
void
static void
really_clear_tiles(uint surfaceIndex)
{
- const uint num_tiles = fb.width_tiles * fb.height_tiles;
+ const uint num_tiles = spu.fb.width_tiles * spu.fb.height_tiles;
uint i, j;
if (surfaceIndex == 0) {
for (i = 0; i < TILE_SIZE; i++)
for (j = 0; j < TILE_SIZE; j++)
- ctile[i][j] = fb.color_clear_value;
+ ctile[i][j] = spu.fb.color_clear_value;
- for (i = init.id; i < num_tiles; i += init.num_spus) {
- uint tx = i % fb.width_tiles;
- uint ty = i / fb.width_tiles;
+ for (i = spu.init.id; i < num_tiles; i += spu.init.num_spus) {
+ uint tx = i % spu.fb.width_tiles;
+ uint ty = i / spu.fb.width_tiles;
if (tile_status[ty][tx] == TILE_STATUS_CLEAR) {
- put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0);
+ put_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0);
}
}
}
else {
for (i = 0; i < TILE_SIZE; i++)
for (j = 0; j < TILE_SIZE; j++)
- ztile[i][j] = fb.depth_clear_value;
+ ztile[i][j] = spu.fb.depth_clear_value;
- for (i = init.id; i < num_tiles; i += init.num_spus) {
- uint tx = i % fb.width_tiles;
- uint ty = i / fb.width_tiles;
+ for (i = spu.init.id; i < num_tiles; i += spu.init.num_spus) {
+ uint tx = i % spu.fb.width_tiles;
+ uint ty = i / spu.fb.width_tiles;
if (tile_status_z[ty][tx] == TILE_STATUS_CLEAR)
- put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 1);
+ put_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 1);
}
}
static void
cmd_clear_surface(const struct cell_command_clear_surface *clear)
{
- const uint num_tiles = fb.width_tiles * fb.height_tiles;
+ const uint num_tiles = spu.fb.width_tiles * spu.fb.height_tiles;
uint i, j;
if (Debug)
- printf("SPU %u: CLEAR SURF %u to 0x%08x\n", init.id,
+ printf("SPU %u: CLEAR SURF %u to 0x%08x\n", spu.init.id,
clear->surface, clear->value);
#define CLEAR_OPT 1
/* set all tile's status to CLEAR */
if (clear->surface == 0) {
memset(tile_status, TILE_STATUS_CLEAR, sizeof(tile_status));
- fb.color_clear_value = clear->value;
+ spu.fb.color_clear_value = clear->value;
}
else {
memset(tile_status_z, TILE_STATUS_CLEAR, sizeof(tile_status_z));
- fb.depth_clear_value = clear->value;
+ spu.fb.depth_clear_value = clear->value;
}
return;
#endif
/*
printf("SPU: %s num=%d w=%d h=%d\n",
- __FUNCTION__, num_tiles, fb.width_tiles, fb.height_tiles);
+ __FUNCTION__, num_tiles, spu.fb.width_tiles, spu.fb.height_tiles);
*/
- for (i = init.id; i < num_tiles; i += init.num_spus) {
- uint tx = i % fb.width_tiles;
- uint ty = i / fb.width_tiles;
+ for (i = spu.init.id; i < num_tiles; i += spu.init.num_spus) {
+ uint tx = i % spu.fb.width_tiles;
+ uint ty = i / spu.fb.width_tiles;
if (clear->surface == 0)
- put_tile(&fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0);
+ put_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_SURFACE_CLEAR, 0);
else
- put_tile(&fb, tx, ty, (uint *) ztile, TAG_SURFACE_CLEAR, 1);
+ put_tile(&spu.fb, tx, ty, (uint *) ztile, TAG_SURFACE_CLEAR, 1);
/* XXX we don't want this here, but it fixes bad tile results */
}
{
#if 1
/* Debug: full-window bounding box */
- uint txmax = fb.width_tiles - 1;
- uint tymax = fb.height_tiles - 1;
+ uint txmax = spu.fb.width_tiles - 1;
+ uint tymax = spu.fb.height_tiles - 1;
*txmin = 0;
*tymin = 0;
- *box_num_tiles = fb.width_tiles * fb.height_tiles;
- *box_width_tiles = fb.width_tiles;
+ *box_num_tiles = spu.fb.width_tiles * spu.fb.height_tiles;
+ *box_width_tiles = spu.fb.width_tiles;
(void) render;
(void) txmax;
(void) tymax;
if (Debug)
printf("SPU %u: RENDER prim %u, indices: %u, nr_vert: %u\n",
- init.id,
+ spu.init.id,
render->prim_type,
render->num_verts,
render->num_indexes);
#else
txmin = 0;
tymin = 0;
- box_num_tiles = fb.width_tiles * fb.height_tiles;
- box_width_tiles = fb.width_tiles;
+ 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);
/* loop over tiles */
- for (i = init.id; i < box_num_tiles; i += init.num_spus) {
+ for (i = spu.init.id; i < box_num_tiles; i += spu.init.num_spus) {
const uint tx = txmin + i % box_width_tiles;
const uint ty = tymin + i / box_width_tiles;
- ASSERT(tx < fb.width_tiles);
- ASSERT(ty < fb.height_tiles);
+ ASSERT(tx < spu.fb.width_tiles);
+ ASSERT(ty < spu.fb.height_tiles);
/* Start fetching color/z tiles. We'll wait for completion when
* we need read/write to them later in triangle rasterization.
*/
- if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) {
+ if (spu.fb.depth_format == PIPE_FORMAT_Z16_UNORM) {
if (tile_status_z[ty][tx] != TILE_STATUS_CLEAR) {
- get_tile(&fb, tx, ty, (uint *) ztile, TAG_READ_TILE_Z, 1);
+ get_tile(&spu.fb, tx, ty, (uint *) ztile, TAG_READ_TILE_Z, 1);
}
}
if (tile_status[ty][tx] != TILE_STATUS_CLEAR) {
- get_tile(&fb, tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0);
+ get_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_READ_TILE_COLOR, 0);
}
ASSERT(render->prim_type == PIPE_PRIM_TRIANGLES);
/* write color/z tiles back to main framebuffer, if dirtied */
if (tile_status[ty][tx] == TILE_STATUS_DIRTY) {
- put_tile(&fb, tx, ty, (uint *) ctile, TAG_WRITE_TILE_COLOR, 0);
+ put_tile(&spu.fb, tx, ty, (uint *) ctile, TAG_WRITE_TILE_COLOR, 0);
tile_status[ty][tx] = TILE_STATUS_DEFINED;
}
- if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) {
+ if (spu.fb.depth_format == PIPE_FORMAT_Z16_UNORM) {
if (tile_status_z[ty][tx] == TILE_STATUS_DIRTY) {
- put_tile(&fb, tx, ty, (uint *) ztile, TAG_WRITE_TILE_Z, 1);
+ put_tile(&spu.fb, tx, ty, (uint *) ztile, TAG_WRITE_TILE_Z, 1);
tile_status_z[ty][tx] = TILE_STATUS_DEFINED;
}
}
/* XXX move these... */
wait_on_mask(1 << TAG_WRITE_TILE_COLOR);
- if (fb.depth_format == PIPE_FORMAT_Z16_UNORM) {
+ if (spu.fb.depth_format == PIPE_FORMAT_Z16_UNORM) {
wait_on_mask(1 << TAG_WRITE_TILE_Z);
}
}
{
if (Debug)
printf("SPU %u: FRAMEBUFFER: %d x %d at %p, cformat 0x%x zformat 0x%x\n",
- init.id,
+ spu.init.id,
cmd->width,
cmd->height,
cmd->color_start,
cmd->color_format,
cmd->depth_format);
- fb.color_start = cmd->color_start;
- fb.depth_start = cmd->depth_start;
- fb.color_format = cmd->color_format;
- fb.depth_format = cmd->depth_format;
- fb.width = cmd->width;
- fb.height = cmd->height;
- fb.width_tiles = (fb.width + TILE_SIZE - 1) / TILE_SIZE;
- fb.height_tiles = (fb.height + TILE_SIZE - 1) / TILE_SIZE;
+ spu.fb.color_start = cmd->color_start;
+ spu.fb.depth_start = cmd->depth_start;
+ spu.fb.color_format = cmd->color_format;
+ spu.fb.depth_format = cmd->depth_format;
+ spu.fb.width = cmd->width;
+ spu.fb.height = cmd->height;
+ spu.fb.width_tiles = (spu.fb.width + TILE_SIZE - 1) / TILE_SIZE;
+ spu.fb.height_tiles = (spu.fb.height + TILE_SIZE - 1) / TILE_SIZE;
}
{
if (Debug)
printf("SPU %u: DEPTH_STENCIL: ztest %d\n",
- init.id,
+ spu.init.id,
state->depth.enabled);
/* XXX copy/save the state */
}
cmd_finish(void)
{
if (Debug)
- printf("SPU %u: FINISH\n", init.id);
+ printf("SPU %u: FINISH\n", spu.init.id);
really_clear_tiles(0);
/* wait for all outstanding DMAs to finish */
mfc_write_tag_mask(~0);
if (Debug)
printf("SPU %u: BATCH buffer %u, len %u, from %p\n",
- init.id, buf, size, init.batch_buffers[buf]);
+ spu.init.id, buf, size, spu.init.batch_buffers[buf]);
ASSERT((opcode & CELL_CMD_OPCODE_MASK) == CELL_CMD_BATCH);
- ASSERT_ALIGN16(init.batch_buffers[buf]);
+ ASSERT_ALIGN16(spu.init.batch_buffers[buf]);
size = (size + 0xf) & ~0xf;
mfc_get(buffer, /* dest */
- (unsigned int) init.batch_buffers[buf], /* src */
+ (unsigned int) spu.init.batch_buffers[buf], /* src */
size,
TAG_BATCH_BUFFER,
0, /* tid */
pos += (1 + sizeof(struct pipe_depth_stencil_alpha_state) / 4);
break;
default:
- printf("SPU %u: bad opcode: 0x%x\n", init.id, buffer[pos]);
+ printf("SPU %u: bad opcode: 0x%x\n", spu.init.id, buffer[pos]);
ASSERT(0);
break;
}
}
if (Debug)
- printf("SPU %u: BATCH complete\n", init.id);
+ printf("SPU %u: BATCH complete\n", spu.init.id);
}
int exitFlag = 0;
if (Debug)
- printf("SPU %u: Enter main loop\n", init.id);
+ printf("SPU %u: Enter main loop\n", spu.init.id);
ASSERT((sizeof(struct cell_command) & 0xf) == 0);
ASSERT_ALIGN16(&cmd);
int tag = 0;
if (Debug)
- printf("SPU %u: Wait for cmd...\n", init.id);
+ printf("SPU %u: Wait for cmd...\n", spu.init.id);
/* read/wait from mailbox */
opcode = (unsigned int) spu_read_in_mbox();
if (Debug)
- printf("SPU %u: got cmd 0x%x\n", init.id, opcode);
+ printf("SPU %u: got cmd 0x%x\n", spu.init.id, opcode);
/* command payload */
mfc_get(&cmd, /* dest */
- (unsigned int) init.cmd, /* src */
+ (unsigned int) spu.init.cmd, /* src */
sizeof(struct cell_command), /* bytes */
tag,
0, /* tid */
switch (opcode & CELL_CMD_OPCODE_MASK) {
case CELL_CMD_EXIT:
if (Debug)
- printf("SPU %u: EXIT\n", init.id);
+ printf("SPU %u: EXIT\n", spu.init.id);
exitFlag = 1;
break;
case CELL_CMD_FRAMEBUFFER:
}
if (Debug)
- printf("SPU %u: Exit main loop\n", init.id);
+ printf("SPU %u: Exit main loop\n", spu.init.id);
}
if (Debug)
printf("SPU: main() speid=%lu\n", speid);
- mfc_get(&init, /* dest */
+ mfc_get(&spu.init, /* dest */
(unsigned int) argp, /* src */
sizeof(struct cell_init_info), /* bytes */
tag,