diff options
author | Marek Olšák <[email protected]> | 2017-06-09 20:37:34 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-06-22 01:48:30 +0200 |
commit | c2408838c83719cb133332c7adac71ef50503259 (patch) | |
tree | e09e430dd0678f4398b500824966ce16114bde51 /src/mesa/main/stencil.h | |
parent | d28cc798bdf10c7e85189dc2dc3461d63e2fbfc7 (diff) |
mesa: replace _mesa_update_stencil() with helper functions
The idea is to remove the dependency on _mesa_update_state_locked,
so that st/mesa can skip it for stencil state updates, and then stop
setting _NEW_STENCIL in mesa/main if the driver is st/mesa.
The main motivation is to stop invoking _mesa_update_state_locked for
certain state groups.
Reviewed-by: Nicolai Hähnle <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa/main/stencil.h')
-rw-r--r-- | src/mesa/main/stencil.h | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/src/mesa/main/stencil.h b/src/mesa/main/stencil.h index ccb86469189..dc371ec36cd 100644 --- a/src/mesa/main/stencil.h +++ b/src/mesa/main/stencil.h @@ -86,11 +86,6 @@ _mesa_StencilMaskSeparate_no_error(GLenum face, GLuint mask); extern void GLAPIENTRY _mesa_StencilMaskSeparate(GLenum face, GLuint mask); - -extern void -_mesa_update_stencil(struct gl_context *ctx); - - extern void _mesa_init_stencil( struct gl_context * ctx ); @@ -108,4 +103,35 @@ _mesa_get_stencil_ref(struct gl_context const *ctx, int face) return CLAMP(ref, 0, stencilMax); } +static inline bool +_mesa_stencil_is_enabled(const struct gl_context *ctx) +{ + return ctx->Stencil.Enabled && + ctx->DrawBuffer->Visual.stencilBits > 0; +} + +static inline bool +_mesa_stencil_is_two_sided(const struct gl_context *ctx) +{ + const int face = ctx->Stencil._BackFace; + + return _mesa_stencil_is_enabled(ctx) && + (ctx->Stencil.Function[0] != ctx->Stencil.Function[face] || + ctx->Stencil.FailFunc[0] != ctx->Stencil.FailFunc[face] || + ctx->Stencil.ZPassFunc[0] != ctx->Stencil.ZPassFunc[face] || + ctx->Stencil.ZFailFunc[0] != ctx->Stencil.ZFailFunc[face] || + ctx->Stencil.Ref[0] != ctx->Stencil.Ref[face] || + ctx->Stencil.ValueMask[0] != ctx->Stencil.ValueMask[face] || + ctx->Stencil.WriteMask[0] != ctx->Stencil.WriteMask[face]); +} + +static inline bool +_mesa_stencil_is_write_enabled(const struct gl_context *ctx, bool is_two_sided) +{ + return _mesa_stencil_is_enabled(ctx) && + (ctx->Stencil.WriteMask[0] != 0 || + (is_two_sided && + ctx->Stencil.WriteMask[ctx->Stencil._BackFace] != 0)); +} + #endif |