<div dir="auto">Should ref also get clamped?</div><div class="gmail_extra"><br><div class="gmail_quote">On Dec 17, 2016 1:03 AM, "Kenneth Graunke" <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Commit b8b1d83c71fd148d2fd84afdc20c0a<wbr>a367114f92 partially fixed<br>
dEQP-GLES3.functional.state_<wbr>query.integers.stencil*value*<wbr>mask*getfloat<br>
by changing the initial value masks from 32-bit ~0 (0xFFFFFFFF) to 0xFF.<br>
<br>
However, the application can call glStencilFunc and related functions<br>
to set a new value mask, which is a 32-bit quantity.  The application<br>
might specify 0xFFFFFFFF, bringing us back to the original problem.<br>
<br>
In particular, dEQP's state reset code seems to do this, so the tests<br>
still fail when running the entire suite from one process, rather than<br>
running the tests individually.<br>
<br>
This patch clamps the value masks to 0xFF when setting them.  Higher<br>
bits have no effect on an 8-bit stencil buffer anyway.<br>
<br>
This might break apps that set a value mask then try to query it back<br>
with glGet and expect to get the same value.  I'm unclear whether apps<br>
can reasonably expect that anyway.<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
 src/mesa/main/stencil.c | 10 +++++-----<br>
 1 file changed, 5 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/src/mesa/main/stencil.c b/src/mesa/main/stencil.c<br>
index b303bb7..608c564 100644<br>
--- a/src/mesa/main/stencil.c<br>
+++ b/src/mesa/main/stencil.c<br>
@@ -161,7 +161,7 @@ _mesa_StencilFuncSeparateATI( GLenum frontfunc, GLenum backfunc, GLint ref, GLui<br>
    ctx->Stencil.Function[0]  = frontfunc;<br>
    ctx->Stencil.Function[1]  = backfunc;<br>
    ctx->Stencil.Ref[0]       = ctx->Stencil.Ref[1]       = ref;<br>
-   ctx->Stencil.ValueMask[0] = ctx->Stencil.ValueMask[1] = mask;<br>
+   ctx->Stencil.ValueMask[0] = ctx->Stencil.ValueMask[1] = mask & 0xFF;<br>
    if (ctx->Driver.<wbr>StencilFuncSeparate) {<br>
       ctx->Driver.<wbr>StencilFuncSeparate(ctx, GL_FRONT,<br>
                                       frontfunc, ref, mask);<br>
@@ -206,7 +206,7 @@ _mesa_StencilFunc( GLenum func, GLint ref, GLuint mask )<br>
       FLUSH_VERTICES(ctx, _NEW_STENCIL);<br>
       ctx->Stencil.Function[face] = func;<br>
       ctx->Stencil.Ref[face] = ref;<br>
-      ctx->Stencil.ValueMask[face] = mask;<br>
+      ctx->Stencil.ValueMask[face] = mask & 0xFF;<br>
<br>
       /* Only propagate the change to the driver if EXT_stencil_two_side<br>
        * is enabled.<br>
@@ -227,7 +227,7 @@ _mesa_StencilFunc( GLenum func, GLint ref, GLuint mask )<br>
       FLUSH_VERTICES(ctx, _NEW_STENCIL);<br>
       ctx->Stencil.Function[0]  = ctx->Stencil.Function[1]  = func;<br>
       ctx->Stencil.Ref[0]       = ctx->Stencil.Ref[1]       = ref;<br>
-      ctx->Stencil.ValueMask[0] = ctx->Stencil.ValueMask[1] = mask;<br>
+      ctx->Stencil.ValueMask[0] = ctx->Stencil.ValueMask[1] = mask & 0xFF;<br>
       if (ctx->Driver.<wbr>StencilFuncSeparate) {<br>
          ctx->Driver.<wbr>StencilFuncSeparate(ctx,<br>
                                         ((ctx->Stencil.TestTwoSide)<br>
@@ -472,13 +472,13 @@ _mesa_StencilFuncSeparate(<wbr>GLenum face, GLenum func, GLint ref, GLuint mask)<br>
       /* set front */<br>
       ctx->Stencil.Function[0] = func;<br>
       ctx->Stencil.Ref[0] = ref;<br>
-      ctx->Stencil.ValueMask[0] = mask;<br>
+      ctx->Stencil.ValueMask[0] = mask & 0xFF;<br>
    }<br>
    if (face != GL_FRONT) {<br>
       /* set back */<br>
       ctx->Stencil.Function[1] = func;<br>
       ctx->Stencil.Ref[1] = ref;<br>
-      ctx->Stencil.ValueMask[1] = mask;<br>
+      ctx->Stencil.ValueMask[1] = mask & 0xFF;<br>
    }<br>
    if (ctx->Driver.<wbr>StencilFuncSeparate) {<br>
       ctx->Driver.<wbr>StencilFuncSeparate(ctx, face, func, ref, mask);<br>
--<br>
2.10.2<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div>