finished up GL_EXT_stencil_two_side

This commit is contained in:
Brian Paul
2002-10-02 23:24:04 +00:00
parent 0adce5d0ed
commit be99e845bd
8 changed files with 34 additions and 19 deletions

View File

@@ -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 * Mesa 3-D graphics library
@@ -1786,6 +1786,10 @@ struct __GLcontextRec {
GLboolean OcclusionResult; /**< for GL_HP_occlusion_test */ GLboolean OcclusionResult; /**< for GL_HP_occlusion_test */
GLboolean OcclusionResultSaved; /**< 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 */ /* Z buffer stuff */
GLuint DepthMax; /**< Max depth buffer value */ GLuint DepthMax; /**< Max depth buffer value */

View File

@@ -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 * 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); _mesa_span_interpolate_z(ctx, span);
if (ctx->Stencil.Enabled) { if (ctx->Stencil.Enabled) {
const GLuint face = 0; /* XXX stencil two side */ if (!_mesa_stencil_and_ztest_span(ctx, span)) {
if (!_mesa_stencil_and_ztest_span(ctx, span, face)) {
span->arrayMask = origArrayMask; span->arrayMask = origArrayMask;
return; return;
} }
@@ -983,8 +982,7 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span)
_mesa_span_interpolate_z(ctx, span); _mesa_span_interpolate_z(ctx, span);
if (ctx->Stencil.Enabled) { if (ctx->Stencil.Enabled) {
const GLuint face = 0; /* XXX stencil two side */ if (!_mesa_stencil_and_ztest_span(ctx, span)) {
if (!_mesa_stencil_and_ztest_span(ctx, span, face)) {
span->interpMask = origInterpMask; span->interpMask = origInterpMask;
span->arrayMask = origArrayMask; span->arrayMask = origArrayMask;
return; return;
@@ -1214,8 +1212,7 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span)
_mesa_span_interpolate_z(ctx, span); _mesa_span_interpolate_z(ctx, span);
if (ctx->Stencil.Enabled) { if (ctx->Stencil.Enabled) {
const GLuint face = 0; /* XXX stencil two side */ if (!_mesa_stencil_and_ztest_span(ctx, span)) {
if (!_mesa_stencil_and_ztest_span(ctx, span, face)) {
span->arrayMask = origArrayMask; span->arrayMask = origArrayMask;
return; return;
} }

View File

@@ -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 * 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. * GL_FALSE = all fragments failed.
*/ */
GLboolean 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) if (span->arrayMask & SPAN_XY)
return stencil_and_ztest_pixels(ctx, span, face); return stencil_and_ztest_pixels(ctx, span, span->facing);
else else
return stencil_and_ztest_span(ctx, span, face); return stencil_and_ztest_span(ctx, span, span->facing);
} }

View File

@@ -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 * Mesa 3-D graphics library
@@ -35,7 +35,7 @@
extern GLboolean 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);

View File

@@ -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 * Mesa 3-D graphics library
@@ -215,6 +215,7 @@
#ifndef DO_OCCLUSION_TEST #ifndef DO_OCCLUSION_TEST
ctx->OcclusionResult = GL_TRUE; ctx->OcclusionResult = GL_TRUE;
#endif #endif
span.facing = ctx->_Facing; /* for 2-sided stencil test */
/* Edge setup. For a triangle strip these could be reused... */ /* Edge setup. For a triangle strip these could be reused... */
{ {

View File

@@ -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 * Mesa 3-D graphics library
@@ -147,6 +147,9 @@ struct sw_span {
/** either GL_POLYGON, GL_LINE, GL_POLYGON, GL_BITMAP */ /** either GL_POLYGON, GL_LINE, GL_POLYGON, GL_BITMAP */
GLenum primitive; 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 * This bitmask (of SPAN_* flags) indicates which of the x/xStep
* variables are relevant. * variables are relevant.
@@ -201,6 +204,7 @@ do { \
(S).arrayMask = (ARRAY_MASK); \ (S).arrayMask = (ARRAY_MASK); \
(S).start = 0; \ (S).start = 0; \
(S).end = (END); \ (S).end = (END); \
(S).facing = 0; \
(S).array = SWRAST_CONTEXT(ctx)->span_data; \ (S).array = SWRAST_CONTEXT(ctx)->span_data; \
} while (0) } while (0)

View File

@@ -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 * Mesa 3-D graphics library
@@ -273,9 +273,15 @@ void _swsetup_choose_trifuncs( GLcontext *ctx )
if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
ind |= SS_TWOSIDE_BIT; 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; ind |= SS_UNFILLED_BIT;
ctx->_Facing = 0;
if (ctx->Visual.rgbMode) if (ctx->Visual.rgbMode)
ind |= SS_RGBA_BIT; ind |= SS_RGBA_BIT;

View File

@@ -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 * 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)) if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT))
{ {
facing = (cc < 0.0) ^ ctx->Polygon._FrontBit; facing = (cc < 0.0) ^ ctx->Polygon._FrontBit;
ctx->_Facing = facing; /* for 2-sided stencil test */
if (IND & SS_UNFILLED_BIT) if (IND & SS_UNFILLED_BIT)
mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode; mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode;