Commit ce89d99f by Geoff Lang Committed by Commit Bot

GL: Flush after framebuffer change on Mac 9th gen Intel GPUs

Speculative fix for crashes during flush on Mac. Mirrors the flush_on_framebuffer_change workaround in Chrome from http://crbug.com/783979 Bug: chromium:1181068 Change-Id: Ic84b1bfc44babf27016b306393da308d504d7fd9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2859984Reviewed-by: 's avatarPeng Huang <penghuang@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 9c66461c
...@@ -549,6 +549,12 @@ struct FeaturesGL : FeatureSetBase ...@@ -549,6 +549,12 @@ struct FeaturesGL : FeatureSetBase
FeatureCategory::OpenGLWorkarounds, FeatureCategory::OpenGLWorkarounds,
"Imagination GL drivers are buggy with context switching.", "Imagination GL drivers are buggy with context switching.",
&members, "http://crbug.com/1181193"}; &members, "http://crbug.com/1181193"};
Feature flushOnFramebufferChange = {"flush_on_framebuffer_change",
FeatureCategory::OpenGLWorkarounds,
"Switching framebuffers without a flush can lead to "
"crashes on Intel 9th Generation GPU Macs.",
&members, "http://crbug.com/1181068"};
}; };
inline FeaturesGL::FeaturesGL() = default; inline FeaturesGL::FeaturesGL() = default;
......
...@@ -146,6 +146,11 @@ bool IsKabylake(uint32_t DeviceId) ...@@ -146,6 +146,11 @@ bool IsKabylake(uint32_t DeviceId)
return std::find(std::begin(Kabylake), std::end(Kabylake), DeviceId) != std::end(Kabylake); return std::find(std::begin(Kabylake), std::end(Kabylake), DeviceId) != std::end(Kabylake);
} }
bool Is9thGenIntel(uint32_t DeviceId)
{
return IsSkylake(DeviceId) || IsBroxton(DeviceId) || IsKabylake(DeviceId);
}
const char *GetVendorString(uint32_t vendorId) const char *GetVendorString(uint32_t vendorId)
{ {
switch (vendorId) switch (vendorId)
......
...@@ -152,6 +152,7 @@ bool IsCherryView(uint32_t DeviceId); ...@@ -152,6 +152,7 @@ bool IsCherryView(uint32_t DeviceId);
bool IsSkylake(uint32_t DeviceId); bool IsSkylake(uint32_t DeviceId);
bool IsBroxton(uint32_t DeviceId); bool IsBroxton(uint32_t DeviceId);
bool IsKabylake(uint32_t DeviceId); bool IsKabylake(uint32_t DeviceId);
bool Is9thGenIntel(uint32_t DeviceId);
// Platform helpers // Platform helpers
inline bool IsWindows() inline bool IsWindows()
......
...@@ -657,6 +657,7 @@ angle::Result StateManagerGL::setPixelPackBuffer(const gl::Context *context, ...@@ -657,6 +657,7 @@ angle::Result StateManagerGL::setPixelPackBuffer(const gl::Context *context,
void StateManagerGL::bindFramebuffer(GLenum type, GLuint framebuffer) void StateManagerGL::bindFramebuffer(GLenum type, GLuint framebuffer)
{ {
bool framebufferChanged = false;
switch (type) switch (type)
{ {
case GL_FRAMEBUFFER: case GL_FRAMEBUFFER:
...@@ -669,6 +670,8 @@ void StateManagerGL::bindFramebuffer(GLenum type, GLuint framebuffer) ...@@ -669,6 +670,8 @@ void StateManagerGL::bindFramebuffer(GLenum type, GLuint framebuffer)
mLocalDirtyBits.set(gl::State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); mLocalDirtyBits.set(gl::State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); mLocalDirtyBits.set(gl::State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING);
framebufferChanged = true;
} }
break; break;
...@@ -680,6 +683,8 @@ void StateManagerGL::bindFramebuffer(GLenum type, GLuint framebuffer) ...@@ -680,6 +683,8 @@ void StateManagerGL::bindFramebuffer(GLenum type, GLuint framebuffer)
mFunctions->bindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer); mFunctions->bindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); mLocalDirtyBits.set(gl::State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING);
framebufferChanged = true;
} }
break; break;
...@@ -691,6 +696,8 @@ void StateManagerGL::bindFramebuffer(GLenum type, GLuint framebuffer) ...@@ -691,6 +696,8 @@ void StateManagerGL::bindFramebuffer(GLenum type, GLuint framebuffer)
mFunctions->bindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer); mFunctions->bindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); mLocalDirtyBits.set(gl::State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING);
framebufferChanged = true;
} }
break; break;
...@@ -698,6 +705,11 @@ void StateManagerGL::bindFramebuffer(GLenum type, GLuint framebuffer) ...@@ -698,6 +705,11 @@ void StateManagerGL::bindFramebuffer(GLenum type, GLuint framebuffer)
UNREACHABLE(); UNREACHABLE();
break; break;
} }
if (framebufferChanged && mFeatures.flushOnFramebufferChange.enabled)
{
mFunctions->flush();
}
} }
void StateManagerGL::bindRenderbuffer(GLenum type, GLuint renderbuffer) void StateManagerGL::bindRenderbuffer(GLenum type, GLuint renderbuffer)
......
...@@ -1800,6 +1800,19 @@ bool GetSystemInfoVendorIDAndDeviceID(const FunctionsGL *functions, ...@@ -1800,6 +1800,19 @@ bool GetSystemInfoVendorIDAndDeviceID(const FunctionsGL *functions,
return isGetSystemInfoSuccess; return isGetSystemInfoSuccess;
} }
bool Has9thGenIntelGPU(const angle::SystemInfo &systemInfo)
{
for (const angle::GPUDeviceInfo &deviceInfo : systemInfo.gpus)
{
if (IsIntel(deviceInfo.vendorId) && Is9thGenIntel(deviceInfo.deviceId))
{
return true;
}
}
return false;
}
void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *features) void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *features)
{ {
angle::VendorID vendor; angle::VendorID vendor;
...@@ -2100,6 +2113,10 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature ...@@ -2100,6 +2113,10 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
// Imagination drivers are buggy with context switching. It needs to unbind fbo before context // Imagination drivers are buggy with context switching. It needs to unbind fbo before context
// switching to workadround the driver issues. // switching to workadround the driver issues.
ANGLE_FEATURE_CONDITION(features, unbindFBOOnContextSwitch, IsPowerVR(vendor)); ANGLE_FEATURE_CONDITION(features, unbindFBOOnContextSwitch, IsPowerVR(vendor));
// http://crbug.com/1181068 and http://crbug.com/783979
ANGLE_FEATURE_CONDITION(features, flushOnFramebufferChange,
IsApple() && Has9thGenIntelGPU(systemInfo));
} }
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