Cell: emit framebuffer state like other state
authorBrian <brian.paul@tungstengraphics.com>
Fri, 25 Jan 2008 16:01:36 +0000 (09:01 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Sat, 26 Jan 2008 00:25:56 +0000 (17:25 -0700)
Plus misc clean-up.  Window resize sometimes works now.

src/mesa/pipe/cell/common.h
src/mesa/pipe/cell/ppu/cell_state_emit.c
src/mesa/pipe/cell/ppu/cell_state_surface.c
src/mesa/pipe/cell/spu/spu_main.c

index af7f27bc831652458adbebe744d66d311486b052..f9edd0cc262dad461a1cd2d4ade3ed1aaa133ee6 100644 (file)
  */
 #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
index e5b7c925143b25c117611d42b0969ad6d58d6910..dbca900c35fcf2058889e151257855b90c291e28 100644 (file)
 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);
index 1f7faca08083a317099849f4c701df76c5ca3e81..287610b76b9c685ea09aacaba16650f53c2d3fd0 100644 (file)
 
 
 #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
 }
 
index 2b88c545766de47ab76870b14f303dc1ed43b902..f9e15538b8b56c728b0b89ae337ddcfeb95e08dc 100644 (file)
@@ -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);