[Mesa-dev] [PATCH 1/8] mesa: add accessor for effective stencil ref
Chris Forbes
chrisf at ijw.co.nz
Mon May 13 04:10:50 PDT 2013
Clamps the stencil reference value to the range representable in the
currently-bound draw framebuffer's stencil attachment.
Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
src/mesa/main/stencil.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/mesa/main/stencil.h b/src/mesa/main/stencil.h
index 1d5e01c..ea67437 100644
--- a/src/mesa/main/stencil.h
+++ b/src/mesa/main/stencil.h
@@ -79,4 +79,13 @@ _mesa_update_stencil(struct gl_context *ctx);
extern void
_mesa_init_stencil( struct gl_context * ctx );
+
+static inline GLint
+_mesa_get_stencil_ref(struct gl_context const *ctx, int face)
+{
+ GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1;
+ GLint ref = ctx->Stencil.Ref[face];
+ return CLAMP(ref, 0, stencilMax);
+}
+
#endif
--
1.8.2.3
More information about the mesa-dev
mailing list