Clamps the stencil reference value to the range representable in the currently-bound draw framebuffer's stencil attachment.
Signed-off-by: Chris Forbes <chr...@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 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev