<div dir="ltr">Hello Mesa-Dev:<div><br></div><div>To give you some background, we are observing that mask values getting converted to -1 when running multiple dEQP-GLES31 tests in sequence.</div><div><br></div><div>There's already a previous commit (b8b1d83c71fd148d2fd84afdc20c0aa367114f92) that attempted to address the test failures by initializing all stencil values to 0xFF.</div><div><br></div><div>However, the test still fails when running all dEQP-GLES3.functional.state_query.integers#stencil_*_getfloat tests sequentially.</div><div><br></div><div>Apparently the test sets mask values to 0xffffffffU using glStencilFunc() API, and this overwrites the 0xFF initial value. Therefore I would propose that we sanitize all input stencil mask values.<br></div><div><br></div><div>Thanks,</div><div>Haixia</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 22, 2016 at 10:43 AM, Haixia Shi <span dir="ltr"><<a href="mailto:hshi@chromium.org" target="_blank">hshi@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Since the maximum supported precision for stencil buffers is 8 bits, we<br>
should set bits 8:31 in the input mask values to zero.<br>
<br>
The problem is that dEQP tests intentionally call glStencilFunc() with mask<br>
values of ~0U (0xffffffffU) which overflows to -1 when converted to signed<br>
integer by glGet* APIs.<br>
<br>
Fixes 6 dEQP failing tests:<br>
* dEQP-GLES3.functional.state_qu<wbr>ery.integers.stencil_value_mas<wbr>k_getfloat<br>
* dEQP-GLES3.functional.state_qu<wbr>ery.integers.stencil_back_valu<wbr>e_mask_getfloat<br>
* dEQP-GLES3.functional.state_qu<wbr>ery.integers.stencil_value_mas<wbr>k_separate_getfloat<br>
* dEQP-GLES3.functional.state_qu<wbr>ery.integers.stencil_value_mas<wbr>k_separate_both_getfloat<br>
* dEQP-GLES3.functional.state_qu<wbr>ery.integers.stencil_back_valu<wbr>e_mask_separate_getfloat<br>
* dEQP-GLES3.functional.state_qu<wbr>ery.integers.stencil_back_valu<wbr>e_mask_separate_both_getfloat<br>
<br>
Signed-off-by: Haixia Shi <<a href="mailto:hshi@chromium.org" target="_blank">hshi@chromium.org</a>><br>
Cc: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>><br>
---<br>
src/mesa/main/stencil.c | 20 ++++++++++++++++++++<br>
1 file changed, 20 insertions(+)<br>
<br>
diff --git a/src/mesa/main/stencil.c b/src/mesa/main/stencil.c<br>
index b303bb7..f29187c 100644<br>
--- a/src/mesa/main/stencil.c<br>
+++ b/src/mesa/main/stencil.c<br>
@@ -198,6 +198,11 @@ _mesa_StencilFunc( GLenum func, GLint ref, GLuint mask )<br>
return;<br>
}<br>
<br>
+ /* Since the maximum supported precision for stencil buffers is 8 bits,<br>
+ * set bits 8:31 in the input mask value to zero.<br>
+ */<br>
+ mask &= 0xFF;<br>
+<br>
if (face != 0) {<br>
if (ctx->Stencil.Function[face] == func &&<br>
ctx->Stencil.ValueMask[face] == mask &&<br>
@@ -258,6 +263,11 @@ _mesa_StencilMask( GLuint mask )<br>
if (MESA_VERBOSE & VERBOSE_API)<br>
_mesa_debug(ctx, "glStencilMask()\n");<br>
<br>
+ /* Since the maximum supported precision for stencil buffers is 8 bits,<br>
+ * set bits 8:31 in the input mask value to zero.<br>
+ */<br>
+ mask &= 0xFF;<br>
+<br>
if (face != 0) {<br>
/* Only modify the EXT_stencil_two_side back-face state.<br>
*/<br>
@@ -468,6 +478,11 @@ _mesa_StencilFuncSeparate(GLen<wbr>um face, GLenum func, GLint ref, GLuint mask)<br>
<br>
FLUSH_VERTICES(ctx, _NEW_STENCIL);<br>
<br>
+ /* Since the maximum supported precision for stencil buffers is 8 bits,<br>
+ * set bits 8:31 in the input mask value to zero.<br>
+ */<br>
+ mask &= 0xFF;<br>
+<br>
if (face != GL_BACK) {<br>
/* set front */<br>
ctx->Stencil.Function[0] = func;<br>
@@ -502,6 +517,11 @@ _mesa_StencilMaskSeparate(GLen<wbr>um face, GLuint mask)<br>
<br>
FLUSH_VERTICES(ctx, _NEW_STENCIL);<br>
<br>
+ /* Since the maximum supported precision for stencil buffers is 8 bits,<br>
+ * set bits 8:31 in the input mask value to zero.<br>
+ */<br>
+ mask &= 0xFF;<br>
+<br>
if (face != GL_BACK) {<br>
ctx->Stencil.WriteMask[0] = mask;<br>
}<br>
<span class="gmail-m_69046281073318776HOEnZb"><font color="#888888">--<br>
2.8.0.rc3.226.g39d4020<br>
<br>
</font></span></blockquote></div><br></div></div>