X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fstencil.c;h=93e2e97ce0c724d31cc0eaed9e2804c0c0c281d2;hb=04dca296e0a5e5ffbb8acb699e013a23ebd7b645;hp=6d6bbb2286b38b3b0fe8baa5c8096c50f0392e95;hpb=2a968113a925845331f0532a5a20d9fa1502c118;p=mesa.git diff --git a/src/mesa/main/stencil.c b/src/mesa/main/stencil.c index 6d6bbb2286b..93e2e97ce0c 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. */ @@ -39,7 +56,7 @@ static GLboolean -validate_stencil_op(GLcontext *ctx, GLenum op) +validate_stencil_op(struct gl_context *ctx, GLenum op) { switch (op) { case GL_KEEP: @@ -62,7 +79,7 @@ validate_stencil_op(GLcontext *ctx, GLenum op) static GLboolean -validate_stencil_func(GLcontext *ctx, GLenum func) +validate_stencil_func(struct gl_context *ctx, GLenum func) { switch (func) { case GL_NEVER: @@ -120,7 +137,7 @@ _mesa_ClearStencil( GLint s ) * \sa glStencilFunc(). * * Verifies the parameters and updates the respective values in - * __GLcontextRec::Stencil. On change flushes the vertices and notifies the + * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the * driver via the dd_function_table::StencilFunc callback. */ void GLAPIENTRY @@ -175,7 +192,7 @@ _mesa_StencilFuncSeparateATI( GLenum frontfunc, GLenum backfunc, GLint ref, GLui * \sa glStencilFunc(). * * Verifies the parameters and updates the respective values in - * __GLcontextRec::Stencil. On change flushes the vertices and notifies the + * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the * driver via the dd_function_table::StencilFunc callback. */ void GLAPIENTRY @@ -295,7 +312,7 @@ _mesa_StencilMask( GLuint mask ) * \sa glStencilOp(). * * Verifies the parameters and updates the respective fields in - * __GLcontextRec::Stencil. On change flushes the vertices and notifies the + * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the * driver via the dd_function_table::StencilOp callback. */ void GLAPIENTRY @@ -515,11 +532,15 @@ _mesa_StencilMaskSeparate(GLenum face, GLuint mask) * Update derived stencil state. */ void -_mesa_update_stencil(GLcontext *ctx) +_mesa_update_stencil(struct gl_context *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] || @@ -535,14 +556,14 @@ _mesa_update_stencil(GLcontext *ctx) * * \param ctx GL context. * - * Initializes __GLcontextRec::Stencil attribute group. + * Initializes __struct gl_contextRec::Stencil attribute group. */ void -_mesa_init_stencil(GLcontext *ctx) +_mesa_init_stencil(struct gl_context *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;