Unbind fbo before context switching for PowerVR GPUs

Imagination GL drivers are buggy with context switching.
We need to ubind fbo to workaround a crash in the driver.

Bug: chromium:1187513
Change-Id: Ie5142b5f43a3f23a9743ba7af0d90567fedd00d3
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2841083
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
This commit is contained in:
Peng Huang 2021-04-20 13:54:47 -04:00 коммит произвёл Commit Bot
Родитель 226259e5ec
Коммит be2f7b1cd2
4 изменённых файлов: 22 добавлений и 0 удалений

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

@ -542,6 +542,13 @@ struct FeaturesGL : FeatureSetBase
"sanitize_amdgpu_renderer_string", FeatureCategory::OpenGLWorkarounds,
"Strip precise kernel and DRM version information from amdgpu renderer strings.", &members,
"http://crbug.com/1181193"};
// Imagination GL drivers are buggy with context switching. We need to ubind fbo to workaround a
// crash in the driver.
Feature unbindFBOOnContextSwitch = {"unbind_fbo_before_switching_context",
FeatureCategory::OpenGLWorkarounds,
"Imagination GL drivers are buggy with context switching.",
&members, "http://crbug.com/1181193"};
};
inline FeaturesGL::FeaturesGL() = default;

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

@ -845,6 +845,15 @@ angle::Result ContextGL::onMakeCurrent(const gl::Context *context)
return mRenderer->getStateManager()->onMakeCurrent(context);
}
angle::Result ContextGL::onUnMakeCurrent(const gl::Context *context)
{
if (getFeaturesGL().unbindFBOOnContextSwitch.enabled)
{
mRenderer->getStateManager()->bindFramebuffer(GL_FRAMEBUFFER, 0);
}
return ContextImpl::onUnMakeCurrent(context);
}
gl::Caps ContextGL::getNativeCaps() const
{
return mRenderer->getNativeCaps();

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

@ -235,6 +235,7 @@ class ContextGL : public ContextImpl
// Context switching
angle::Result onMakeCurrent(const gl::Context *context) override;
angle::Result onUnMakeCurrent(const gl::Context *context) override;
// Caps queries
gl::Caps getNativeCaps() const override;

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

@ -2094,6 +2094,11 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
// On desktop Linux/AMD when using the amdgpu drivers, the precise kernel and DRM version are
// leaked via GL_RENDERER. We workaround this too improve user security.
ANGLE_FEATURE_CONDITION(features, sanitizeAmdGpuRendererString, IsLinux() && hasAMD);
// http://crbug.com/1187513
// Imagination drivers are buggy with context switching. It needs to unbind fbo before context
// switching to workadround the driver issues.
ANGLE_FEATURE_CONDITION(features, unbindFBOOnContextSwitch, IsPowerVR(vendor));
}
void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFeatures *features)