mesa: fix stencil state problem when GL_ATI_separate_stencil wasn't enabled

In glStencilFunc/Op/Mask() set both the front and back-face state, unless
GL_EXT_stencil_two_side is enabled.  Before, we only set the front+back state
if GL_ATI_separate_stencil was enabled.

Ultimately, we probably should remove GL_EXT_stencil_two_side since it's
incompatible with GL 2.x.
This commit is contained in:
Brian Paul 2008-07-14 09:55:33 -06:00
parent 6852ef64f3
commit 2833d4e715

View file

@ -207,7 +207,23 @@ _mesa_StencilFunc( GLenum func, GLint ref, GLuint mask )
ref = CLAMP( ref, 0, stencilMax );
if (ctx->Extensions.ATI_separate_stencil) {
if (ctx->Extensions.EXT_stencil_two_side) {
/* only set active face state */
const GLint face = ctx->Stencil.ActiveFace;
if (ctx->Stencil.Function[face] == func &&
ctx->Stencil.ValueMask[face] == mask &&
ctx->Stencil.Ref[face] == ref)
return;
FLUSH_VERTICES(ctx, _NEW_STENCIL);
ctx->Stencil.Function[face] = func;
ctx->Stencil.Ref[face] = ref;
ctx->Stencil.ValueMask[face] = mask;
if (ctx->Driver.StencilFuncSeparate) {
ctx->Driver.StencilFuncSeparate(ctx, face ? GL_BACK : GL_FRONT,
func, ref, mask);
}
}
else {
/* set both front and back state */
if (ctx->Stencil.Function[0] == func &&
ctx->Stencil.Function[1] == func &&
@ -225,22 +241,6 @@ _mesa_StencilFunc( GLenum func, GLint ref, GLuint mask )
func, ref, mask);
}
}
else {
/* only set active face state */
const GLint face = ctx->Stencil.ActiveFace;
if (ctx->Stencil.Function[face] == func &&
ctx->Stencil.ValueMask[face] == mask &&
ctx->Stencil.Ref[face] == ref)
return;
FLUSH_VERTICES(ctx, _NEW_STENCIL);
ctx->Stencil.Function[face] = func;
ctx->Stencil.Ref[face] = ref;
ctx->Stencil.ValueMask[face] = mask;
if (ctx->Driver.StencilFuncSeparate) {
ctx->Driver.StencilFuncSeparate(ctx, face ? GL_BACK : GL_FRONT,
func, ref, mask);
}
}
}
@ -261,18 +261,7 @@ _mesa_StencilMask( GLuint mask )
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (ctx->Extensions.ATI_separate_stencil) {
/* set both front and back state */
if (ctx->Stencil.WriteMask[0] == mask &&
ctx->Stencil.WriteMask[1] == mask)
return;
FLUSH_VERTICES(ctx, _NEW_STENCIL);
ctx->Stencil.WriteMask[0] = ctx->Stencil.WriteMask[1] = mask;
if (ctx->Driver.StencilMaskSeparate) {
ctx->Driver.StencilMaskSeparate(ctx, GL_FRONT_AND_BACK, mask);
}
}
else {
if (ctx->Extensions.EXT_stencil_two_side) {
/* only set active face state */
const GLint face = ctx->Stencil.ActiveFace;
if (ctx->Stencil.WriteMask[face] == mask)
@ -283,6 +272,17 @@ _mesa_StencilMask( GLuint mask )
ctx->Driver.StencilMaskSeparate(ctx, face ? GL_BACK : GL_FRONT, mask);
}
}
else {
/* set both front and back state */
if (ctx->Stencil.WriteMask[0] == mask &&
ctx->Stencil.WriteMask[1] == mask)
return;
FLUSH_VERTICES(ctx, _NEW_STENCIL);
ctx->Stencil.WriteMask[0] = ctx->Stencil.WriteMask[1] = mask;
if (ctx->Driver.StencilMaskSeparate) {
ctx->Driver.StencilMaskSeparate(ctx, GL_FRONT_AND_BACK, mask);
}
}
}
@ -319,7 +319,23 @@ _mesa_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
return;
}
if (ctx->Extensions.ATI_separate_stencil) {
if (ctx->Extensions.EXT_stencil_two_side) {
/* only set active face state */
const GLint face = ctx->Stencil.ActiveFace;
if (ctx->Stencil.ZFailFunc[face] == zfail &&
ctx->Stencil.ZPassFunc[face] == zpass &&
ctx->Stencil.FailFunc[face] == fail)
return;
FLUSH_VERTICES(ctx, _NEW_STENCIL);
ctx->Stencil.ZFailFunc[face] = zfail;
ctx->Stencil.ZPassFunc[face] = zpass;
ctx->Stencil.FailFunc[face] = fail;
if (ctx->Driver.StencilOpSeparate) {
ctx->Driver.StencilOpSeparate(ctx, face ? GL_BACK : GL_FRONT,
fail, zfail, zpass);
}
}
else {
/* set both front and back state */
if (ctx->Stencil.ZFailFunc[0] == zfail &&
ctx->Stencil.ZFailFunc[1] == zfail &&
@ -337,22 +353,6 @@ _mesa_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
fail, zfail, zpass);
}
}
else {
/* only set active face state */
const GLint face = ctx->Stencil.ActiveFace;
if (ctx->Stencil.ZFailFunc[face] == zfail &&
ctx->Stencil.ZPassFunc[face] == zpass &&
ctx->Stencil.FailFunc[face] == fail)
return;
FLUSH_VERTICES(ctx, _NEW_STENCIL);
ctx->Stencil.ZFailFunc[face] = zfail;
ctx->Stencil.ZPassFunc[face] = zpass;
ctx->Stencil.FailFunc[face] = fail;
if (ctx->Driver.StencilOpSeparate) {
ctx->Driver.StencilOpSeparate(ctx, face ? GL_BACK : GL_FRONT,
fail, zfail, zpass);
}
}
}
@ -463,12 +463,14 @@ _mesa_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
FLUSH_VERTICES(ctx, _NEW_STENCIL);
if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
if (face != GL_BACK) {
/* set front */
ctx->Stencil.Function[0] = func;
ctx->Stencil.Ref[0] = ref;
ctx->Stencil.ValueMask[0] = mask;
}
if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
if (face != GL_FRONT) {
/* set back */
ctx->Stencil.Function[1] = func;
ctx->Stencil.Ref[1] = ref;
ctx->Stencil.ValueMask[1] = mask;