diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/pipe/cell/common.h | 4 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_spu.c | 15 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_state_surface.c | 77 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_surface.c | 7 | ||||
-rw-r--r-- | src/mesa/pipe/cell/spu/main.c | 17 | ||||
-rw-r--r-- | src/mesa/pipe/cell/spu/main.h | 6 | ||||
-rw-r--r-- | src/mesa/pipe/cell/spu/tri.c | 2 |
7 files changed, 103 insertions, 25 deletions
diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index 983ccd07750..dff0b1f8ec6 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -59,9 +59,9 @@ */ 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; diff --git a/src/mesa/pipe/cell/ppu/cell_spu.c b/src/mesa/pipe/cell/ppu/cell_spu.c index 55a0d5038bf..15b89682fa4 100644 --- a/src/mesa/pipe/cell/ppu/cell_spu.c +++ b/src/mesa/pipe/cell/ppu/cell_spu.c @@ -158,16 +158,19 @@ void 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); } @@ -179,7 +182,7 @@ test_spus(struct cell_context *cell) 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]); } diff --git a/src/mesa/pipe/cell/ppu/cell_state_surface.c b/src/mesa/pipe/cell/ppu/cell_state_surface.c index f7330caf5e9..cd8e5def311 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_state_surface.c @@ -1,7 +1,36 @@ - - +/************************************************************************** + * + * 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, @@ -9,9 +38,49 @@ 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; diff --git a/src/mesa/pipe/cell/ppu/cell_surface.c b/src/mesa/pipe/cell/ppu/cell_surface.c index 5fa37dd2cd0..62e0febc0c2 100644 --- a/src/mesa/pipe/cell/ppu/cell_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_surface.c @@ -55,16 +55,17 @@ cell_clear_surface(struct pipe_context *pipe, 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 diff --git a/src/mesa/pipe/cell/spu/main.c b/src/mesa/pipe/cell/spu/main.c index a131bd51982..6292962f447 100644 --- a/src/mesa/pipe/cell/spu/main.c +++ b/src/mesa/pipe/cell/spu/main.c @@ -70,7 +70,7 @@ get_tile(const struct framebuffer *fb, uint tx, uint ty, uint *tile, { 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); @@ -94,7 +94,7 @@ put_tile(const struct framebuffer *fb, uint tx, uint ty, const uint *tile, { 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); @@ -180,7 +180,6 @@ tile_bounding_box(const struct cell_command_render *render, 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; @@ -302,16 +301,20 @@ main_loop(void) 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); diff --git a/src/mesa/pipe/cell/spu/main.h b/src/mesa/pipe/cell/spu/main.h index 3240e01615b..60a565bfa77 100644 --- a/src/mesa/pipe/cell/spu/main.h +++ b/src/mesa/pipe/cell/spu/main.h @@ -37,8 +37,10 @@ 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 */ }; diff --git a/src/mesa/pipe/cell/spu/tri.c b/src/mesa/pipe/cell/spu/tri.c index 3707ebea458..f58cc4b0249 100644 --- a/src/mesa/pipe/cell/spu/tri.c +++ b/src/mesa/pipe/cell/spu/tri.c @@ -234,7 +234,7 @@ pack_color(const float color[4]) 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: |