[virglrenderer-devel] [PATCH 1/1] Fixes stencil cleaning issue in OpenGL ES3

Robert Tarasov tutankhamen at chromium.org
Thu Mar 15 01:41:44 UTC 2018


Resets stencil buffer write mask to ~0u before glClear().
Fixes many tests which use stencil buffer with increment, decrement or
invert operations. For example:
dEQP-GLES3.functional.fragment_ops.random.18
dEQP-GLES3.functional.fragment_ops.random.25
dEQP-GLES3.functional.fragment_ops.interaction.basic_shader.2
---
 src/vrend_renderer.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 70fbdca..02d26be 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -2470,8 +2470,10 @@ void vrend_clear(struct vrend_context *ctx,
       }
    }
 
-   if (buffers & PIPE_CLEAR_STENCIL)
+   if (buffers & PIPE_CLEAR_STENCIL) {
+      glStencilMask(~0u);
       glClearStencil(stencil);
+   }
 
    if (buffers & PIPE_CLEAR_COLOR) {
       uint32_t mask = 0;
@@ -2510,6 +2512,12 @@ void vrend_clear(struct vrend_context *ctx,
       if (!ctx->sub->dsa_state.depth.writemask)
          glDepthMask(GL_FALSE);
 
+   /* Restore previous stencil buffer write masks for both front and back faces */
+   if (buffers & PIPE_CLEAR_STENCIL) {
+      glStencilMaskSeparate(GL_FRONT, ctx->sub->dsa_state.stencil[0].writemask);
+      glStencilMaskSeparate(GL_BACK, ctx->sub->dsa_state.stencil[1].writemask);
+   }
+
    /* Restore previous colormask */
    if (buffers & PIPE_CLEAR_COLOR) {
       if (ctx->sub->hw_blend_state.independent_blend_enable) {
-- 
2.16.2.804.g6dcf76e118-goog



More information about the virglrenderer-devel mailing list