summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/main/mtypes.h6
-rw-r--r--src/mesa/swrast/s_span.c11
-rw-r--r--src/mesa/swrast/s_stencil.c10
-rw-r--r--src/mesa/swrast/s_stencil.h4
-rw-r--r--src/mesa/swrast/s_tritemp.h3
-rw-r--r--src/mesa/swrast/swrast.h6
-rw-r--r--src/mesa/swrast_setup/ss_triangle.c10
-rw-r--r--src/mesa/swrast_setup/ss_tritmp.h3
8 files changed, 34 insertions, 19 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index dfe1ad883e3..83a63bfa118 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.91 2002/10/02 22:05:55 brianp Exp $ */
+/* $Id: mtypes.h,v 1.92 2002/10/02 23:24:04 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1786,6 +1786,10 @@ struct __GLcontextRec {
GLboolean OcclusionResult; /**< for GL_HP_occlusion_test */
GLboolean OcclusionResultSaved; /**< for GL_HP_occlusion_test */
+ GLuint _Facing; /* This is a hack for 2-sided stencil test. We don't */
+ /* have a better way to communicate this value from */
+ /* swrast_setup to swrast. */
+
/* Z buffer stuff */
GLuint DepthMax; /**< Max depth buffer value */
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 74fccc55c72..b134890a3b2 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1,4 +1,4 @@
-/* $Id: s_span.c,v 1.47 2002/09/06 02:56:09 brianp Exp $ */
+/* $Id: s_span.c,v 1.48 2002/10/02 23:24:04 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -803,8 +803,7 @@ _mesa_write_index_span( GLcontext *ctx, struct sw_span *span)
_mesa_span_interpolate_z(ctx, span);
if (ctx->Stencil.Enabled) {
- const GLuint face = 0; /* XXX stencil two side */
- if (!_mesa_stencil_and_ztest_span(ctx, span, face)) {
+ if (!_mesa_stencil_and_ztest_span(ctx, span)) {
span->arrayMask = origArrayMask;
return;
}
@@ -983,8 +982,7 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span)
_mesa_span_interpolate_z(ctx, span);
if (ctx->Stencil.Enabled) {
- const GLuint face = 0; /* XXX stencil two side */
- if (!_mesa_stencil_and_ztest_span(ctx, span, face)) {
+ if (!_mesa_stencil_and_ztest_span(ctx, span)) {
span->interpMask = origInterpMask;
span->arrayMask = origArrayMask;
return;
@@ -1214,8 +1212,7 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span)
_mesa_span_interpolate_z(ctx, span);
if (ctx->Stencil.Enabled) {
- const GLuint face = 0; /* XXX stencil two side */
- if (!_mesa_stencil_and_ztest_span(ctx, span, face)) {
+ if (!_mesa_stencil_and_ztest_span(ctx, span)) {
span->arrayMask = origArrayMask;
return;
}
diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c
index 4ec64ee8481..90ff06c951d 100644
--- a/src/mesa/swrast/s_stencil.c
+++ b/src/mesa/swrast/s_stencil.c
@@ -1,4 +1,4 @@
-/* $Id: s_stencil.c,v 1.26 2002/09/06 02:56:09 brianp Exp $ */
+/* $Id: s_stencil.c,v 1.27 2002/10/02 23:24:04 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1006,12 +1006,14 @@ stencil_and_ztest_pixels( GLcontext *ctx, struct sw_span *span, GLuint face )
* GL_FALSE = all fragments failed.
*/
GLboolean
-_mesa_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span, GLuint face)
+_mesa_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span)
{
+ /* span->facing can only be non-zero if using two-sided stencil */
+ ASSERT(ctx->Stencil.TestTwoSide || span->facing == 0);
if (span->arrayMask & SPAN_XY)
- return stencil_and_ztest_pixels(ctx, span, face);
+ return stencil_and_ztest_pixels(ctx, span, span->facing);
else
- return stencil_and_ztest_span(ctx, span, face);
+ return stencil_and_ztest_span(ctx, span, span->facing);
}
diff --git a/src/mesa/swrast/s_stencil.h b/src/mesa/swrast/s_stencil.h
index ec76edaf78b..b174f2e01e1 100644
--- a/src/mesa/swrast/s_stencil.h
+++ b/src/mesa/swrast/s_stencil.h
@@ -1,4 +1,4 @@
-/* $Id: s_stencil.h,v 1.8 2002/09/06 02:56:09 brianp Exp $ */
+/* $Id: s_stencil.h,v 1.9 2002/10/02 23:24:04 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,7 +35,7 @@
extern GLboolean
-_mesa_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span, GLuint face);
+_mesa_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span);
diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h
index 726f17e9bb4..ef5e00eb5bf 100644
--- a/src/mesa/swrast/s_tritemp.h
+++ b/src/mesa/swrast/s_tritemp.h
@@ -1,4 +1,4 @@
-/* $Id: s_tritemp.h,v 1.38 2002/08/07 15:18:42 brianp Exp $ */
+/* $Id: s_tritemp.h,v 1.39 2002/10/02 23:24:04 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -215,6 +215,7 @@
#ifndef DO_OCCLUSION_TEST
ctx->OcclusionResult = GL_TRUE;
#endif
+ span.facing = ctx->_Facing; /* for 2-sided stencil test */
/* Edge setup. For a triangle strip these could be reused... */
{
diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h
index 4db055b6fe1..2d547c889ea 100644
--- a/src/mesa/swrast/swrast.h
+++ b/src/mesa/swrast/swrast.h
@@ -1,4 +1,4 @@
-/* $Id: swrast.h,v 1.27 2002/09/17 15:46:36 brianp Exp $ */
+/* $Id: swrast.h,v 1.28 2002/10/02 23:24:04 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -147,6 +147,9 @@ struct sw_span {
/** either GL_POLYGON, GL_LINE, GL_POLYGON, GL_BITMAP */
GLenum primitive;
+ /** 0 = front-facing span, 1 = back-facing span (for two-sided stencil) */
+ GLuint facing;
+
/**
* This bitmask (of SPAN_* flags) indicates which of the x/xStep
* variables are relevant.
@@ -201,6 +204,7 @@ do { \
(S).arrayMask = (ARRAY_MASK); \
(S).start = 0; \
(S).end = (END); \
+ (S).facing = 0; \
(S).array = SWRAST_CONTEXT(ctx)->span_data; \
} while (0)
diff --git a/src/mesa/swrast_setup/ss_triangle.c b/src/mesa/swrast_setup/ss_triangle.c
index 159dc799efc..fa1f3e74e90 100644
--- a/src/mesa/swrast_setup/ss_triangle.c
+++ b/src/mesa/swrast_setup/ss_triangle.c
@@ -1,4 +1,4 @@
-/* $Id: ss_triangle.c,v 1.16 2002/10/02 21:44:08 brianp Exp $ */
+/* $Id: ss_triangle.c,v 1.17 2002/10/02 23:24:04 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -273,9 +273,15 @@ void _swsetup_choose_trifuncs( GLcontext *ctx )
if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
ind |= SS_TWOSIDE_BIT;
- if (ctx->_TriangleCaps & DD_TRI_UNFILLED)
+ /* We piggyback the two-sided stencil front/back determination on the
+ * unfilled triangle path.
+ */
+ if ((ctx->_TriangleCaps & DD_TRI_UNFILLED) ||
+ (ctx->Stencil.Enabled && ctx->Stencil.TestTwoSide))
ind |= SS_UNFILLED_BIT;
+ ctx->_Facing = 0;
+
if (ctx->Visual.rgbMode)
ind |= SS_RGBA_BIT;
diff --git a/src/mesa/swrast_setup/ss_tritmp.h b/src/mesa/swrast_setup/ss_tritmp.h
index 61d1f8008a4..2a1ff14cf9c 100644
--- a/src/mesa/swrast_setup/ss_tritmp.h
+++ b/src/mesa/swrast_setup/ss_tritmp.h
@@ -1,4 +1,4 @@
-/* $Id: ss_tritmp.h,v 1.15 2001/09/14 21:36:43 brianp Exp $ */
+/* $Id: ss_tritmp.h,v 1.16 2002/10/02 23:24:04 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -54,6 +54,7 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT))
{
facing = (cc < 0.0) ^ ctx->Polygon._FrontBit;
+ ctx->_Facing = facing; /* for 2-sided stencil test */
if (IND & SS_UNFILLED_BIT)
mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode;