From 0614b7a6f75d7ab0c7c524ca71199d242f2bd052 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 20 Jun 2017 18:23:07 +0200 Subject: mesa: add stencil_op_separate() helper Signed-off-by: Samuel Pitoiset Reviewed-by: Timothy Arceri --- src/mesa/main/stencil.c | 61 ++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 24 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/stencil.c b/src/mesa/main/stencil.c index 746775d2db6..fa68fa1bd0d 100644 --- a/src/mesa/main/stencil.c +++ b/src/mesa/main/stencil.c @@ -391,32 +391,11 @@ _mesa_ActiveStencilFaceEXT(GLenum face) } - -void GLAPIENTRY -_mesa_StencilOpSeparate(GLenum face, GLenum sfail, GLenum zfail, GLenum zpass) +static void +stencil_op_separate(struct gl_context *ctx, GLenum face, GLenum sfail, + GLenum zfail, GLenum zpass) { GLboolean set = GL_FALSE; - GET_CURRENT_CONTEXT(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glStencilOpSeparate()\n"); - - if (!validate_stencil_op(ctx, sfail)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(sfail)"); - return; - } - if (!validate_stencil_op(ctx, zfail)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zfail)"); - return; - } - if (!validate_stencil_op(ctx, zpass)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zpass)"); - return; - } - if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(face)"); - return; - } if (face != GL_BACK) { /* set front */ @@ -430,6 +409,7 @@ _mesa_StencilOpSeparate(GLenum face, GLenum sfail, GLenum zfail, GLenum zpass) set = GL_TRUE; } } + if (face != GL_FRONT) { /* set back */ if (ctx->Stencil.ZFailFunc[1] != zfail || @@ -442,12 +422,45 @@ _mesa_StencilOpSeparate(GLenum face, GLenum sfail, GLenum zfail, GLenum zpass) set = GL_TRUE; } } + if (set && ctx->Driver.StencilOpSeparate) { ctx->Driver.StencilOpSeparate(ctx, face, sfail, zfail, zpass); } } +void GLAPIENTRY +_mesa_StencilOpSeparate(GLenum face, GLenum sfail, GLenum zfail, GLenum zpass) +{ + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glStencilOpSeparate()\n"); + + if (!validate_stencil_op(ctx, sfail)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(sfail)"); + return; + } + + if (!validate_stencil_op(ctx, zfail)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zfail)"); + return; + } + + if (!validate_stencil_op(ctx, zpass)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zpass)"); + return; + } + + if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(face)"); + return; + } + + stencil_op_separate(ctx, face, sfail, zfail, zpass); +} + + static void stencil_func_separate(struct gl_context *ctx, GLenum face, GLenum func, GLint ref, GLuint mask) -- cgit v1.2.3