mesa: add _mesa_InternalBind{ElementBuffer,VertexBuffers} for glthread
[mesa.git] / src / mesa / main / stencil.h
index ccb864691893b477006c41e36f70b54c4971d780..dc371ec36cd8a7e4f9a9f4d22c655fcd0e973721 100644 (file)
@@ -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