summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2001-02-23 20:08:29 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2001-02-23 20:08:29 +0000
commit74b775e14de000027492f6ea3c836aa82f850d21 (patch)
tree7c30507e17eaabc7748dd18657afa5f264ae5bf8
parentdab76b4dc585f5833003ff3a0e53c256bf974d47 (diff)
fixed bug in _mesa_stencil_and_ztest_pixels() found w/ DRI mga driver
-rw-r--r--src/mesa/swrast/s_stencil.c55
1 files changed, 29 insertions, 26 deletions
diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c
index 8ce6c0ae5a..5f308ab28c 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.5 2001/01/23 23:39:37 brianp Exp $ */
+/* $Id: s_stencil.c,v 1.6 2001/02/23 20:08:29 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -916,47 +916,50 @@ _mesa_stencil_and_ztest_pixels( GLcontext *ctx,
if (ctx->Driver.WriteStencilPixels) {
/*** Hardware stencil buffer ***/
GLstencil stencil[PB_SIZE];
- GLubyte mask[PB_SIZE];
+ GLubyte origMask[PB_SIZE];
ASSERT(ctx->Driver.ReadStencilPixels);
(*ctx->Driver.ReadStencilPixels)(ctx, n, x, y, stencil);
-
- if (do_stencil_test( ctx, n, stencil, mask ) == GL_FALSE) {
+ if (do_stencil_test(ctx, n, stencil, mask) == GL_FALSE) {
/* all fragments failed the stencil test, we're done. */
return GL_FALSE;
}
+ MEMCPY(origMask, mask, n * sizeof(GLubyte));
+
if (ctx->Depth.Test == GL_FALSE) {
- apply_stencil_op( ctx, ctx->Stencil.ZPassFunc, n, stencil, mask );
+ apply_stencil_op(ctx, ctx->Stencil.ZPassFunc, n, stencil, mask);
}
else {
- GLubyte passmask[PB_SIZE], failmask[PB_SIZE], oldmask[PB_SIZE];
- GLuint i;
-
- MEMCPY(oldmask, mask, n * sizeof(GLubyte));
-
_mesa_depth_test_pixels(ctx, n, x, y, z, mask);
- for (i=0;i<n;i++) {
- ASSERT(mask[i] == 0 || mask[i] == 1);
- passmask[i] = oldmask[i] & mask[i];
- failmask[i] = oldmask[i] & (mask[i] ^ 1);
- }
-
if (ctx->Stencil.ZFailFunc != GL_KEEP) {
- apply_stencil_op( ctx, ctx->Stencil.ZFailFunc, n, stencil, failmask );
+ GLubyte failmask[PB_SIZE];
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ ASSERT(mask[i] == 0 || mask[i] == 1);
+ failmask[i] = origMask[i] & (mask[i] ^ 1);
+ }
+ apply_stencil_op(ctx, ctx->Stencil.ZFailFunc,
+ n, stencil, failmask);
}
if (ctx->Stencil.ZPassFunc != GL_KEEP) {
- apply_stencil_op( ctx, ctx->Stencil.ZPassFunc, n, stencil, passmask );
+ GLubyte passmask[PB_SIZE];
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ ASSERT(mask[i] == 0 || mask[i] == 1);
+ passmask[i] = origMask[i] & mask[i];
+ }
+ apply_stencil_op(ctx, ctx->Stencil.ZPassFunc,
+ n, stencil, passmask);
}
}
/* Write updated stencil values into hardware stencil buffer */
- (ctx->Driver.WriteStencilPixels)(ctx, n, x, y, stencil, mask );
+ (ctx->Driver.WriteStencilPixels)(ctx, n, x, y, stencil, origMask);
return GL_TRUE;
-
}
else {
/*** Software stencil buffer ***/
@@ -966,9 +969,9 @@ _mesa_stencil_and_ztest_pixels( GLcontext *ctx,
return GL_FALSE;
}
-
if (ctx->Depth.Test==GL_FALSE) {
- apply_stencil_op_to_pixels( ctx, n, x, y, ctx->Stencil.ZPassFunc, mask );
+ apply_stencil_op_to_pixels(ctx, n, x, y,
+ ctx->Stencil.ZPassFunc, mask);
}
else {
GLubyte passmask[PB_SIZE], failmask[PB_SIZE], oldmask[PB_SIZE];
@@ -985,12 +988,12 @@ _mesa_stencil_and_ztest_pixels( GLcontext *ctx,
}
if (ctx->Stencil.ZFailFunc != GL_KEEP) {
- apply_stencil_op_to_pixels( ctx, n, x, y,
- ctx->Stencil.ZFailFunc, failmask );
+ apply_stencil_op_to_pixels(ctx, n, x, y,
+ ctx->Stencil.ZFailFunc, failmask);
}
if (ctx->Stencil.ZPassFunc != GL_KEEP) {
- apply_stencil_op_to_pixels( ctx, n, x, y,
- ctx->Stencil.ZPassFunc, passmask );
+ apply_stencil_op_to_pixels(ctx, n, x, y,
+ ctx->Stencil.ZPassFunc, passmask);
}
}