Bug 1563264 - More early-exits to reduce nesting and maybe increase clarity. r=jrmuizel
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 04 Jul 2019 18:54:44 +0000
changeset 544169 5edc3595af5cc7301888aae1d3527df73cd0abf4
parent 544168 d74f7bb86aa3091d4269b4c756cef2d49036238c
child 544170 ca50879f67b35654e9f89b1222bcbc8ff013eab1
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1563264
milestone69.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 1563264 - More early-exits to reduce nesting and maybe increase clarity. r=jrmuizel Depends on D36779 Differential Revision: https://phabricator.services.mozilla.com/D36780
gfx/thebes/gfxPlatform.cpp
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -2606,54 +2606,65 @@ static bool CalculateWrQualifiedPrefValu
   // above to abort early as the pref would have a valid type.
   //  We also don't want those prefs to appear in about:config.
   if (Preferences::HasUserValue(WR_ROLLOUT_PREF_OVERRIDE)) {
     return Preferences::GetBool(WR_ROLLOUT_PREF_OVERRIDE);
   }
   return Preferences::GetBool(WR_ROLLOUT_PREF, WR_ROLLOUT_PREF_DEFAULTVALUE);
 }
 
+static void HardwareTooOldForWR(FeatureState& aFeature) {
+  aFeature.Disable(
+      FeatureStatus::BlockedDeviceTooOld, "Device too old",
+      NS_LITERAL_CSTRING("FEATURE_FAILURE_DEVICE_TOO_OLD"));
+}
+
 static void UpdateWRQualificationForNvidia(FeatureState& aFeature,
     int32_t aDeviceId) {
-  if (aDeviceId < 0x6c0) {
-    // 0x6c0 is the lowest Fermi device id. Unfortunately some Tesla
-    // devices that don't support D3D 10.1 have higher deviceIDs. They
-    // will be included, but blocked by ANGLE.
-    aFeature.Disable(
-        FeatureStatus::BlockedDeviceTooOld, "Device too old",
-        NS_LITERAL_CSTRING("FEATURE_FAILURE_DEVICE_TOO_OLD"));
+  // 0x6c0 is the lowest Fermi device id. Unfortunately some Tesla
+  // devices that don't support D3D 10.1 have higher deviceIDs. They
+  // will be included, but blocked by ANGLE.
+  bool supported = aDeviceId >= 0x6c0;
+
+  if (!supported) {
+    HardwareTooOldForWR(aFeature);
+    return;
   }
+
+  // Any additional Nvidia checks go here
 }
 
 static void UpdateWRQualificationForAMD(FeatureState& aFeature,
     int32_t aDeviceId) {
   // AMD deviceIDs are not very well ordered. This
   // condition is based off the information in gpu-db
-  if ((aDeviceId >= 0x6600 && aDeviceId < 0x66b0) ||
+  bool supported =
+      (aDeviceId >= 0x6600 && aDeviceId < 0x66b0) ||
       (aDeviceId >= 0x6700 && aDeviceId < 0x6720) ||
       (aDeviceId >= 0x6780 && aDeviceId < 0x6840) ||
       (aDeviceId >= 0x6860 && aDeviceId < 0x6880) ||
       (aDeviceId >= 0x6900 && aDeviceId < 0x6a00) ||
       (aDeviceId == 0x7300) ||
       (aDeviceId >= 0x9830 && aDeviceId < 0x9870) ||
-      (aDeviceId >= 0x9900 && aDeviceId < 0x9a00)) {
-    // we have a desktop CAYMAN, SI, CIK, VI, or GFX9 device
-    // so treat the device as qualified unless it is not Windows
-    // and not nightly.
+      (aDeviceId >= 0x9900 && aDeviceId < 0x9a00);
+
+  if (!supported) {
+    HardwareTooOldForWR(aFeature);
+    return;
+  }
+
+  // we have a desktop CAYMAN, SI, CIK, VI, or GFX9 device
+  // so treat the device as qualified unless it is not Windows
+  // and not nightly.
 #if !defined(XP_WIN) && !defined(NIGHTLY_BUILD)
-    aFeature.Disable(
-        FeatureStatus::BlockedReleaseChannelAMD,
-        "Release channel and AMD",
-        NS_LITERAL_CSTRING("FEATURE_FAILURE_RELEASE_CHANNEL_AMD"));
+  aFeature.Disable(
+      FeatureStatus::BlockedReleaseChannelAMD,
+      "Release channel and AMD",
+      NS_LITERAL_CSTRING("FEATURE_FAILURE_RELEASE_CHANNEL_AMD"));
 #endif  // !XPWIN && !NIGHTLY_BUILD
-  } else {
-    aFeature.Disable(
-        FeatureStatus::BlockedDeviceTooOld, "Device too old",
-        NS_LITERAL_CSTRING("FEATURE_FAILURE_DEVICE_TOO_OLD"));
-  }
 }
 
 static void UpdateWRQualificationForIntel(FeatureState& aFeature,
     int32_t aDeviceId, int32_t aScreenPixels) {
   const uint16_t supportedDevices[] = {
       // skylake gt2+
       0x1912,
       0x1913,
@@ -2738,45 +2749,44 @@ static void UpdateWRQualificationForInte
   };
   bool supported = false;
   for (uint16_t id : supportedDevices) {
     if (aDeviceId == id) {
       supported = true;
       break;
     }
   }
-  if (supported) {
+  if (!supported) {
+    HardwareTooOldForWR(aFeature);
+    return;
+  }
+
 #ifdef MOZ_WIDGET_GTK
-    // Performance is not great on 4k screens with WebRender + Linux.
-    // Disable it for now if it is too large.
-    const int32_t kMaxPixelsLinux = 3440 * 1440;  // UWQHD
-    if (aScreenPixels > kMaxPixelsLinux) {
-      aFeature.Disable(
-          FeatureStatus::BlockedScreenTooLarge, "Screen size too large",
-          NS_LITERAL_CSTRING("FEATURE_FAILURE_SCREEN_SIZE_TOO_LARGE"));
-    } else if (aScreenPixels <= 0) {
-      aFeature.Disable(
-          FeatureStatus::BlockedScreenUnknown, "Screen size unknown",
-          NS_LITERAL_CSTRING("FEATURE_FAILURE_SCREEN_SIZE_UNKNOWN"));
-    } else {
+  // Performance is not great on 4k screens with WebRender + Linux.
+  // Disable it for now if it is too large.
+  const int32_t kMaxPixelsLinux = 3440 * 1440;  // UWQHD
+  if (aScreenPixels > kMaxPixelsLinux) {
+    aFeature.Disable(
+        FeatureStatus::BlockedScreenTooLarge, "Screen size too large",
+        NS_LITERAL_CSTRING("FEATURE_FAILURE_SCREEN_SIZE_TOO_LARGE"));
+  } else if (aScreenPixels <= 0) {
+    aFeature.Disable(
+        FeatureStatus::BlockedScreenUnknown, "Screen size unknown",
+        NS_LITERAL_CSTRING("FEATURE_FAILURE_SCREEN_SIZE_UNKNOWN"));
+  } else {
 #endif  // MOZ_WIDGET_GTK
 #ifndef NIGHTLY_BUILD
-      aFeature.Disable(
-          FeatureStatus::BlockedReleaseChannelIntel,
-          "Release channel and Intel",
-          NS_LITERAL_CSTRING("FEATURE_FAILURE_RELEASE_CHANNEL_INTEL"));
+    aFeature.Disable(
+        FeatureStatus::BlockedReleaseChannelIntel,
+        "Release channel and Intel",
+        NS_LITERAL_CSTRING("FEATURE_FAILURE_RELEASE_CHANNEL_INTEL"));
 #endif  // !NIGHTLY_BUILD
 #ifdef MOZ_WIDGET_GTK
-    }
+  }
 #endif  // MOZ_WIDGET_GTK
-  } else {
-    aFeature.Disable(
-        FeatureStatus::BlockedDeviceTooOld, "Device too old",
-        NS_LITERAL_CSTRING("FEATURE_FAILURE_DEVICE_TOO_OLD"));
-  }
 }
 
 static FeatureState& WebRenderHardwareQualificationStatus(
     const IntSize& aScreenSize, bool aHasBattery, nsCString& aOutFailureId) {
   FeatureState& featureWebRenderQualified =
       gfxConfig::GetFeature(Feature::WEBRENDER_QUALIFIED);
   featureWebRenderQualified.EnableByDefault();
 
@@ -2829,19 +2839,24 @@ static FeatureState& WebRenderHardwareQu
     UpdateWRQualificationForIntel(featureWebRenderQualified, deviceID,
                                   screenPixels);
   } else {
     featureWebRenderQualified.Disable(
         FeatureStatus::BlockedVendorUnsupported, "Unsupported vendor",
         NS_LITERAL_CSTRING("FEATURE_FAILURE_UNSUPPORTED_VENDOR"));
   }
 
+  if (!featureWebRenderQualified.IsEnabled()) {
+    // One of the checks above failed, early exit
+    return featureWebRenderQualified;
+  }
+
   // We leave checking the battery for last because we would like to know
   // which users were denied WebRender only because they have a battery.
-  if (featureWebRenderQualified.IsEnabled() && aHasBattery) {
+  if (aHasBattery) {
     // For AMD/Intel devices, if we have a battery, ignore it if the
     // screen is small enough. Note that we always check for a battery
     // with NVIDIA because we do not have a limited/curated set of devices
     // to support WebRender on.
     const int32_t kMaxPixelsBattery = 1920 * 1200;  // WUXGA
     if ((adapterVendorID == u"0x8086" || adapterVendorID == u"0x1002") &&
         screenPixels > 0 && screenPixels <= kMaxPixelsBattery) {
 #ifndef NIGHTLY_BUILD