Bug 1271770 - Fallback to WARP if accelerated ANGLE fails r=BenWa,jrmuizel, a=sylvestre
authoreyim <eyim@mozilla.com>
Wed, 13 Jul 2016 13:51:40 -0400
changeset 342051 b283934782589961e1585b2ea130c92ad0883789
parent 342050 70ca7c42db312a2a07aad0560aff0bd1fc48de02
child 342052 a9e8f70d870c1492bc3d64d3ac2f21f033d125cf
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBenWa, jrmuizel, sylvestre
bugs1271770
milestone49.0a2
Bug 1271770 - Fallback to WARP if accelerated ANGLE fails r=BenWa,jrmuizel, a=sylvestre MozReview-Commit-ID: LDJON8Vie5R
gfx/gl/GLLibraryEGL.cpp
--- a/gfx/gl/GLLibraryEGL.cpp
+++ b/gfx/gl/GLLibraryEGL.cpp
@@ -390,45 +390,41 @@ GLLibraryEGL::EnsureInitialized(bool for
     // Check the ANGLE support the system has
     nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
     mIsANGLE = IsExtensionSupported(ANGLE_platform_angle);
 
     EGLDisplay chosenDisplay = nullptr;
 
     if (IsExtensionSupported(ANGLE_platform_angle_d3d)) {
         bool accelAngleSupport = IsAccelAngleSupported(gfxInfo, aFailureId);
+        bool shouldTryAccel = forceAccel || accelAngleSupport;
+        bool shouldTryWARP = !forceAccel; // Only if ANGLE not supported or fails
 
-        bool shouldTryAccel = forceAccel || accelAngleSupport;
-        bool shouldTryWARP = !shouldTryAccel;
+        // If WARP preferred, will override ANGLE support
         if (gfxPrefs::WebGLANGLEForceWARP()) {
             shouldTryWARP = true;
             shouldTryAccel = false;
         }
 
-        // Fallback to a WARP display if non-WARP is blacklisted, or if WARP is forced.
-        if (shouldTryWARP) {
-            chosenDisplay = GetAndInitWARPDisplay(*this, EGL_DEFAULT_DISPLAY);
-            if (chosenDisplay) {
-                mIsWARP = true;
-            }
+        // Hardware accelerated ANGLE path (supported or force accel)
+        if (shouldTryAccel) {
+            chosenDisplay = GetAndInitDisplayForAccelANGLE(*this);
         }
 
-        if (!chosenDisplay) {
-            // If falling back to WARP did not work and we don't want to try
-            // using HW accelerated ANGLE, then fail.
-            if (!shouldTryAccel) {
+        // Fallback to a WARP display if ANGLE fails, or if WARP is forced
+        if (!chosenDisplay && shouldTryWARP) {
+            chosenDisplay = GetAndInitWARPDisplay(*this, EGL_DEFAULT_DISPLAY);
+            if (!chosenDisplay) {
                 if (aFailureId.IsEmpty()) {
                     aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WARP_FALLBACK");
                 }
-                NS_ERROR("Fallback WARP ANGLE context failed to initialize.");
+                NS_ERROR("Fallback WARP context failed to initialize.");
                 return false;
             }
-
-            // Hardware accelerated ANGLE path
-            chosenDisplay = GetAndInitDisplayForAccelANGLE(*this);
+            mIsWARP = true;
         }
     } else {
         chosenDisplay = GetAndInitDisplay(*this, EGL_DEFAULT_DISPLAY);
     }
 
     if (!chosenDisplay) {
         if (aFailureId.IsEmpty()) {
             aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NO_DISPLAY");