diff --git a/include/platform/FeaturesGL.h b/include/platform/FeaturesGL.h index 08ecd7348..5dfa7e33c 100644 --- a/include/platform/FeaturesGL.h +++ b/include/platform/FeaturesGL.h @@ -306,6 +306,13 @@ struct FeaturesGL : FeatureSetBase "Reset texture base level before calling glTexImage2D to " "work around pixel comparison failure.", &members, "https://crbug.com/705865"}; + + // glClearColor does not always work on Intel 6xxx Mac drivers when the clear color made up of + // all zeros and ones. + Feature clearToZeroOrOneBroken = { + "clear_to_zero_or_one_broken", FeatureCategory::OpenGLWorkarounds, + "Clears when the clear color is all zeros or ones do not work.", &members, + "https://crbug.com/710443"}; }; inline FeaturesGL::FeaturesGL() = default; diff --git a/src/libANGLE/renderer/gl/RendererGL.cpp b/src/libANGLE/renderer/gl/RendererGL.cpp index 888bf7d3c..658d4b973 100644 --- a/src/libANGLE/renderer/gl/RendererGL.cpp +++ b/src/libANGLE/renderer/gl/RendererGL.cpp @@ -198,7 +198,8 @@ RendererGL::RendererGL(std::unique_ptr functions, ASSERT(mFunctions); nativegl_gl::InitializeFeatures(mFunctions.get(), &mFeatures); OverrideFeaturesWithDisplayState(&mFeatures, display->getState()); - mStateManager = new StateManagerGL(mFunctions.get(), getNativeCaps(), getNativeExtensions()); + mStateManager = + new StateManagerGL(mFunctions.get(), getNativeCaps(), getNativeExtensions(), mFeatures); mBlitter = new BlitGL(mFunctions.get(), mFeatures, mStateManager); mMultiviewClearer = new ClearMultiviewGL(mFunctions.get(), mStateManager); diff --git a/src/libANGLE/renderer/gl/StateManagerGL.cpp b/src/libANGLE/renderer/gl/StateManagerGL.cpp index a6c755ea6..74754bd4d 100644 --- a/src/libANGLE/renderer/gl/StateManagerGL.cpp +++ b/src/libANGLE/renderer/gl/StateManagerGL.cpp @@ -38,8 +38,10 @@ StateManagerGL::IndexedBufferBinding::IndexedBufferBinding() : offset(0), size(0 StateManagerGL::StateManagerGL(const FunctionsGL *functions, const gl::Caps &rendererCaps, - const gl::Extensions &extensions) + const gl::Extensions &extensions, + const angle::FeaturesGL &features) : mFunctions(functions), + mFeatures(features), mProgram(0), mVAO(0), mVertexAttribCurrentValues(rendererCaps.maxVertexAttributes), @@ -1475,9 +1477,26 @@ void StateManagerGL::setClearDepth(float clearDepth) void StateManagerGL::setClearColor(const gl::ColorF &clearColor) { - if (mClearColor != clearColor) + gl::ColorF modifiedClearColor = clearColor; + if (mFeatures.clearToZeroOrOneBroken.enabled && + (clearColor.red == 1.0f || clearColor.red == 0.0f) && + (clearColor.green == 1.0f || clearColor.green == 0.0f) && + (clearColor.blue == 1.0f || clearColor.blue == 0.0f) && + (clearColor.alpha == 1.0f || clearColor.alpha == 0.0f)) { - mClearColor = clearColor; + if (clearColor.alpha == 1.0f) + { + modifiedClearColor.alpha = 2.0f; + } + else + { + modifiedClearColor.alpha = -1.0f; + } + } + + if (mClearColor != modifiedClearColor) + { + mClearColor = modifiedClearColor; mFunctions->clearColor(mClearColor.red, mClearColor.green, mClearColor.blue, mClearColor.alpha); diff --git a/src/libANGLE/renderer/gl/StateManagerGL.h b/src/libANGLE/renderer/gl/StateManagerGL.h index c3841b9d6..7a654ce78 100644 --- a/src/libANGLE/renderer/gl/StateManagerGL.h +++ b/src/libANGLE/renderer/gl/StateManagerGL.h @@ -14,6 +14,7 @@ #include "libANGLE/State.h" #include "libANGLE/angletypes.h" #include "libANGLE/renderer/gl/functionsgl_typedefs.h" +#include "platform/FeaturesGL.h" #include @@ -38,7 +39,8 @@ class StateManagerGL final : angle::NonCopyable public: StateManagerGL(const FunctionsGL *functions, const gl::Caps &rendererCaps, - const gl::Extensions &extensions); + const gl::Extensions &extensions, + const angle::FeaturesGL &features); ~StateManagerGL(); void deleteProgram(GLuint program); @@ -198,6 +200,7 @@ class StateManagerGL final : angle::NonCopyable const gl::FramebufferState &drawFramebufferState) const; const FunctionsGL *mFunctions; + const angle::FeaturesGL &mFeatures; GLuint mProgram; diff --git a/src/libANGLE/renderer/gl/renderergl_utils.cpp b/src/libANGLE/renderer/gl/renderergl_utils.cpp index 27fd4a117..b5c97dee3 100644 --- a/src/libANGLE/renderer/gl/renderergl_utils.cpp +++ b/src/libANGLE/renderer/gl/renderergl_utils.cpp @@ -1517,6 +1517,9 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature features->resetTexImage2DBaseLevel.enabled = IsApple() && IsIntel(vendor) && GetMacOSVersion() >= OSVersion(10, 12, 4); + + features->clearToZeroOrOneBroken.enabled = + IsApple() && IsIntel(vendor) && GetMacOSVersion() < OSVersion(10, 12, 6); } void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFeatures *features)