X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fstencil.c;h=15c98e2015668db089dfaea90fb3697c8ed0474f;hb=e661bf50183bf5481ee0d6c8e6be0809da991913;hp=b4ea9978d874bfc858083d1db81992537285c167;hpb=53116910b10e3b8a05f42970eff311c21808699f;p=mesa.git diff --git a/src/mesa/main/stencil.c b/src/mesa/main/stencil.c index b4ea9978d87..15c98e20156 100644 --- a/src/mesa/main/stencil.c +++ b/src/mesa/main/stencil.c @@ -27,6 +27,23 @@ * \file stencil.c * Stencil operations. * + * Note: There's some conflict between GL_EXT_stencil_two_side and + * OpenGL 2.0's two-sided stencil feature. + * + * With GL_EXT_stencil_two_side, calling glStencilOp/Func/Mask() only the + * front OR back face state (as set by glActiveStencilFaceEXT) is set. + * + * But with OpenGL 2.0, calling glStencilOp/Func/Mask() sets BOTH the + * front AND back state. + * + * Also, note that GL_ATI_separate_stencil is different as well: + * glStencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, ...) vs. + * glStencilFuncSeparate(GLenum face, GLenum func, ...). + * + * This problem is solved by keeping three sets of stencil state: + * state[0] = GL_FRONT state. + * state[1] = OpenGL 2.0 / GL_ATI_separate_stencil GL_BACK state. + * state[2] = GL_EXT_stencil_two_side GL_BACK state. */ @@ -519,7 +536,11 @@ _mesa_update_stencil(GLcontext *ctx) { const GLint face = ctx->Stencil._BackFace; - ctx->Stencil._TestTwoSide = + ctx->Stencil._Enabled = (ctx->Stencil.Enabled && + ctx->DrawBuffer->Visual.stencilBits > 0); + + ctx->Stencil._TestTwoSide = + ctx->Stencil._Enabled && (ctx->Stencil.Function[0] != ctx->Stencil.Function[face] || ctx->Stencil.FailFunc[0] != ctx->Stencil.FailFunc[face] || ctx->Stencil.ZPassFunc[0] != ctx->Stencil.ZPassFunc[face] || @@ -542,7 +563,7 @@ _mesa_init_stencil(GLcontext *ctx) { ctx->Stencil.Enabled = GL_FALSE; ctx->Stencil.TestTwoSide = GL_FALSE; - ctx->Stencil.ActiveFace = 0; /* 0 = GL_FRONT, 1 = GL_BACK */ + ctx->Stencil.ActiveFace = 0; /* 0 = GL_FRONT, 2 = GL_BACK */ ctx->Stencil.Function[0] = GL_ALWAYS; ctx->Stencil.Function[1] = GL_ALWAYS; ctx->Stencil.Function[2] = GL_ALWAYS; @@ -565,4 +586,5 @@ _mesa_init_stencil(GLcontext *ctx) ctx->Stencil.WriteMask[1] = ~0U; ctx->Stencil.WriteMask[2] = ~0U; ctx->Stencil.Clear = 0; + ctx->Stencil._BackFace = 1; }