Bug 1671054 - Decide AllowWebglOop after InitWebRenderConfig. r=lsalzman
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 27 Oct 2020 19:36:36 +0000
changeset 554777 fe27a1a3ec011267a19a83012da6fa1833851eb5
parent 554776 883f63709b7442c3cebfbdc12ff1821aea642c6d
child 554778 ac4b468736bbb053500307b587c211d26b95b5f7
push id37898
push userabutkovits@mozilla.com
push dateWed, 28 Oct 2020 09:24:21 +0000
treeherdermozilla-central@83bf4fd3b1fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1671054
milestone84.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1671054 - Decide AllowWebglOop after InitWebRenderConfig. r=lsalzman Differential Revision: https://phabricator.services.mozilla.com/D94785
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -940,16 +940,17 @@ void gfxPlatform::Init() {
   gPlatform = new gfxAndroidPlatform;
 #else
 #  error "No gfxPlatform implementation available"
 #endif
   gPlatform->PopulateScreenInfo();
   gPlatform->InitAcceleration();
   gPlatform->InitWebRenderConfig();
 
+  gPlatform->InitWebGLConfig();
   gPlatform->InitWebGPUConfig();
 
   // When using WebRender, we defer initialization of the D3D11 devices until
   // the (rare) cases where they're used. Note that the GPU process where
   // WebRender runs doesn't initialize gfxPlatform and performs explicit
   // initialization of the bits it needs.
   if (!UseWebRender()
 #if defined(XP_WIN) && defined(NIGHTLY_BUILD)
@@ -2542,72 +2543,16 @@ void gfxPlatform::InitAcceleration() {
       gfxCriticalNote << "Cannot evaluate keyed mutex feature status";
       gfxVars::SetAllowD3D11KeyedMutex(true);
     }
     if (StaticPrefs::gfx_direct3d11_use_double_buffering() &&
         IsWin10OrLater()) {
       gfxVars::SetUseDoubleBufferingWithCompositor(true);
     }
 #endif
-
-    if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_WEBGL2,
-                                               discardFailureId, &status))) {
-      gfxVars::SetAllowWebgl2(status == nsIGfxInfo::FEATURE_STATUS_OK);
-    }
-    if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_WEBGL_OPENGL,
-                                               discardFailureId, &status))) {
-      gfxVars::SetWebglAllowWindowsNativeGl(status ==
-                                            nsIGfxInfo::FEATURE_STATUS_OK);
-    }
-    if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_WEBGL_ANGLE,
-                                               discardFailureId, &status))) {
-      gfxVars::SetAllowWebglAccelAngle(status == nsIGfxInfo::FEATURE_STATUS_OK);
-    }
-
-    if (kIsMacOS) {
-      // Avoid crash for Intel HD Graphics 3000 on OSX. (Bug 1413269)
-      nsString vendorID, deviceID;
-      gfxInfo->GetAdapterVendorID(vendorID);
-      gfxInfo->GetAdapterDeviceID(deviceID);
-      if (vendorID.EqualsLiteral("0x8086") &&
-          (deviceID.EqualsLiteral("0x0116") ||
-           deviceID.EqualsLiteral("0x0126"))) {
-        gfxVars::SetWebglAllowCoreProfile(false);
-      }
-    }
-
-    const auto IsFeatureOk = [&](const int32_t feature) {
-      nsCString discardFailureId;
-      int32_t status;
-      MOZ_RELEASE_ASSERT(NS_SUCCEEDED(
-          gfxInfo->GetFeatureStatus(feature, discardFailureId, &status)));
-      return (status == nsIGfxInfo::FEATURE_STATUS_OK);
-    };
-
-    {
-      bool allowWebGLOop =
-          IsFeatureOk(nsIGfxInfo::FEATURE_ALLOW_WEBGL_OUT_OF_PROCESS);
-
-      const bool threadsafeGl = IsFeatureOk(nsIGfxInfo::FEATURE_THREADSAFE_GL);
-      if (gfxVars::UseWebRender() && !threadsafeGl) {
-        allowWebGLOop = false;
-      }
-
-      gfxVars::SetAllowWebglOop(allowWebGLOop);
-    }
-
-    if (kIsAndroid) {
-      // Don't enable robust buffer access on Adreno 630 devices.
-      // It causes the linking of some shaders to fail. See bug 1485441.
-      nsAutoString renderer;
-      gfxInfo->GetAdapterDeviceID(renderer);
-      if (renderer.Find("Adreno (TM) 630") != -1) {
-        gfxVars::SetAllowEglRbab(false);
-      }
-    }
   }
 
   if (Preferences::GetBool("media.hardware-video-decoding.enabled", false) &&
 #ifdef XP_WIN
       Preferences::GetBool("media.wmf.dxva.enabled", true) &&
 #endif
       NS_SUCCEEDED(
           gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
@@ -2864,16 +2809,72 @@ void gfxPlatform::InitWebRenderConfig() 
   gfxVars::SetUseWebRenderScissoredCacheClears(IsFeatureSupported(
       nsIGfxInfo::FEATURE_WEBRENDER_SCISSORED_CACHE_CLEARS, true));
 
   // The RemoveShaderCacheFromDiskIfNecessary() needs to be called after
   // WebRenderConfig initialization.
   gfxUtils::RemoveShaderCacheFromDiskIfNecessary();
 }
 
+void gfxPlatform::InitWebGLConfig() {
+  // Depends on InitWebRenderConfig() for UseWebRender().
+
+  if (!XRE_IsParentProcess()) return;
+
+  const nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
+
+  const auto IsFeatureOk = [&](const int32_t feature) {
+    nsCString discardFailureId;
+    int32_t status;
+    MOZ_RELEASE_ASSERT(NS_SUCCEEDED(
+        gfxInfo->GetFeatureStatus(feature, discardFailureId, &status)));
+    return (status == nsIGfxInfo::FEATURE_STATUS_OK);
+  };
+
+  gfxVars::SetAllowWebgl2(IsFeatureOk(nsIGfxInfo::FEATURE_WEBGL2));
+  gfxVars::SetWebglAllowWindowsNativeGl(
+      IsFeatureOk(nsIGfxInfo::FEATURE_WEBGL_OPENGL));
+  gfxVars::SetAllowWebglAccelAngle(
+      IsFeatureOk(nsIGfxInfo::FEATURE_WEBGL_ANGLE));
+
+  if (kIsMacOS) {
+    // Avoid crash for Intel HD Graphics 3000 on OSX. (Bug 1413269)
+    nsString vendorID, deviceID;
+    gfxInfo->GetAdapterVendorID(vendorID);
+    gfxInfo->GetAdapterDeviceID(deviceID);
+    if (vendorID.EqualsLiteral("0x8086") &&
+        (deviceID.EqualsLiteral("0x0116") ||
+         deviceID.EqualsLiteral("0x0126"))) {
+      gfxVars::SetWebglAllowCoreProfile(false);
+    }
+  }
+
+  {
+    bool allowWebGLOop =
+        IsFeatureOk(nsIGfxInfo::FEATURE_ALLOW_WEBGL_OUT_OF_PROCESS);
+
+    const bool threadsafeGl = IsFeatureOk(nsIGfxInfo::FEATURE_THREADSAFE_GL);
+    if (gfxVars::UseWebRender() && !threadsafeGl) {
+      allowWebGLOop = false;
+    }
+
+    gfxVars::SetAllowWebglOop(allowWebGLOop);
+  }
+
+  if (kIsAndroid) {
+    // Don't enable robust buffer access on Adreno 630 devices.
+    // It causes the linking of some shaders to fail. See bug 1485441.
+    nsAutoString renderer;
+    gfxInfo->GetAdapterDeviceID(renderer);
+    if (renderer.Find("Adreno (TM) 630") != -1) {
+      gfxVars::SetAllowEglRbab(false);
+    }
+  }
+}
+
 void gfxPlatform::InitWebGPUConfig() {
   FeatureState& feature = gfxConfig::GetFeature(Feature::WEBGPU);
   feature.SetDefaultFromPref("dom.webgpu.enabled", true, false);
 #ifndef NIGHTLY_BUILD
   feature.ForceDisable(FeatureStatus::Blocked,
                        "WebGPU can only be enabled in nightly",
                        "WEBGPU_DISABLE_NON_NIGHTLY"_ns);
 #endif
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -800,16 +800,17 @@ class gfxPlatform : public mozilla::laye
   static bool UseDesktopZoomingScrollbars();
 
  protected:
   gfxPlatform();
   virtual ~gfxPlatform();
 
   virtual void InitAcceleration();
   virtual void InitWebRenderConfig();
+  virtual void InitWebGLConfig();
   virtual void InitWebGPUConfig();
 
   virtual void GetPlatformDisplayInfo(mozilla::widget::InfoObject& aObj) {}
 
   /**
    * Called immediately before deleting the gfxPlatform object.
    */
   virtual void WillShutdown();