*/
struct cell_command_framebuffer
{
- void *start;
int width, height;
- enum pipe_format format;
+ void *color_start, *depth_start;
+ enum pipe_format color_format, depth_format;
} ALIGN16_ATTRIB;
test_spus(struct cell_context *cell)
{
uint i;
- struct pipe_surface *surf = cell->framebuffer.cbufs[0];
+ struct pipe_surface *csurf = cell->framebuffer.cbufs[0];
+ struct pipe_surface *zsurf = cell->framebuffer.zbuf;
printf("PPU: sleep(2)\n\n\n");
sleep(2);
for (i = 0; i < cell->num_spus; i++) {
- cell_global.command[i].fb.start = surf->map;
- cell_global.command[i].fb.width = surf->width;
- cell_global.command[i].fb.height = surf->height;
- cell_global.command[i].fb.format = PIPE_FORMAT_A8R8G8B8_UNORM;
+ cell_global.command[i].fb.color_start = csurf->map;
+ cell_global.command[i].fb.depth_start = zsurf ? zsurf->map : NULL;
+ cell_global.command[i].fb.width = csurf->width;
+ cell_global.command[i].fb.height = csurf->height;
+ cell_global.command[i].fb.color_format = PIPE_FORMAT_A8R8G8B8_UNORM;
+ cell_global.command[i].fb.depth_format = PIPE_FORMAT_Z32_UNORM;
send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_FRAMEBUFFER);
}
finish_all(cell->num_spus);
{
- uint *b = (uint*) surf->map;
+ uint *b = (uint*) csurf->map;
printf("PPU: Clear results: 0x%x 0x%x 0x%x 0x%x\n",
b[0], b[1000], b[2000], b[3000]);
}
-
-
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "pipe/p_inlines.h"
#include "cell_context.h"
#include "cell_state.h"
+#include "cell_spu.h"
+
void
cell_set_framebuffer_state(struct pipe_context *pipe,
{
struct cell_context *cell = cell_context(pipe);
- cell->framebuffer = *fb;
+ if (memcmp(&cell->framebuffer, fb, sizeof(*fb))) {
+ struct pipe_surface *csurf = fb->cbufs[0];
+ struct pipe_surface *zsurf = fb->zbuf;
+ uint i;
+
+ /* change in fb state */
+
+ /* unmap old surfaces */
+ for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+ if (cell->framebuffer.cbufs[i] &&
+ cell->framebuffer.cbufs[i]->map) {
+ pipe_surface_unmap(cell->framebuffer.cbufs[i]);
+ }
+ }
- cell->dirty |= CELL_NEW_FRAMEBUFFER;
+ if (cell->framebuffer.zbuf &&
+ cell->framebuffer.zbuf->map) {
+ pipe_surface_unmap(cell->framebuffer.zbuf);
+ }
+
+ /* update my state */
+ cell->framebuffer = *fb;
+
+ /* map new surfaces */
+ if (csurf && !csurf->map)
+ pipe_surface_map(csurf);
+
+ if (zsurf && !zsurf->map)
+ pipe_surface_map(zsurf);
+
+ for (i = 0; i < cell->num_spus; i++) {
+ struct cell_command_framebuffer *fb = &cell_global.command[i].fb;
+ fb->color_start = csurf->map;
+ fb->color_format = csurf->format;
+ fb->depth_start = zsurf ? zsurf->map : NULL;
+ fb->depth_format = zsurf ? zsurf->format : PIPE_FORMAT_NONE;
+ fb->width = csurf->width;
+ fb->height = csurf->height;
+ send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_FRAMEBUFFER);
+ }
+
+ cell->dirty |= CELL_NEW_FRAMEBUFFER;
+ }
#if 0
struct pipe_surface *ps;
printf("Cell: Skipping non 32bpp clear_surface\n");
return;
}
-
+#if 0
for (i = 0; i < cell->num_spus; i++) {
struct cell_command_framebuffer *fb = &cell_global.command[i].fb;
printf("%s %u start = 0x%x\n", __FUNCTION__, i, ps->map);
- fb->start = ps->map;
+ fb->color_start = ps->map;
fb->width = ps->width;
fb->height = ps->height;
- fb->format = ps->format;
+ fb->color_format = ps->format;
send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_FRAMEBUFFER);
}
+#endif
for (i = 0; i < cell->num_spus; i++) {
#if 1
{
uint offset = ty * fb->width_tiles + tx;
uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4;
- ubyte *src = (ubyte *) fb->start + offset * bytesPerTile;
+ ubyte *src = (ubyte *) fb->color_start + offset * bytesPerTile;
assert(tx < fb->width_tiles);
assert(ty < fb->height_tiles);
{
uint offset = ty * fb->width_tiles + tx;
uint bytesPerTile = TILE_SIZE * TILE_SIZE * 4;
- ubyte *dst = (ubyte *) fb->start + offset * bytesPerTile;
+ ubyte *dst = (ubyte *) fb->color_start + offset * bytesPerTile;
assert(tx < fb->width_tiles);
assert(ty < fb->height_tiles);
static void
render(const struct cell_command_render *render)
{
- const uint num_tiles = fb.width_tiles * fb.height_tiles;
struct cell_prim_buffer prim_buffer ALIGN16_ATTRIB;
int tag = init.id /**DefaultTag**/;
uint i, j, vertex_bytes;
printf("SPU %u: FRAMEBUFFER: %d x %d at %p, format 0x%x\n", init.id,
cmd.fb.width,
cmd.fb.height,
- cmd.fb.start,
- cmd.fb.format);
- fb.format = cmd.fb.format;
+ cmd.fb.color_start,
+ cmd.fb.color_format);
+ fb.color_start = cmd.fb.color_start;
+ fb.depth_start = cmd.fb.depth_start;
+ fb.color_format = cmd.fb.color_format;
+ fb.depth_format = cmd.fb.depth_format;
fb.width = cmd.fb.width;
fb.height = cmd.fb.height;
fb.width_tiles = (fb.width + TILE_SIZE - 1) / TILE_SIZE;
fb.height_tiles = (fb.height + TILE_SIZE - 1) / TILE_SIZE;
+ /*
printf("SPU %u: %u x %u tiles\n",
init.id, fb.width_tiles, fb.height_tiles);
- fb.start = cmd.fb.start;
+ */
break;
case CELL_CMD_CLEAR_TILES:
printf("SPU %u: CLEAR to 0x%08x\n", init.id, cmd.clear.value);
extern volatile struct cell_init_info init;
struct framebuffer {
- void *start; /**< addr of surface in main memory */
- enum pipe_format format;
+ void *color_start; /**< addr of color surface in main memory */
+ void *depth_start; /**< addr of depth surface in main memory */
+ enum pipe_format color_format;
+ enum pipe_format depth_format;
uint width, height; /**< size in pixels */
uint width_tiles, height_tiles; /**< width and height in tiles */
};
uint g = (uint) (color[1] * 255.0);
uint b = (uint) (color[2] * 255.0);
uint a = (uint) (color[3] * 255.0);
- switch (fb.format) {
+ switch (fb.color_format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
return (a << 24) | (r << 16) | (g << 8) | b;
case PIPE_FORMAT_B8G8R8A8_UNORM: