diff --git a/src/libANGLE/Framebuffer.cpp b/src/libANGLE/Framebuffer.cpp index 0672c1298a..bandaid 100644 --- a/src/libANGLE/Framebuffer.cpp +++ b/src/libANGLE/Framebuffer.cpp @@ -1690,15 +1690,14 @@ bool Framebuffer::partialClearNeedsInit(const Context *context, { ASSERT(HasSupportedStencilBitCount(glState.getDrawFramebuffer())); - // The least significant |stencilBits| of stencil mask state specify a - // mask. Compare the masks for differences only in those bits, ignoring any - // difference in the high bits. - const auto &depthStencil = glState.getDepthStencilState(); - const GLuint differentFwdMasks = depthStencil.stencilMask ^ depthStencil.stencilWritemask; - const GLuint differentBackMasks = - depthStencil.stencilBackMask ^ depthStencil.stencilBackWritemask; - - if (((differentFwdMasks | differentBackMasks) & 0xFF) != 0) + // glClear honors GL_STENCIL_WRITEMASK only; GL_STENCIL_VALUE_MASK is + // irrelevant. The clear is a *full* clear of the stencil plane only when + // the writemask covers all stencil bits. If any bit is unwritable the + // clear is partial and the existing (uninitialized) bits would survive, + // so robust-resource-init must run first. + const auto &depthStencil = glState.getDepthStencilState(); + if ((depthStencil.stencilWritemask & 0xFF) != 0xFF || + (depthStencil.stencilBackWritemask & 0xFF) != 0xFF) { return true; }