From 4d534124e77109a0405bf68dc3fa1a370f5ea014 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 25 Jan 2008 09:01:36 -0700 Subject: Cell: emit framebuffer state like other state Plus misc clean-up. Window resize sometimes works now. --- src/mesa/pipe/cell/common.h | 18 ++--- src/mesa/pipe/cell/ppu/cell_state_emit.c | 14 ++++ src/mesa/pipe/cell/ppu/cell_state_surface.c | 118 +--------------------------- src/mesa/pipe/cell/spu/spu_main.c | 13 +-- 4 files changed, 32 insertions(+), 131 deletions(-) (limited to 'src/mesa/pipe/cell') diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index af7f27bc83..f9edd0cc26 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -56,15 +56,15 @@ */ #define CELL_CMD_OPCODE_MASK 0xf -#define CELL_CMD_EXIT 1 -#define CELL_CMD_FRAMEBUFFER 2 -#define CELL_CMD_CLEAR_SURFACE 3 -#define CELL_CMD_FINISH 4 -#define CELL_CMD_RENDER 5 -#define CELL_CMD_BATCH 6 -#define CELL_CMD_STATE_DEPTH_STENCIL 7 -#define CELL_CMD_STATE_SAMPLER 8 -#define CELL_CMD_STATE_VERTEX_INFO 9 +#define CELL_CMD_EXIT 1 +#define CELL_CMD_CLEAR_SURFACE 2 +#define CELL_CMD_FINISH 3 +#define CELL_CMD_RENDER 4 +#define CELL_CMD_BATCH 5 +#define CELL_CMD_STATE_FRAMEBUFFER 10 +#define CELL_CMD_STATE_DEPTH_STENCIL 11 +#define CELL_CMD_STATE_SAMPLER 12 +#define CELL_CMD_STATE_VERTEX_INFO 13 #define CELL_NUM_BATCH_BUFFERS 3 diff --git a/src/mesa/pipe/cell/ppu/cell_state_emit.c b/src/mesa/pipe/cell/ppu/cell_state_emit.c index e5b7c92514..dbca900c35 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_emit.c +++ b/src/mesa/pipe/cell/ppu/cell_state_emit.c @@ -36,6 +36,20 @@ void cell_emit_state(struct cell_context *cell) { + if (cell->dirty & CELL_NEW_FRAMEBUFFER) { + struct pipe_surface *cbuf = cell->framebuffer.cbufs[0]; + struct pipe_surface *zbuf = cell->framebuffer.zsbuf; + struct cell_command_framebuffer *fb + = cell_batch_alloc(cell, sizeof(*fb)); + fb->opcode = CELL_CMD_STATE_FRAMEBUFFER; + fb->color_start = cell->cbuf_map[0]; + fb->color_format = cbuf->format; + fb->depth_start = cell->zsbuf_map; + fb->depth_format = zbuf ? zbuf->format : PIPE_FORMAT_NONE; + fb->width = cell->framebuffer.cbufs[0]->width; + fb->height = cell->framebuffer.cbufs[0]->height; + } + if (cell->dirty & CELL_NEW_DEPTH_STENCIL) { uint cmd = CELL_CMD_STATE_DEPTH_STENCIL; cell_batch_append(cell, &cmd, 4); diff --git a/src/mesa/pipe/cell/ppu/cell_state_surface.c b/src/mesa/pipe/cell/ppu/cell_state_surface.c index 1f7faca080..287610b76b 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_state_surface.c @@ -27,10 +27,8 @@ #include "pipe/p_inlines.h" -#include "cell_batch.h" #include "cell_context.h" #include "cell_state.h" -#include "cell_spu.h" void @@ -39,14 +37,11 @@ cell_set_framebuffer_state(struct pipe_context *pipe, { struct cell_context *cell = cell_context(pipe); - /* XXX revisit this memcmp! */ - if (memcmp(&cell->framebuffer, fb, sizeof(*fb))) { + if (1 /*memcmp(&cell->framebuffer, fb, sizeof(*fb))*/) { struct pipe_surface *csurf = fb->cbufs[0]; struct pipe_surface *zsurf = fb->zsbuf; uint i; - /* change in fb state */ - /* unmap old surfaces */ for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { if (cell->framebuffer.cbufs[i] && cell->cbuf_map[i]) { @@ -70,118 +65,7 @@ cell_set_framebuffer_state(struct pipe_context *pipe, if (zsurf) cell->zsbuf_map = pipe_surface_map(zsurf); -#if 0 - for (i = 0; i < cell->num_spus; i++) { - struct cell_command_framebuffer *fb = &cell_global.command[i].fb; - fb->opcode = CELL_CMD_FRAMEBUFFER; - 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); - } -#endif -#if 1 - { - struct cell_command_framebuffer *fb - = cell_batch_alloc(cell, sizeof(*fb)); - fb->opcode = CELL_CMD_FRAMEBUFFER; - fb->color_start = cell->cbuf_map[0]; - fb->color_format = csurf->format; - fb->depth_start = cell->zsbuf_map; - fb->depth_format = zsurf ? zsurf->format : PIPE_FORMAT_NONE; - fb->width = csurf->width; - fb->height = csurf->height; - /*cell_batch_flush(cell);*/ - /*cell_flush(&cell->pipe, 0x0);*/ - } -#endif cell->dirty |= CELL_NEW_FRAMEBUFFER; } - -#if 0 - struct pipe_surface *ps; - uint i; - - for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { - /* check if changing cbuf */ - if (sp->framebuffer.cbufs[i] != fb->cbufs[i]) { - /* flush old */ - sp_flush_tile_cache(sp, sp->cbuf_cache[i]); - /* unmap old */ - ps = sp->framebuffer.cbufs[i]; - if (ps && ps->map) - pipe_surface_unmap(ps); - /* map new */ - ps = fb->cbufs[i]; - if (ps) - pipe_surface_map(ps); - /* assign new */ - sp->framebuffer.cbufs[i] = fb->cbufs[i]; - - /* update cache */ - sp_tile_cache_set_surface(sp, sp->cbuf_cache[i], ps); - } - } - - sp->framebuffer.num_cbufs = fb->num_cbufs; - - /* zbuf changing? */ - if (sp->framebuffer.zbuf != fb->zbuf) { - /* flush old */ - sp_flush_tile_cache(sp, sp->zbuf_cache); - /* unmap old */ - ps = sp->framebuffer.zbuf; - if (ps && ps->map) - pipe_surface_unmap(ps); - if (sp->framebuffer.sbuf == sp->framebuffer.zbuf) { - /* combined z/stencil */ - sp->framebuffer.sbuf = NULL; - } - /* map new */ - ps = fb->zbuf; - if (ps) - pipe_surface_map(ps); - /* assign new */ - sp->framebuffer.zbuf = fb->zbuf; - - /* update cache */ - sp_tile_cache_set_surface(sp, sp->zbuf_cache, ps); - } - - /* XXX combined depth/stencil here */ - - /* sbuf changing? */ - if (sp->framebuffer.sbuf != fb->sbuf) { - /* flush old */ - sp_flush_tile_cache(sp, sp->sbuf_cache_sep); - /* unmap old */ - ps = sp->framebuffer.sbuf; - if (ps && ps->map) - pipe_surface_unmap(ps); - /* map new */ - ps = fb->sbuf; - if (ps && fb->sbuf != fb->zbuf) - pipe_surface_map(ps); - /* assign new */ - sp->framebuffer.sbuf = fb->sbuf; - - /* update cache */ - if (fb->sbuf != fb->zbuf) { - /* separate stencil buf */ - sp->sbuf_cache = sp->sbuf_cache_sep; - sp_tile_cache_set_surface(sp, sp->sbuf_cache, ps); - } - else { - /* combined depth/stencil */ - sp->sbuf_cache = sp->zbuf_cache; - sp_tile_cache_set_surface(sp, sp->sbuf_cache, ps); - } - } - - sp->dirty |= SP_NEW_FRAMEBUFFER; -#endif } diff --git a/src/mesa/pipe/cell/spu/spu_main.c b/src/mesa/pipe/cell/spu/spu_main.c index 2b88c54576..f9e15538b8 100644 --- a/src/mesa/pipe/cell/spu/spu_main.c +++ b/src/mesa/pipe/cell/spu/spu_main.c @@ -338,7 +338,7 @@ cmd_render(const struct cell_command_render *render) static void -cmd_framebuffer(const struct cell_command_framebuffer *cmd) +cmd_state_framebuffer(const struct cell_command_framebuffer *cmd) { if (Debug) printf("SPU %u: FRAMEBUFFER: %d x %d at %p, cformat 0x%x zformat 0x%x\n", @@ -349,6 +349,9 @@ cmd_framebuffer(const struct cell_command_framebuffer *cmd) cmd->color_format, cmd->depth_format); + ASSERT_ALIGN16(cmd->color_start); + ASSERT_ALIGN16(cmd->depth_start); + spu.fb.color_start = cmd->color_start; spu.fb.depth_start = cmd->depth_start; spu.fb.color_format = cmd->color_format; @@ -485,11 +488,11 @@ cmd_batch(uint opcode) for (pos = 0; pos < usize; /* no incr */) { switch (buffer[pos]) { - case CELL_CMD_FRAMEBUFFER: + case CELL_CMD_STATE_FRAMEBUFFER: { struct cell_command_framebuffer *fb = (struct cell_command_framebuffer *) &buffer[pos]; - cmd_framebuffer(fb); + cmd_state_framebuffer(fb); pos += sizeof(*fb) / 4; } break; @@ -581,8 +584,8 @@ main_loop(void) printf("SPU %u: EXIT\n", spu.init.id); exitFlag = 1; break; - case CELL_CMD_FRAMEBUFFER: - cmd_framebuffer(&cmd.fb); + case CELL_CMD_STATE_FRAMEBUFFER: + cmd_state_framebuffer(&cmd.fb); break; case CELL_CMD_CLEAR_SURFACE: cmd_clear_surface(&cmd.clear); -- cgit v1.2.3