Commit 2a4f36b1 by Geoff Lang Committed by Commit Bot

GL: Work around Intel driver bug when clearing to zeros or ones.

When clearing to zeros or ones on some Intel drivers on Mac, the clear color would be incorrect. This replicates the chromium clear_to_zero_or_one_broken workaround. BUG=angleproject:3672 Change-Id: I0f065420b577bd8f8d931ccdbeeebdcbf9fd08d2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1692977 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent 2538f6b4
...@@ -306,6 +306,13 @@ struct FeaturesGL : FeatureSetBase ...@@ -306,6 +306,13 @@ struct FeaturesGL : FeatureSetBase
"Reset texture base level before calling glTexImage2D to " "Reset texture base level before calling glTexImage2D to "
"work around pixel comparison failure.", "work around pixel comparison failure.",
&members, "https://crbug.com/705865"}; &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; inline FeaturesGL::FeaturesGL() = default;
......
...@@ -198,7 +198,8 @@ RendererGL::RendererGL(std::unique_ptr<FunctionsGL> functions, ...@@ -198,7 +198,8 @@ RendererGL::RendererGL(std::unique_ptr<FunctionsGL> functions,
ASSERT(mFunctions); ASSERT(mFunctions);
nativegl_gl::InitializeFeatures(mFunctions.get(), &mFeatures); nativegl_gl::InitializeFeatures(mFunctions.get(), &mFeatures);
OverrideFeaturesWithDisplayState(&mFeatures, display->getState()); 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); mBlitter = new BlitGL(mFunctions.get(), mFeatures, mStateManager);
mMultiviewClearer = new ClearMultiviewGL(mFunctions.get(), mStateManager); mMultiviewClearer = new ClearMultiviewGL(mFunctions.get(), mStateManager);
......
...@@ -38,8 +38,10 @@ StateManagerGL::IndexedBufferBinding::IndexedBufferBinding() : offset(0), size(0 ...@@ -38,8 +38,10 @@ StateManagerGL::IndexedBufferBinding::IndexedBufferBinding() : offset(0), size(0
StateManagerGL::StateManagerGL(const FunctionsGL *functions, StateManagerGL::StateManagerGL(const FunctionsGL *functions,
const gl::Caps &rendererCaps, const gl::Caps &rendererCaps,
const gl::Extensions &extensions) const gl::Extensions &extensions,
const angle::FeaturesGL &features)
: mFunctions(functions), : mFunctions(functions),
mFeatures(features),
mProgram(0), mProgram(0),
mVAO(0), mVAO(0),
mVertexAttribCurrentValues(rendererCaps.maxVertexAttributes), mVertexAttribCurrentValues(rendererCaps.maxVertexAttributes),
...@@ -1475,9 +1477,26 @@ void StateManagerGL::setClearDepth(float clearDepth) ...@@ -1475,9 +1477,26 @@ void StateManagerGL::setClearDepth(float clearDepth)
void StateManagerGL::setClearColor(const gl::ColorF &clearColor) 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, mFunctions->clearColor(mClearColor.red, mClearColor.green, mClearColor.blue,
mClearColor.alpha); mClearColor.alpha);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "libANGLE/State.h" #include "libANGLE/State.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/renderer/gl/functionsgl_typedefs.h" #include "libANGLE/renderer/gl/functionsgl_typedefs.h"
#include "platform/FeaturesGL.h"
#include <map> #include <map>
...@@ -38,7 +39,8 @@ class StateManagerGL final : angle::NonCopyable ...@@ -38,7 +39,8 @@ class StateManagerGL final : angle::NonCopyable
public: public:
StateManagerGL(const FunctionsGL *functions, StateManagerGL(const FunctionsGL *functions,
const gl::Caps &rendererCaps, const gl::Caps &rendererCaps,
const gl::Extensions &extensions); const gl::Extensions &extensions,
const angle::FeaturesGL &features);
~StateManagerGL(); ~StateManagerGL();
void deleteProgram(GLuint program); void deleteProgram(GLuint program);
...@@ -198,6 +200,7 @@ class StateManagerGL final : angle::NonCopyable ...@@ -198,6 +200,7 @@ class StateManagerGL final : angle::NonCopyable
const gl::FramebufferState &drawFramebufferState) const; const gl::FramebufferState &drawFramebufferState) const;
const FunctionsGL *mFunctions; const FunctionsGL *mFunctions;
const angle::FeaturesGL &mFeatures;
GLuint mProgram; GLuint mProgram;
......
...@@ -1517,6 +1517,9 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature ...@@ -1517,6 +1517,9 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
features->resetTexImage2DBaseLevel.enabled = features->resetTexImage2DBaseLevel.enabled =
IsApple() && IsIntel(vendor) && GetMacOSVersion() >= OSVersion(10, 12, 4); 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) void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFeatures *features)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment