From 3ed3399a932c8906d4c4a7fd1ef108ced30141d4 Mon Sep 17 00:00:00 2001 From: Adrienne Walker Date: Tue, 15 May 2018 11:44:34 -0700 Subject: Driver bug workaround: restore_scissor_on_fbo_change Bug: chromium: 829614 Change-Id: I333aed9a378ab9b7aafaa96bb495378d1db4a61d Reviewed-on: https://skia-review.googlesource.com/127118 Commit-Queue: Adrienne Walker Reviewed-by: Brian Salomon --- src/gpu/GrCaps.h | 2 ++ src/gpu/gl/GrGLGpu.cpp | 16 ++++++++++++++++ src/gpu/gl/GrGLGpu.h | 2 ++ src/gpu/gl/GrGLRenderTarget.cpp | 2 ++ src/gpu/gpu_workaround_list.txt | 1 + 5 files changed, 23 insertions(+) (limited to 'src/gpu') diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h index ef06f3612a..b6758d1352 100644 --- a/src/gpu/GrCaps.h +++ b/src/gpu/GrCaps.h @@ -273,6 +273,8 @@ public: virtual bool getConfigFromBackendFormat(const GrBackendFormat& format, SkColorType ct, GrPixelConfig*) const = 0; + const GrDriverBugWorkarounds& workarounds() const { return fDriverBugWorkarounds; } + protected: /** Subclasses must call this at the end of their constructors in order to apply caps overrides requested by the client. Note that overrides will only reduce the caps never diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 908d367fcd..d957eb3c8a 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1353,6 +1353,7 @@ bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, fGLContext->caps()->markConfigAsValidColorAttachment(desc.fConfig); } + this->didBindFramebuffer(); return true; FAILED: @@ -2475,6 +2476,7 @@ void GrGLGpu::flushRenderTargetNoColorWrites(GrGLRenderTarget* target, bool disa if (fHWBoundRenderTargetUniqueID != rtID) { fStats.incRenderTargetBinds(); GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); + this->didBindFramebuffer(); #ifdef SK_DEBUG // don't do this check in Chromium -- this is causing // lots of repeated command buffer flushes when the compositor is @@ -3379,6 +3381,7 @@ void GrGLGpu::bindSurfaceFBOForPixelOps(GrSurface* surface, GrGLenum fboTarget, GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, rt->renderFBOID())); *viewport = rt->getViewport(); } + this->didBindFramebuffer(); } void GrGLGpu::unbindTextureFBOForPixelOps(GrGLenum fboTarget, GrSurface* surface) { @@ -3394,6 +3397,19 @@ void GrGLGpu::unbindTextureFBOForPixelOps(GrGLenum fboTarget, GrSurface* surface } } +void GrGLGpu::didBindFramebuffer() { + if (!this->caps()->workarounds().restore_scissor_on_fbo_change) { + return; + } + + // The driver forgets the correct scissor when modifying the FBO binding. + fHWScissorSettings.fRect.pushToGLScissor(this->glInterface()); + + // crbug.com/222018 - Also on QualComm, the flush here avoids flicker, + // it's unclear how this bug works. + GL_CALL(Flush()); +} + bool GrGLGpu::onCopySurface(GrSurface* dst, GrSurfaceOrigin dstOrigin, GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect, const SkIPoint& dstPoint, diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 43df889913..d09dd4cfa9 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -179,6 +179,8 @@ public: void insertEventMarker(const char*); + void didBindFramebuffer(); + private: GrGLGpu(std::unique_ptr, GrContext*); diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp index e996588ee0..693bc12fae 100644 --- a/src/gpu/gl/GrGLRenderTarget.cpp +++ b/src/gpu/gl/GrGLRenderTarget.cpp @@ -143,6 +143,8 @@ bool GrGLRenderTarget::completeStencilAttachment() { GR_GL_RENDERBUFFER, 0)); } + gpu->didBindFramebuffer(); + #ifdef SK_DEBUG if (kChromium_GrGLDriver != gpu->glContext().driver()) { // This check can cause problems in Chromium if the context has been asynchronously diff --git a/src/gpu/gpu_workaround_list.txt b/src/gpu/gpu_workaround_list.txt index aa1e1a2826..8425ca3d85 100644 --- a/src/gpu/gpu_workaround_list.txt +++ b/src/gpu/gpu_workaround_list.txt @@ -3,3 +3,4 @@ disable_discard_framebuffer disallow_large_instanced_draw max_msaa_sample_count_4 max_texture_size_limit_4096 +restore_scissor_on_fbo_change -- cgit v1.2.3