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: Jonah Ryan-Davis <jonahr@google.com>
This commit is contained in:
Geoff Lang 2019-07-09 16:10:59 -04:00 коммит произвёл Commit Bot
Родитель 2538f6b462
Коммит 2a4f36b14f
5 изменённых файлов: 38 добавлений и 5 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -198,7 +198,8 @@ RendererGL::RendererGL(std::unique_ptr<FunctionsGL> 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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -14,6 +14,7 @@
#include "libANGLE/State.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/renderer/gl/functionsgl_typedefs.h"
#include "platform/FeaturesGL.h"
#include <map>
@ -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;

Просмотреть файл

@ -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)