From 6bd22ad430182f89dcbaab0275f0a77dcd83a5c9 Mon Sep 17 00:00:00 2001 From: Jamie Nicol Date: Wed, 10 Feb 2021 23:09:19 +0000 Subject: [PATCH] Bug 1689064 - Disable optimized shaders on Mali-T6xx. r=aosmond Webrender's pre-optimized shaders result in completely broken rendering on a Huawei MediaPad M2 (Mali-T628). As a precaution, disable optimized shaders on all Mali-T6xx devices. Differential Revision: https://phabricator.services.mozilla.com/D104752 --- gfx/config/gfxConfigManager.cpp | 12 +++++++++++ gfx/config/gfxConfigManager.h | 4 ++++ gfx/config/gfxFeature.h | 37 +++++++++++++++++---------------- gfx/thebes/gfxPlatform.cpp | 5 ++--- widget/GfxInfoBase.cpp | 3 +++ widget/android/GfxInfo.cpp | 16 ++++++++++++++ widget/nsIGfxInfo.idl | 4 +++- 7 files changed, 59 insertions(+), 22 deletions(-) diff --git a/gfx/config/gfxConfigManager.cpp b/gfx/config/gfxConfigManager.cpp index ce8d1b39c927..9f066dc40b88 100644 --- a/gfx/config/gfxConfigManager.cpp +++ b/gfx/config/gfxConfigManager.cpp @@ -38,6 +38,8 @@ void gfxConfigManager::Init() { StaticPrefs::layers_gpu_process_allow_software_AtStartup(); mWrPartialPresent = StaticPrefs::gfx_webrender_max_partial_present_rects_AtStartup() > 0; + mWrOptimizedShaders = + StaticPrefs::gfx_webrender_use_optimized_shaders_AtStartup(); #ifdef XP_WIN mWrForceAngle = StaticPrefs::gfx_webrender_force_angle_AtStartup(); mWrForceAngleNoGPUProcess = StaticPrefs:: @@ -76,6 +78,8 @@ void gfxConfigManager::Init() { mFeatureWrAngle = &gfxConfig::GetFeature(Feature::WEBRENDER_ANGLE); mFeatureWrDComp = &gfxConfig::GetFeature(Feature::WEBRENDER_DCOMP_PRESENT); mFeatureWrPartial = &gfxConfig::GetFeature(Feature::WEBRENDER_PARTIAL); + mFeatureWrOptimizedShaders = + &gfxConfig::GetFeature(Feature::WEBRENDER_OPTIMIZED_SHADERS); mFeatureWrSoftware = &gfxConfig::GetFeature(Feature::WEBRENDER_SOFTWARE); mFeatureHwCompositing = &gfxConfig::GetFeature(Feature::HW_COMPOSITING); @@ -403,6 +407,14 @@ void gfxConfigManager::ConfigureWebRender() { } } } + + mFeatureWrOptimizedShaders->EnableByDefault(); + if (!mWrOptimizedShaders) { + mFeatureWrOptimizedShaders->UserDisable("User disabled via pref", + "FEATURE_FAILURE_PREF_DISABLED"_ns); + } + ConfigureFromBlocklist(nsIGfxInfo::FEATURE_WEBRENDER_OPTIMIZED_SHADERS, + mFeatureWrOptimizedShaders); } } // namespace gfx diff --git a/gfx/config/gfxConfigManager.h b/gfx/config/gfxConfigManager.h index ee4324d8ca2e..4edde4c26110 100644 --- a/gfx/config/gfxConfigManager.h +++ b/gfx/config/gfxConfigManager.h @@ -24,6 +24,7 @@ class gfxConfigManager { mFeatureWrAngle(nullptr), mFeatureWrDComp(nullptr), mFeatureWrPartial(nullptr), + mFeatureWrOptimizedShaders(nullptr), mFeatureWrSoftware(nullptr), mFeatureHwCompositing(nullptr), mFeatureD3D11HwAngle(nullptr), @@ -37,6 +38,7 @@ class gfxConfigManager { mWrDCompWinEnabled(false), mWrCompositorDCompRequired(false), mWrPartialPresent(false), + mWrOptimizedShaders(false), mGPUProcessAllowSoftware(false), mXRenderEnabled(false), mWrEnvForceEnabled(false), @@ -65,6 +67,7 @@ class gfxConfigManager { FeatureState* mFeatureWrAngle; FeatureState* mFeatureWrDComp; FeatureState* mFeatureWrPartial; + FeatureState* mFeatureWrOptimizedShaders; FeatureState* mFeatureWrSoftware; FeatureState* mFeatureHwCompositing; @@ -84,6 +87,7 @@ class gfxConfigManager { bool mWrDCompWinEnabled; bool mWrCompositorDCompRequired; bool mWrPartialPresent; + bool mWrOptimizedShaders; bool mGPUProcessAllowSoftware; bool mXRenderEnabled; diff --git a/gfx/config/gfxFeature.h b/gfx/config/gfxFeature.h index a54d37303062..b0c240a50491 100644 --- a/gfx/config/gfxFeature.h +++ b/gfx/config/gfxFeature.h @@ -16,24 +16,25 @@ namespace mozilla { namespace gfx { -#define GFX_FEATURE_MAP(_) \ - /* Name, Type, Description */ \ - _(HW_COMPOSITING, Feature, "Compositing") \ - _(D3D11_COMPOSITING, Feature, "Direct3D11 Compositing") \ - _(OPENGL_COMPOSITING, Feature, "OpenGL Compositing") \ - _(DIRECT2D, Feature, "Direct2D") \ - _(D3D11_HW_ANGLE, Feature, "Direct3D11 hardware ANGLE") \ - _(DIRECT_DRAW, Feature, "DirectDraw") \ - _(GPU_PROCESS, Feature, "GPU Process") \ - _(WEBRENDER, Feature, "WebRender") \ - _(WEBRENDER_QUALIFIED, Feature, "WebRender qualified") \ - _(WEBRENDER_COMPOSITOR, Feature, "WebRender native compositor") \ - _(WEBRENDER_PARTIAL, Feature, "WebRender partial present") \ - _(WEBRENDER_ANGLE, Feature, "WebRender ANGLE") \ - _(WEBRENDER_DCOMP_PRESENT, Feature, "WebRender DirectComposition") \ - _(WEBRENDER_SOFTWARE, Feature, "WebRender software fallback") \ - _(OMTP, Feature, "Off Main Thread Painting") \ - _(WEBGPU, Feature, "WebGPU") \ +#define GFX_FEATURE_MAP(_) \ + /* Name, Type, Description */ \ + _(HW_COMPOSITING, Feature, "Compositing") \ + _(D3D11_COMPOSITING, Feature, "Direct3D11 Compositing") \ + _(OPENGL_COMPOSITING, Feature, "OpenGL Compositing") \ + _(DIRECT2D, Feature, "Direct2D") \ + _(D3D11_HW_ANGLE, Feature, "Direct3D11 hardware ANGLE") \ + _(DIRECT_DRAW, Feature, "DirectDraw") \ + _(GPU_PROCESS, Feature, "GPU Process") \ + _(WEBRENDER, Feature, "WebRender") \ + _(WEBRENDER_QUALIFIED, Feature, "WebRender qualified") \ + _(WEBRENDER_COMPOSITOR, Feature, "WebRender native compositor") \ + _(WEBRENDER_PARTIAL, Feature, "WebRender partial present") \ + _(WEBRENDER_OPTIMIZED_SHADERS, Feature, "WebRender optimized shaders") \ + _(WEBRENDER_ANGLE, Feature, "WebRender ANGLE") \ + _(WEBRENDER_DCOMP_PRESENT, Feature, "WebRender DirectComposition") \ + _(WEBRENDER_SOFTWARE, Feature, "WebRender software fallback") \ + _(OMTP, Feature, "Off Main Thread Painting") \ + _(WEBGPU, Feature, "WebGPU") \ /* Add new entries above this comment */ enum class Feature : uint32_t { diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 6c09fcc7f5f3..23a10f035718 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -2733,9 +2733,8 @@ void gfxPlatform::InitWebRenderConfig() { gfxVars::SetUseWebRenderProgramBinaryDisk(hasWebRender); } - if (StaticPrefs::gfx_webrender_use_optimized_shaders_AtStartup()) { - gfxVars::SetUseWebRenderOptimizedShaders(hasWebRender); - } + gfxVars::SetUseWebRenderOptimizedShaders( + gfxConfig::IsEnabled(Feature::WEBRENDER_OPTIMIZED_SHADERS)); gfxVars::SetUseSoftwareWebRender(!hasHardware && hasSoftware); diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index baa8923d8545..a255b076f0d8 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -228,6 +228,9 @@ static const char* GetPrefNameForFeature(int32_t aFeature) { case nsIGfxInfo::FEATURE_WEBRENDER_SOFTWARE: name = BLOCKLIST_PREF_BRANCH "webrender.software"; break; + case nsIGfxInfo::FEATURE_WEBRENDER_OPTIMIZED_SHADERS: + name = BLOCKLIST_PREF_BRANCH "webrender.optimized-shaders"; + break; default: MOZ_ASSERT_UNREACHABLE("Unexpected nsIGfxInfo feature?!"); break; diff --git a/widget/android/GfxInfo.cpp b/widget/android/GfxInfo.cpp index cd3e612e2a97..f91213b8aaf6 100644 --- a/widget/android/GfxInfo.cpp +++ b/widget/android/GfxInfo.cpp @@ -653,6 +653,22 @@ nsresult GfxInfo::GetFeatureStatusImpl( } return NS_OK; } + + if (aFeature == FEATURE_WEBRENDER_OPTIMIZED_SHADERS) { + // Optimized shaders result in completely broken rendering in at least one + // Mali-T6xx device. Disable on all T6xx as a precaution until we know + // more specifically which devices are affected. See bug 1689064 for + // details. + const bool isMaliT6xx = + mGLStrings->Renderer().Find("Mali-T6", /*ignoreCase*/ true) >= 0; + if (isMaliT6xx) { + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; + aFailureId = "FEATURE_FAILURE_BUG_1689064"; + } else { + *aStatus = nsIGfxInfo::FEATURE_STATUS_OK; + } + return NS_OK; + } } return GfxInfoBase::GetFeatureStatusImpl( diff --git a/widget/nsIGfxInfo.idl b/widget/nsIGfxInfo.idl index 566c9b48c162..d6ee299e41d3 100644 --- a/widget/nsIGfxInfo.idl +++ b/widget/nsIGfxInfo.idl @@ -171,8 +171,10 @@ interface nsIGfxInfo : nsISupports const long FEATURE_THREADSAFE_GL = 31; /* Support running WebRender using the software backend, starting in 84. */ const long FEATURE_WEBRENDER_SOFTWARE = 32; + /* Whether webrender uses pre-optimized shaders, starting in 87. */ + const long FEATURE_WEBRENDER_OPTIMIZED_SHADERS = 33; /* the maximum feature value. */ - const long FEATURE_MAX_VALUE = FEATURE_WEBRENDER_SOFTWARE; + const long FEATURE_MAX_VALUE = FEATURE_WEBRENDER_OPTIMIZED_SHADERS; /* * A set of return values from GetFeatureStatus