diff options
Diffstat (limited to 'src/mesa/swrast/s_stencil.c')
-rw-r--r-- | src/mesa/swrast/s_stencil.c | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c index 1a80cc1b430..488ccc0559f 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.12 2001/05/17 20:18:45 brianp Exp $ */ +/* $Id: s_stencil.c,v 1.13 2001/12/17 04:54:35 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -457,7 +457,7 @@ stencil_and_ztest_span( GLcontext *ctx, GLuint n, GLint x, GLint y, MEMCPY(oldmask, mask, n * sizeof(GLubyte)); /* apply the depth test */ - _mesa_depth_test_span(ctx, n, x, y, z, mask); + _old_depth_test_span(ctx, n, x, y, z, mask); /* Set the stencil pass/fail flags according to result of depth testing. * if oldmask[i] == 0 then @@ -502,7 +502,7 @@ stencil_and_ztest_span( GLcontext *ctx, GLuint n, GLint x, GLint y, * */ GLboolean -_mesa_stencil_and_ztest_span( GLcontext *ctx, GLuint n, GLint x, GLint y, +_old_stencil_and_ztest_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], GLubyte mask[] ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); @@ -536,6 +536,61 @@ _mesa_stencil_and_ztest_span( GLcontext *ctx, GLuint n, GLint x, GLint y, return result; } +/* + * Apply stencil and depth testing to the span of pixels. + * Both software and hardware stencil buffers are acceptable. + * Input: n - number of pixels in the span + * x, y - location of leftmost pixel in span + * z - array [n] of z values + * mask - array [n] of flags (1=test this pixel, 0=skip the pixel) + * Output: mask - array [n] of flags (1=stencil and depth test passed) + * Return: GL_TRUE - all fragments failed the testing + * GL_FALSE - one or more fragments passed the testing + * + */ +GLboolean +_mesa_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + + GLstencil stencilRow[MAX_WIDTH]; + GLstencil *stencil; + GLboolean result; + + ASSERT(ctx->Stencil.Enabled); + ASSERT(span->end <= MAX_WIDTH); + ASSERT(span->filledMask == GL_TRUE); + ASSERT(span->filledDepth == GL_TRUE); + SW_SPAN_SET_FLAG(span->testedDepth); + + + /* Get initial stencil values */ + if (swrast->Driver.WriteStencilSpan) { + ASSERT(swrast->Driver.ReadStencilSpan); + /* Get stencil values from the hardware stencil buffer */ + (*swrast->Driver.ReadStencilSpan)(ctx, span->end, span->x, span->y, stencilRow); + stencil = stencilRow; + } + else { + /* software stencil buffer */ + stencil = STENCIL_ADDRESS(span->x, span->y); + } + + /* do all the stencil/depth testing/updating */ + result = stencil_and_ztest_span( ctx, span->end, span->x, span->y, + span->depth, stencil, span->mask ); + + if (swrast->Driver.WriteStencilSpan) { + /* Write updated stencil values into hardware stencil buffer */ + (swrast->Driver.WriteStencilSpan)(ctx, span->end, span->x, + span->y, stencil, span->mask ); + } + + span->write_all = GL_FALSE; + + return result; +} + |