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>
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index ba05316..5b6d45a 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -53,7 +53,7 @@
fDoManualMipmapping = false;
fSRGBDecodeDisableSupport = false;
fSRGBDecodeDisableAffectsMipmaps = false;
- fClearToOpaqueBlackIsBroken = false;
+ fClearToBoundaryValuesIsBroken = false;
fDrawArraysBaseVertexIsBroken = false;
fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag;
@@ -571,7 +571,7 @@
// 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()) {
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 6948583..de3d847 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -359,7 +359,8 @@
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 @@
bool fDoManualMipmapping : 1;
bool fSRGBDecodeDisableSupport : 1;
bool fSRGBDecodeDisableAffectsMipmaps : 1;
- bool fClearToOpaqueBlackIsBroken : 1;
+ bool fClearToBoundaryValuesIsBroken : 1;
bool fDrawArraysBaseVertexIsBroken : 1;
uint32_t fBlitFramebufferFlags;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index c52d1d1..a24a259 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2084,14 +2084,17 @@
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));