Mesa (master): cell: update clear() code to catch up to gallium changes

Brian Paul brianp at kemper.freedesktop.org
Sat Apr 4 19:46:06 UTC 2009


Module: Mesa
Branch: master
Commit: 7a164411ab678622d6f3194cf708b2884bfde90e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7a164411ab678622d6f3194cf708b2884bfde90e

Author: Brian Paul <brianp at vmware.com>
Date:   Sat Apr  4 13:45:14 2009 -0600

cell: update clear() code to catch up to gallium changes

---

 src/gallium/drivers/cell/ppu/cell_clear.c   |   56 ++++++++++----------------
 src/gallium/drivers/cell/ppu/cell_clear.h   |    6 +--
 src/gallium/drivers/cell/ppu/cell_context.c |    2 +-
 3 files changed, 25 insertions(+), 39 deletions(-)

diff --git a/src/gallium/drivers/cell/ppu/cell_clear.c b/src/gallium/drivers/cell/ppu/cell_clear.c
index 34be5f3..79ad687 100644
--- a/src/gallium/drivers/cell/ppu/cell_clear.c
+++ b/src/gallium/drivers/cell/ppu/cell_clear.c
@@ -46,53 +46,41 @@
 
 
 /**
- * Convert packed pixel from one format to another.
- */
-static unsigned
-convert_color(enum pipe_format srcFormat, unsigned srcColor,
-              enum pipe_format dstFormat)
-{
-   ubyte r, g, b, a;
-   unsigned dstColor;
-
-   util_unpack_color_ub(srcFormat, &srcColor, &r, &g, &b, &a);
-   util_pack_color_ub(r, g, b, a, dstFormat, &dstColor);
-
-   return dstColor;
-}
-
-
-
-/**
  * Called via pipe->clear()
  */
 void
-cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps,
-                   unsigned clearValue)
+cell_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+           double depth, unsigned stencil)
 {
    struct cell_context *cell = cell_context(pipe);
-   uint surfIndex;
 
    if (cell->dirty)
       cell_update_derived(cell);
 
-   if (ps == cell->framebuffer.zsbuf) {
-      /* clear z/stencil buffer */
-      surfIndex = 1;
-   }
-   else {
-      /* clear color buffer */
-      surfIndex = 0;
+   if (buffers & PIPE_CLEAR_COLOR) {
+      uint surfIndex = 0;
+      uint clearValue;
 
-      if (ps->format != PIPE_FORMAT_A8R8G8B8_UNORM) {
-         clearValue = convert_color(PIPE_FORMAT_A8R8G8B8_UNORM, clearValue,
-                                    ps->format);
-      }
+      util_pack_color(rgba, cell->framebuffer.cbufs[0]->format, &clearValue);
+
+      /* Build a CLEAR command and place it in the current batch buffer */
+      STATIC_ASSERT(sizeof(struct cell_command_clear_surface) % 16 == 0);
+      struct cell_command_clear_surface *clr
+         = (struct cell_command_clear_surface *)
+         cell_batch_alloc16(cell, sizeof(*clr));
+      clr->opcode[0] = CELL_CMD_CLEAR_SURFACE;
+      clr->surface = surfIndex;
+      clr->value = clearValue;
    }
 
+   if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
+      uint surfIndex = 1;
+      uint clearValue;
+
+      clearValue = util_pack_z_stencil(cell->framebuffer.zsbuf->format,
+                                       depth, stencil);
 
-   /* Build a CLEAR command and place it in the current batch buffer */
-   {
+      /* Build a CLEAR command and place it in the current batch buffer */
       STATIC_ASSERT(sizeof(struct cell_command_clear_surface) % 16 == 0);
       struct cell_command_clear_surface *clr
          = (struct cell_command_clear_surface *)
diff --git a/src/gallium/drivers/cell/ppu/cell_clear.h b/src/gallium/drivers/cell/ppu/cell_clear.h
index ff47d43..08e091a 100644
--- a/src/gallium/drivers/cell/ppu/cell_clear.h
+++ b/src/gallium/drivers/cell/ppu/cell_clear.h
@@ -31,13 +31,11 @@
 
 
 struct pipe_context;
-struct pipe_surface;
 
 
 extern void
-cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps,
-                   unsigned clearValue);
-
+cell_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+           double depth, unsigned stencil);
 
 
 #endif /* CELL_CLEAR_H */
diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c
index ae82ded..808be58 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.c
+++ b/src/gallium/drivers/cell/ppu/cell_context.c
@@ -119,7 +119,7 @@ cell_create_context(struct pipe_screen *screen,
    cell->pipe.screen = screen;
    cell->pipe.destroy = cell_destroy_context;
 
-   cell->pipe.clear = cell_clear_surface;
+   cell->pipe.clear = cell_clear;
    cell->pipe.flush = cell_flush;
 
 #if 0




More information about the mesa-commit mailing list