-/* $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
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 */
-/* $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
_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;
}
_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;
_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;
}
-/* $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
* 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);
}
-/* $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
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);
-/* $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
#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... */
{
-/* $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
/** 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.
(S).arrayMask = (ARRAY_MASK); \
(S).start = 0; \
(S).end = (END); \
+ (S).facing = 0; \
(S).array = SWRAST_CONTEXT(ctx)->span_data; \
} while (0)
-/* $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
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;
-/* $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
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;