Workaround for Intel 6xxx clear to opaque black bug

Bug: skia:
Change-Id: Id5e29b483c2b6f698219abfc5bbb2d858c4fc117
Reviewed-on: https://skia-review.googlesource.com/16427
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Salomon 2017-05-11 11:39:08 -04:00 committed by Skia Commit-Bot
parent 7b1cc7625b
commit 028a9a5fcb
5 changed files with 33 additions and 0 deletions

View File

@ -53,6 +53,7 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
fDoManualMipmapping = false;
fSRGBDecodeDisableSupport = false;
fSRGBDecodeDisableAffectsMipmaps = false;
fClearToOpaqueBlackIsBroken = false;
fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag;
@ -572,6 +573,13 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
fSRGBDecodeDisableAffectsMipmaps = fSRGBDecodeDisableSupport &&
kChromium_GrGLDriver != ctxInfo.driver();
// See http://crbug.com/710443
#ifdef SK_BUILD_FOR_MAC
if (kIntel6xxx_GrGLRenderer == ctxInfo.renderer()) {
fClearToOpaqueBlackIsBroken = true;
}
#endif
// Requires fTextureRedSupport, fTextureSwizzleSupport, msaa support, ES compatibility have
// already been detected.
this->initConfigTable(contextOptions, ctxInfo, gli, shaderCaps);

View File

@ -359,6 +359,7 @@ public:
return fRGBAToBGRAReadbackConversionsAreSlow;
}
bool clearToOpaqueBlackIsBroken() const { return fClearToOpaqueBlackIsBroken; }
bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
bool* rectsMustMatch, bool* disallowSubrect) const override;
@ -430,6 +431,7 @@ private:
bool fDoManualMipmapping : 1;
bool fSRGBDecodeDisableSupport : 1;
bool fSRGBDecodeDisableAffectsMipmaps : 1;
bool fClearToOpaqueBlackIsBroken : 1;
uint32_t fBlitFramebufferFlags;

View File

@ -7,6 +7,7 @@
#include "GrGLGpu.h"
#include <cmath>
#include "../private/GrGLSL.h"
#include "GrBackendSurface.h"
#include "GrFixedClip.h"
@ -2104,6 +2105,16 @@ 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) {
#ifdef SK_BUILD_FOR_ANDROID
// Android doesn't have std::nextafter but has nextafter.
static const GrGLfloat safeAlpha = nextafter(1.f, 2.f);
#else
static const GrGLfloat safeAlpha = std::nextafter(1.f, 2.f);
#endif
a = safeAlpha;
}
GL_CALL(ClearColor(r, g, b, a));
GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT));
}

View File

@ -313,6 +313,16 @@ GrGLRenderer GrGLGetRendererFromString(const char* rendererString) {
}
}
}
int intelNumber;
n = sscanf(rendererString, "Intel(R) Iris(TM) Graphics %d", &intelNumber);
if (1 != n) {
n = sscanf(rendererString, "Intel(R) HD Graphics %d", &intelNumber);
}
if (1 == n) {
if (intelNumber >= 6000 && intelNumber < 7000) {
return kIntel6xxx_GrGLRenderer;
}
}
if (0 == strcmp("Mesa Offscreen", rendererString)) {
return kOSMesa_GrGLRenderer;
}

View File

@ -54,6 +54,8 @@ enum GrGLRenderer {
kAdreno4xx_GrGLRenderer,
kAdreno5xx_GrGLRenderer,
kOSMesa_GrGLRenderer,
/** Either HD 6xxx or Iris 6xxx */
kIntel6xxx_GrGLRenderer,
kOther_GrGLRenderer
};