<div dir="ltr"><div>I don't see any spec justification for masking this. dEQP is broken here. Implementations have the flexibility to retain more bits in the mask (and have more bits set in the initial state) than the depth of the deepest stencil buffer supported. From the ES3 spec, 4.1.4, second to last para:</div><div><br></div><div> "In the initial state, ... , and the front and back stencil mask are both set to the value 2^s - 1, where s is greater than or equal to the number of bits in the deepest stencil buffer supported by the GL implementation"</div><div><br></div><div>/ref/ is specified as being clamped on use and on query, which ought to be indistinguishable from clamping it upfront.</div><div><br></div><div>- Chris</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 18, 2016 at 4:44 AM, Jason Ekstrand <span dir="ltr"><<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Should ref also get clamped?</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Dec 17, 2016 1:03 AM, "Kenneth Graunke" <<a href="mailto:kenneth@whitecape.org" target="_blank">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_qu<wbr>ery.integers.stencil*value*mas<wbr>k*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" target="_blank">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.StencilFuncSepara<wbr>te) {<br>
ctx->Driver.StencilFuncSepara<wbr>te(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.StencilFuncSepara<wbr>te) {<br>
ctx->Driver.StencilFuncSeparat<wbr>e(ctx,<br>
((ctx->Stencil.TestTwoSide)<br>
@@ -472,13 +472,13 @@ _mesa_StencilFuncSeparate(GLen<wbr>um 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.StencilFuncSepara<wbr>te) {<br>
ctx->Driver.StencilFuncSepara<wbr>te(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" target="_blank">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>
</div></div><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>
<br></blockquote></div><br></div>