Bug 1170143 - Disable texture sharing if we've blacklisted direct2d. r=Bas
authorMatt Woodrow <mwoodrow@mozilla.com>
Mon, 08 Jun 2015 12:41:37 -0400
changeset 247627 73dda324715f
parent 247626 636412252449
child 247628 a9cff1d9e7c6
push id60757
push usermwoodrow@mozilla.com
push date2015-06-08 16:41 +0000
treeherdermozilla-inbound@73dda324715f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs1170143
milestone41.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 1170143 - Disable texture sharing if we've blacklisted direct2d. r=Bas
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -1828,16 +1828,33 @@ bool DoesD3D11TextureSharingWork(ID3D11D
   if (checked)
     return result;
   checked = true;
 
   result = DoesD3D11TextureSharingWorkInternal(device, DXGI_FORMAT_B8G8R8A8_UNORM, D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE);
   return result;
 }
 
+bool DoesD3D11AlphaTextureSharingWork(ID3D11Device *device)
+{
+  nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
+  if (gfxInfo) {
+    // Disable texture sharing if we're blocking d2d since that's the only other time we use it
+    // and it might be broken.
+    int32_t status;
+    if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DIRECT2D, &status))) {
+      if (status != nsIGfxInfo::FEATURE_STATUS_OK) {
+        return false;
+      }
+    }
+  }
+
+  return DoesD3D11TextureSharingWorkInternal(device, DXGI_FORMAT_A8_UNORM, D3D11_BIND_SHADER_RESOURCE);
+}
+
 void
 gfxWindowsPlatform::InitD3D11Devices()
 {
   // This function attempts to initialize our D3D11 devices. If the hardware
   // is not blacklisted for D3D11 layers. This will first attempt to create a
   // hardware accelerated device. If this creation fails or the hardware is
   // blacklisted, then this function will abort if WARP is disabled, causing us
   // to fallback to D3D9 or Basic layers. If WARP is not disabled it will use
@@ -2017,17 +2034,17 @@ gfxWindowsPlatform::InitD3D11Devices()
 
     if (FAILED(hr)) {
       d3d11Module.disown();
       return;
     }
 
     mD3D11ImageBridgeDevice->SetExceptionMode(0);
 
-    if (!DoesD3D11TextureSharingWorkInternal(mD3D11ImageBridgeDevice, DXGI_FORMAT_A8_UNORM, D3D11_BIND_SHADER_RESOURCE)) {
+    if (!DoesD3D11AlphaTextureSharingWork(mD3D11ImageBridgeDevice)) {
       mD3D11ImageBridgeDevice = nullptr;
     }
   }
 
   // We leak these everywhere and we need them our entire runtime anyway, let's
   // leak it here as well.
   d3d11Module.disown();
 }