Updated workaround for Intel 6xxx clear to 0/1 bug

The previous workaround only handled the glClearColor(0,0,0,1) case,
it turns out we need to work around any glClearColor made up of entirely
0s and 1s.

R=bsalomon@google.com
Bug: 710443
Change-Id: I78a75559fc11811ad9a218436231354d66d2ad51
Reviewed-on: https://skia-review.googlesource.com/17327
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Eric Karl <ericrk@chromium.org>
This commit is contained in:
Eric Karl 2017-05-18 15:08:09 -07:00 committed by Skia Commit-Bot
parent cb9cc70860
commit aeaf22bb07
3 changed files with 12 additions and 8 deletions

View File

@ -53,7 +53,7 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
fDoManualMipmapping = false;
fSRGBDecodeDisableSupport = false;
fSRGBDecodeDisableAffectsMipmaps = false;
fClearToOpaqueBlackIsBroken = false;
fClearToBoundaryValuesIsBroken = false;
fDrawArraysBaseVertexIsBroken = false;
fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag;
@ -571,7 +571,7 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
// See http://crbug.com/710443
#ifdef SK_BUILD_FOR_MAC
if (kIntel6xxx_GrGLRenderer == ctxInfo.renderer()) {
fClearToOpaqueBlackIsBroken = true;
fClearToBoundaryValuesIsBroken = true;
}
#endif
if (kQualcomm_GrGLVendor == ctxInfo.vendor()) {

View File

@ -359,7 +359,8 @@ public:
return fRGBAToBGRAReadbackConversionsAreSlow;
}
bool clearToOpaqueBlackIsBroken() const { return fClearToOpaqueBlackIsBroken; }
// Certain Intel GPUs on Mac fail to clear if the glClearColor is made up of only 1s and 0s.
bool clearToBoundaryValuesIsBroken() const { return fClearToBoundaryValuesIsBroken; }
// Adreno/MSAA drops a draw on the imagefiltersbase GM if the base vertex param to
// glDrawArrays is nonzero.
@ -437,7 +438,7 @@ private:
bool fDoManualMipmapping : 1;
bool fSRGBDecodeDisableSupport : 1;
bool fSRGBDecodeDisableAffectsMipmaps : 1;
bool fClearToOpaqueBlackIsBroken : 1;
bool fClearToBoundaryValuesIsBroken : 1;
bool fDrawArraysBaseVertexIsBroken : 1;
uint32_t fBlitFramebufferFlags;

View File

@ -2084,14 +2084,17 @@ void GrGLGpu::clear(const GrFixedClip& clip, GrColor color, GrRenderTarget* targ
GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE));
fHWWriteToColor = kYes_TriState;
if (this->glCaps().clearToOpaqueBlackIsBroken() && 0 == r && 0 == g && 0 == b && 1 == a) {
if (this->glCaps().clearToBoundaryValuesIsBroken() &&
(1 == r || 0 == r) && (1 == g || 0 == g) && (1 == b || 0 == b) && (1 == a || 0 == a)) {
#ifdef SK_BUILD_FOR_ANDROID
// Android doesn't have std::nextafter but has nextafter.
static const GrGLfloat safeAlpha = nextafter(1.f, 2.f);
static const GrGLfloat safeAlpha1 = nextafter(1.f, 2.f);
static const GrGLfloat safeAlpha0 = nextafter(0.f, -1.f);
#else
static const GrGLfloat safeAlpha = std::nextafter(1.f, 2.f);
static const GrGLfloat safeAlpha1 = std::nextafter(1.f, 2.f);
static const GrGLfloat safeAlpha0 = std::nextafter(0.f, -1.f);
#endif
a = safeAlpha;
a = (1 == a) ? safeAlpha1 : safeAlpha0;
}
GL_CALL(ClearColor(r, g, b, a));
GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT));