diff options
author | Brian <[email protected]> | 2008-01-03 09:40:02 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2008-01-03 09:40:02 -0700 |
commit | 4ff6367295bc266cf1e3390570c9aee50fe716a0 (patch) | |
tree | 1bc19ebc25dd83fffc430b0e7fdfb6e82d15f322 /src/mesa/pipe/cell/ppu | |
parent | 9b598df95ebe99d9aaf2043ce8786847978de4aa (diff) |
Cell: improve surface state code to replace some temporary code.
Diffstat (limited to 'src/mesa/pipe/cell/ppu')
-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 |
3 files changed, 86 insertions, 13 deletions
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 |