summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/intel/intel_span.c
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2011-06-01 11:31:56 -0700
committerChad Versace <[email protected]>2011-06-08 10:06:39 -0700
commitff99103c0a8a1b9e76fff80f9753d2124da27da2 (patch)
tree4d10079e6ac4907120acbd51dade302fa5fdc06f /src/mesa/drivers/dri/intel/intel_span.c
parent2abc8cae87b4cd037ebde68b4b9a1d02254657df (diff)
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 <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/intel/intel_span.c')
-rw-r--r--src/mesa/drivers/dri/intel/intel_span.c64
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 5290342c3e1..a4a1d6bd6eb 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 <[email protected]>
+ *
**************************************************************************/
#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,