From 084340bb9bbb538baf02a11ac36e29f0d9cdc493 Mon Sep 17 00:00:00 2001 From: bsalomon Date: Wed, 11 Mar 2015 15:49:54 -0700 Subject: Add terrible workaround to fix stencil clear crash on S3. BUG=skia:3525 Review URL: https://codereview.chromium.org/1001693003 --- src/gpu/gl/GrGLGpu.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/gpu/gl') diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index b7901400fb..51fc42b995 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1210,8 +1210,27 @@ bool GrGLGpu::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, } GL_CALL(ClearStencil(0)); + // At least some versions of the SGX 54x driver can't handle clearing a stencil + // buffer without a color buffer and will crash. + GrGLuint tempRB = 0; + if (kPowerVR54x_GrGLRenderer == this->ctxInfo().renderer()) { + GL_CALL(GenRenderbuffers(1, &tempRB)); + GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, tempRB)); + GL_CALL(RenderbufferStorage(GR_GL_RENDERBUFFER, GR_GL_RGBA8, width, height)); + GL_CALL(FramebufferRenderbuffer(fboTarget, + GR_GL_COLOR_ATTACHMENT0, + GR_GL_RENDERBUFFER, tempRB)); + } + GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); + if (tempRB) { + GL_CALL(FramebufferRenderbuffer(fboTarget, + GR_GL_COLOR_ATTACHMENT0, + GR_GL_RENDERBUFFER, 0)); + GL_CALL(DeleteRenderbuffers(1, &tempRB)); + } + // Unbind the SB from the FBO so that we don't keep it alive. GL_CALL(FramebufferRenderbuffer(fboTarget, GR_GL_STENCIL_ATTACHMENT, -- cgit v1.2.3