Bug 1287653 - Blacklist dx_interop2. - r=milan draft
authorJeff Gilbert <jgilbert@mozilla.com>
Thu, 28 Jul 2016 19:44:58 -0700
changeset 394106 b66730d390fc8953fc8dfe7e0bc4500fdf4c6cb7
parent 394105 edca0339544f4afe4137fe15caac571f829d0300
child 395246 1e1bf22481ef0bc149d1bfbfdcc00d0ca90b18fa
push id24492
push userbmo:jgilbert@mozilla.com
push dateFri, 29 Jul 2016 03:02:43 +0000
reviewersmilan
bugs1287653
milestone50.0a1
Bug 1287653 - Blacklist dx_interop2. - r=milan MozReview-Commit-ID: GYyUIXYvcp1
gfx/gl/GLContextProviderWGL.cpp
gfx/thebes/gfxPrefs.h
gfx/thebes/gfxUtils.cpp
gfx/thebes/gfxUtils.h
modules/libpref/init/all.js
--- a/gfx/gl/GLContextProviderWGL.cpp
+++ b/gfx/gl/GLContextProviderWGL.cpp
@@ -209,30 +209,45 @@ WGLLibrary::EnsureInitialized()
                     mHasRobustness = true;
                 }
             } else {
                 NS_ERROR("WGL supports ARB_create_context without supplying its functions.");
                 fCreateContextAttribs = nullptr;
             }
         }
 
-        if (HasExtension(extString, "WGL_NV_DX_interop")) {
-            if (GLLibraryLoader::LoadSymbols(mOGLLibrary, &dxInteropSymbols[0], lookupFunc)) {
-                mHasDXInterop = true;
-                mHasDXInterop2 = HasExtension(extString, "WGL_NV_DX_interop2");
-            } else {
-                NS_ERROR("WGL supports NV_DX_interop without supplying its functions.");
+        ////
+
+        mHasDXInterop = HasExtension(extString, "WGL_NV_DX_interop");
+        mHasDXInterop2 = HasExtension(extString, "WGL_NV_DX_interop2");
+
+        nsCString blocklistId;
+        if (gfxUtils::IsFeatureBlacklisted(nullptr, nsIGfxInfo::FEATURE_DX_INTEROP2,
+                                           &blocklistId) &&
+            !gfxPrefs::IgnoreDXInterop2Blacklist())
+        {
+            mHasDXInterop2 = false;
+        }
+
+        if (mHasDXInterop || mHasDXInterop2) {
+            if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, &dxInteropSymbols[0],
+                                              lookupFunc))
+            {
+                NS_ERROR("WGL supports NV_DX_interop(2) without supplying its functions.");
                 fDXSetResourceShareHandle = nullptr;
                 fDXOpenDevice = nullptr;
                 fDXCloseDevice = nullptr;
                 fDXRegisterObject = nullptr;
                 fDXUnregisterObject = nullptr;
                 fDXObjectAccess = nullptr;
                 fDXLockObjects = nullptr;
                 fDXUnlockObjects = nullptr;
+
+                mHasDXInterop = false;
+                mHasDXInterop2 = false;
             }
         }
     }
 
     // reset back to the previous context, just in case
     fMakeCurrent(curDC, curCtx);
 
     if (mHasRobustness) {
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -394,16 +394,17 @@ private:
   DECL_GFX_PREF(Once, "gfx.work-around-driver-bugs",           WorkAroundDriverBugs, bool, true);
   DECL_GFX_PREF(Once, "gfx.screen-mirroring.enabled",          ScreenMirroringEnabled, bool, false);
 
   DECL_GFX_PREF(Live, "gl.msaa-level",                         MSAALevel, uint32_t, 2);
 #if defined(XP_MACOSX)
   DECL_GFX_PREF(Live, "gl.multithreaded",                      GLMultithreaded, bool, false);
 #endif
   DECL_GFX_PREF(Live, "gl.require-hardware",                   RequireHardwareGL, bool, false);
+  DECL_GFX_PREF(Live, "ignore-dx-interop2-blacklist",          IgnoreDXInterop2Blacklist, bool, false);
 
   DECL_GFX_PREF(Once, "image.cache.size",                      ImageCacheSize, int32_t, 5*1024*1024);
   DECL_GFX_PREF(Once, "image.cache.timeweight",                ImageCacheTimeWeight, int32_t, 500);
   DECL_GFX_PREF(Live, "image.decode-immediately.enabled",      ImageDecodeImmediatelyEnabled, bool, false);
   DECL_GFX_PREF(Live, "image.downscale-during-decode.enabled", ImageDownscaleDuringDecodeEnabled, bool, true);
   DECL_GFX_PREF(Live, "image.infer-src-animation.threshold-ms", ImageInferSrcAnimationThresholdMS, uint32_t, 2000);
   DECL_GFX_PREF(Once, "image.mem.decode_bytes_at_a_time",      ImageMemDecodeBytesAtATime, uint32_t, 200000);
   DECL_GFX_PREF(Live, "image.mem.discardable",                 ImageMemDiscardable, bool, false);
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -1424,16 +1424,35 @@ gfxUtils::ThreadSafeGetFeatureStatus(con
 
     return runnable->GetNSResult();
   }
 
   return gfxInfo->GetFeatureStatus(feature, failureId, status);
 }
 
 /* static */ bool
+gfxUtils::IsFeatureBlacklisted(nsCOMPtr<nsIGfxInfo> gfxInfo, int32_t feature,
+                               nsACString* const out_blacklistId)
+{
+  if (!gfxInfo) {
+    gfxInfo = services::GetGfxInfo();
+  }
+
+  int32_t status;
+  if (!NS_SUCCEEDED(gfxUtils::ThreadSafeGetFeatureStatus(gfxInfo, feature,
+                                                         *out_blacklistId, &status)))
+  {
+    out_blacklistId->AssignLiteral("");
+    return true;
+  }
+
+  return status != nsIGfxInfo::FEATURE_STATUS_OK;
+}
+
+/* static */ bool
 gfxUtils::DumpDisplayList() {
   return gfxPrefs::LayoutDumpDisplayList() ||
          (gfxPrefs::LayoutDumpDisplayListContent() && XRE_IsContentProcess());
 }
 
 FILE *gfxUtils::sDumpPaintFile = stderr;
 
 namespace mozilla {
--- a/gfx/thebes/gfxUtils.h
+++ b/gfx/thebes/gfxUtils.h
@@ -263,16 +263,21 @@ public:
                                    const char16_t* aEncoderOptions,
                                    nsIInputStream** outStream);
 
     static nsresult ThreadSafeGetFeatureStatus(const nsCOMPtr<nsIGfxInfo>& gfxInfo,
                                                int32_t feature,
                                                nsACString& failureId,
                                                int32_t* status);
 
+    // Can pass `nullptr` for gfxInfo.
+    // If FAILED(ThreadSafeGetFeatureStatus), out_blacklistId will be empty.
+    static bool IsFeatureBlacklisted(nsCOMPtr<nsIGfxInfo> gfxInfo, int32_t feature,
+                                     nsACString* const out_blacklistId);
+
     /**
      * Copy to the clipboard as a PNG encoded Data URL.
      */
     static void CopyAsDataURI(SourceSurface* aSourceSurface);
     static void CopyAsDataURI(DrawTarget* aDT);
 
     static bool DumpDisplayList();
 
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4394,16 +4394,17 @@ pref("canvas.image.cache.limit", 0);
 pref("gl.msaa-level", 0);
 #else
 pref("gl.msaa-level", 2);
 #endif
 pref("gl.require-hardware", false);
 #ifdef XP_MACOSX
 pref("gl.multithreaded", true);
 #endif
+pref("gl.ignore-dx-interop2-blacklist", false);
 
 pref("webgl.force-enabled", false);
 pref("webgl.disabled", false);
 pref("webgl.disable-angle", false);
 pref("webgl.disable-wgl", false);
 pref("webgl.min_capability_mode", false);
 pref("webgl.disable-extensions", false);
 pref("webgl.msaa-force", false);