Mesa (master): intel: Define span functions for S8 renderbuffers

Chad Versace chadversary at kemper.freedesktop.org
Wed Jun 8 17:07:53 UTC 2011


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

Author: Chad Versace <chad at chad-versace.us>
Date:   Wed Jun  1 11:31:56 2011 -0700

intel: Define span functions for S8 renderbuffers

Since the stencil buffer is interleaved, the generic Mesa renderbuffer
accessors do not suffice. Custom span functions are necessary.

Acked-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Eric Anholt <eric at anholt.net>
Signed-off-by: Chad Versace <chad at chad-versace.us>

---

 src/mesa/drivers/dri/intel/intel_span.c |   64 +++++++++++++++++++++++++++++++
 1 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c
index 5290342..a4a1d6b 100644
--- a/src/mesa/drivers/dri/intel/intel_span.c
+++ b/src/mesa/drivers/dri/intel/intel_span.c
@@ -1,6 +1,7 @@
 /**************************************************************************
  * 
  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2011 Intel Corporation
  * All Rights Reserved.
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,9 +24,13 @@
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  * 
+ * Authors:
+ *     Chad Versace <chad at chad-versace.us>
+ *
  **************************************************************************/
 
 #include <stdbool.h>
+#include <stdint.h>
 #include "main/glheader.h"
 #include "main/macros.h"
 #include "main/mtypes.h"
@@ -112,6 +117,64 @@ intel_set_span_functions(struct intel_context *intel,
 #define TAG2(x,y) intel_##x##y##_A8
 #include "spantmp2.h"
 
+/* ------------------------------------------------------------------------- */
+/* s8 stencil span and pixel functions                                       */
+/* ------------------------------------------------------------------------- */
+
+/*
+ * HAVE_HW_STENCIL_SPANS determines if stencil buffer read/writes are done with
+ * memcpy or for loops. Since the stencil buffer is interleaved, memcpy won't
+ * work.
+ */
+#define HAVE_HW_STENCIL_SPANS 0
+
+#define LOCAL_STENCIL_VARS						\
+   (void) ctx;								\
+   int minx = 0;							\
+   int miny = 0;							\
+   int maxx = rb->Width;						\
+   int maxy = rb->Height;						\
+   int stride = rb->RowStride;						\
+   uint8_t *buf = rb->Data;						\
+
+/* Don't flip y. */
+#undef Y_FLIP
+#define Y_FLIP(y) y
+
+/**
+ * \brief Get pointer offset into stencil buffer.
+ *
+ * The stencil buffer interleaves two rows into one. Yay for crazy hardware.
+ * The table below demonstrates how the pointer arithmetic behaves for a buffer
+ * with positive stride (s=stride).
+ *
+ *     x    | y     | byte offset
+ *     --------------------------
+ *     0    | 0     | 0
+ *     0    | 0     | 1
+ *     1    | 0     | 2
+ *     1    | 1     | 3
+ *     ...  | ...   | ...
+ *     0    | 2     | s
+ *     0    | 3     | s + 1
+ *     1    | 2     | s + 2
+ *     1    | 3     | s + 3
+ *
+ *
+ */
+static inline intptr_t
+intel_offset_S8(int stride, GLint x, GLint y)
+{
+   return 2 * ((y / 2) * stride + x) + y % 2;
+}
+
+#define WRITE_STENCIL(x, y, src)  buf[intel_offset_S8(stride, x, y)] = src;
+#define READ_STENCIL(dest, x, y) dest = buf[intel_offset_S8(stride, x, y)]
+#define TAG(x) intel_##x##_S8
+#include "stenciltmp.h"
+
+/* ------------------------------------------------------------------------- */
+
 void
 intel_renderbuffer_map(struct intel_context *intel, struct gl_renderbuffer *rb)
 {
@@ -332,6 +395,7 @@ static span_init_func intel_span_init_funcs[MESA_FORMAT_COUNT] =
    [MESA_FORMAT_Z16] = _mesa_set_renderbuffer_accessors,
    [MESA_FORMAT_X8_Z24] = _mesa_set_renderbuffer_accessors,
    [MESA_FORMAT_S8_Z24] = _mesa_set_renderbuffer_accessors,
+   [MESA_FORMAT_S8] = intel_InitStencilPointers_S8,
    [MESA_FORMAT_R8] = _mesa_set_renderbuffer_accessors,
    [MESA_FORMAT_RG88] = _mesa_set_renderbuffer_accessors,
    [MESA_FORMAT_R16] = _mesa_set_renderbuffer_accessors,




More information about the mesa-commit mailing list