Fix pow <small> and a very stypid bug with dummy srcs(0 equals to tmp0.x)</small...
[mesa.git] / src / mesa / main / stencil.c
index f03d94eb8f7b7e7b4141dbb13111af164adf4082..6b4d7e81eb8b8e25f642c40eb8e8608df98c922a 100644 (file)
@@ -95,7 +95,7 @@ void GLAPIENTRY
 _mesa_StencilFunc( GLenum func, GLint ref, GLuint mask )
 {
    GET_CURRENT_CONTEXT(ctx);
-   GLint maxref;
+   const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    switch (func) {
@@ -113,8 +113,7 @@ _mesa_StencilFunc( GLenum func, GLint ref, GLuint mask )
          return;
    }
 
-   maxref = (1 << STENCIL_BITS) - 1;
-   ref = CLAMP( ref, 0, maxref );
+   ref = CLAMP( ref, 0, stencilMax );
 
    if (ctx->Extensions.EXT_stencil_two_side) {
       /* only set active face state */
@@ -429,7 +428,7 @@ void GLAPIENTRY
 _mesa_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
 {
    GET_CURRENT_CONTEXT(ctx);
-   GLint maxref;
+   const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) {
@@ -452,8 +451,7 @@ _mesa_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
          return;
    }
 
-   maxref = (1 << STENCIL_BITS) - 1;
-   ref = CLAMP(ref, 0, maxref);
+   ref = CLAMP(ref, 0, stencilMax);
 
    FLUSH_VERTICES(ctx, _NEW_STENCIL);