#define CELL_CMD_EXIT 1
#define CELL_CMD_FRAMEBUFFER 2
#define CELL_CMD_CLEAR_TILES 3
-#define CELL_CMD_TRIANGLE 4
#define CELL_CMD_FINISH 5
#define CELL_CMD_RENDER 6
} ALIGN16_ATTRIB;
-struct cell_command_triangle
-{
- float vert[3][4];
- float color[3][4];
-} ALIGN16_ATTRIB;
-
-
struct cell_command_render
{
uint prim_type;
{
struct cell_command_framebuffer fb;
struct cell_command_clear_tiles clear;
- struct cell_command_triangle tri;
struct cell_command_render render;
} ALIGN16_ATTRIB;
cell_global.command[i].clear.value = clearValue | (i << 21);
send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_CLEAR_TILES);
}
-
-#if 0
- /* XXX Draw a test triangle over the cleared surface */
- for (i = 0; i < cell->num_spus; i++) {
- /* Same triangle data for all SPUs */
- struct cell_command_triangle *tri = &cell_global.command[i].tri;
- tri->vert[0][0] = 20.0;
- tri->vert[0][1] = ps->height - 20;
-
- tri->vert[1][0] = ps->width - 20.0;
- tri->vert[1][1] = ps->height - 20;
-
- tri->vert[2][0] = ps->width / 2;
- tri->vert[2][1] = 20.0;
-
- tri->color[0][0] = 1.0;
- tri->color[0][1] = 0.0;
- tri->color[0][2] = 0.0;
- tri->color[0][3] = 0.0;
-
- tri->color[1][0] = 0.0;
- tri->color[1][1] = 1.0;
- tri->color[1][2] = 0.0;
- tri->color[1][3] = 0.0;
-
- tri->color[2][0] = 0.0;
- tri->color[2][1] = 0.0;
- tri->color[2][2] = 1.0;
- tri->color[2][3] = 0.0;
-
- send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_TRIANGLE);
- }
-#endif
}
static void
-triangle(const struct cell_command_triangle *tri)
-{
- uint num_tiles = fb.width_tiles * fb.height_tiles;
- struct prim_header prim;
- uint i;
-
- COPY_4V(prim.v[0].data[0], tri->vert[0]);
- COPY_4V(prim.v[1].data[0], tri->vert[1]);
- COPY_4V(prim.v[2].data[0], tri->vert[2]);
-
- COPY_4V(prim.v[0].data[1], tri->color[0]);
- COPY_4V(prim.v[1].data[1], tri->color[1]);
- COPY_4V(prim.v[2].data[1], tri->color[2]);
-
- for (i = init.id; i < num_tiles; i += init.num_spus) {
- uint tx = i % fb.width_tiles;
- uint ty = i / fb.width_tiles;
- draw_triangle(&prim, tx, ty);
- }
-}
-
-
-
-static void
render(const struct cell_command_render *render)
{
const uint num_tiles = fb.width_tiles * fb.height_tiles;
COPY_4V(prim.v[1].data[1], prim_buffer.vertex[j+1][1]);
COPY_4V(prim.v[2].data[1], prim_buffer.vertex[j+2][1]);
- draw_triangle(&prim, tx, ty);
+ tri_draw(&prim, tx, ty);
}
put_tile(&fb, tx, ty, (uint *) tile, DefaultTag);
printf("SPU %u: CLEAR to 0x%08x\n", init.id, cmd.clear.value);
clear_tiles(&cmd.clear);
break;
- case CELL_CMD_TRIANGLE:
- printf("SPU %u: TRIANGLE\n", init.id);
- triangle(&cmd.tri);
- break;
case CELL_CMD_RENDER:
printf("SPU %u: RENDER %u verts, prim %u\n",
init.id, cmd.render.num_verts, cmd.render.prim_type);
#endif
-void
-draw_triangle(struct prim_header *tri, uint tx, uint ty)
-{
- /* set clipping bounds to tile bounds */
- cliprect_minx = tx * TILE_SIZE;
- cliprect_miny = ty * TILE_SIZE;
- cliprect_maxx = (tx + 1) * TILE_SIZE;
- cliprect_maxy = (ty + 1) * TILE_SIZE;
-
- get_tile(&fb, tx, ty, (uint *) tile, DefaultTag);
- wait_on_mask(1 << DefaultTag);
-
- setup_tri(tri);
-
- put_tile(&fb, tx, ty, (uint *) tile, DefaultTag);
- wait_on_mask(1 << DefaultTag);
-}
-
-
+/**
+ * Draw triangle into tile at (tx, ty) (tile coords)
+ * The tile data should have already been fetched.
+ */
void
tri_draw(struct prim_header *tri, uint tx, uint ty)
{
extern void
-draw_triangle(struct prim_header *tri, uint tx, uint ty);
-
-
-extern void
tri_draw(struct prim_header *tri, uint tx, uint ty);