Bug 1170143 - Disable texture sharing if we've blacklisted direct2d. r=Bas, a=lizzard
authorMatt Woodrow <mwoodrow@mozilla.com>
Mon, 08 Jun 2015 12:41:37 -0400
changeset 266211 4241def0561b
parent 266210 48c9f45a00f2
child 266212 780e1c2b8013
child 266214 d965a18e6054
child 266216 c5327254125d
push id4788
push userryanvm@gmail.com
push date2015-06-08 18:03 +0000
treeherdermozilla-beta@4241def0561b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, lizzard
bugs1170143
milestone39.0
Bug 1170143 - Disable texture sharing if we've blacklisted direct2d. r=Bas, a=lizzard
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -1824,16 +1824,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
@@ -2019,17 +2036,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();
 }