Mesa (lp-binning): llvmpipe: implement lp_rast_load_zstencil

Keith Whitwell keithw at kemper.freedesktop.org
Wed Jan 13 20:14:19 UTC 2010


Module: Mesa
Branch: lp-binning
Commit: 95ee14f147e713bd132dc56a1151232957752c90
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=95ee14f147e713bd132dc56a1151232957752c90

Author: Keith Whitwell <keithw at vmware.com>
Date:   Wed Jan 13 16:52:17 2010 +0000

llvmpipe: implement lp_rast_load_zstencil

Load zbuffer contents for binned scenes that don't start with a clear
and which have a bound zbuffer.

---

 src/gallium/drivers/llvmpipe/lp_rast.c |   36 ++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index 0a8d730..7753f9b 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -269,6 +269,23 @@ void lp_rast_load_color( struct lp_rasterizer *rast,
 }
 
 
+static void
+lp_tile_read_z32(uint32_t *tile,
+                 const uint8_t *map,
+                 unsigned map_stride,
+                 unsigned x0, unsigned y0, unsigned w, unsigned h)
+{
+   unsigned x, y;
+   const uint8_t *map_row = map + y0*map_stride;
+   for (y = 0; y < h; ++y) {
+      const uint32_t *map_pixel = (uint32_t *)(map_row + x0*4);
+      for (x = 0; x < w; ++x) {
+         *tile++ = *map_pixel++;
+      }
+      map_row += map_stride;
+   }
+}
+
 /**
  * Load tile z/stencil from the framebuffer surface.
  * This is a bin command called during bin processing.
@@ -277,9 +294,24 @@ void lp_rast_load_zstencil( struct lp_rasterizer *rast,
                             unsigned thread_index,
                             const union lp_rast_cmd_arg arg )
 {
-   LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
+   const unsigned x = rast->tasks[thread_index].x;
+   const unsigned y = rast->tasks[thread_index].y;
+   unsigned w = TILE_SIZE;
+   unsigned h = TILE_SIZE;
+
+   if (x + w > rast->state.fb.width)
+      w -= x + w - rast->state.fb.width;
 
-   /* call u_tile func to load depth (and stencil?) from surface */
+   if (y + h > rast->state.fb.height)
+      h -= y + h - rast->state.fb.height;
+
+   LP_DBG(DEBUG_RAST, "%s %d,%d %dx%d\n", __FUNCTION__, x, y, w, h);
+
+   assert(rast->zsbuf_transfer->texture->format == PIPE_FORMAT_Z32_UNORM);
+   lp_tile_read_z32(rast->tasks[thread_index].tile.depth,
+                    rast->zsbuf_map, 
+                    rast->zsbuf_transfer->stride,
+                    x, y, w, h);
 }
 
 




More information about the mesa-commit mailing list