Bug 1160295: Bad DisplayLink drivers -> no acceleration. r=jrmuizel a=sylvestre
authorMilan Sreckovic <milan@mozilla.com>
Wed, 12 Aug 2015 15:59:57 -0700
changeset 288714 29300721bb127fecc8b9fc782cbfa2453180964a
parent 288713 c63d3aab172e7b0fdf804e52ceb7e17fc32c0072
child 288715 6ac553d3b93f29ea4eb054218d3390797e752bd8
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, sylvestre
bugs1160295
milestone42.0a2
Bug 1160295: Bad DisplayLink drivers -> no acceleration. r=jrmuizel a=sylvestre
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -1668,17 +1668,17 @@ gfxWindowsPlatform::GetDXGIAdapter()
   }
 
   // We leak this module everywhere, we might as well do so here as well.
   dxgiModule.disown();
 
   return mAdapter;
 }
 
-bool DoesD3D11DeviceWork(ID3D11Device *device)
+bool CouldD3D11DeviceWork()
 {
   static bool checked = false;
   static bool result = false;
 
   if (checked)
       return result;
   checked = true;
 
@@ -1972,16 +1972,20 @@ gfxWindowsPlatform::CheckD3D11Support(bo
 // We don't have access to the D3D11CreateDevice type in gfxWindowsPlatform.h,
 // since it doesn't include d3d11.h, so we use a static here. It should only
 // be used within InitializeD3D11.
 decltype(D3D11CreateDevice)* sD3D11CreateDeviceFn = nullptr;
 
 void
 gfxWindowsPlatform::AttemptD3D11DeviceCreation()
 {
+  if (!CouldD3D11DeviceWork()) {
+    return;
+  }
+
   RefPtr<IDXGIAdapter1> adapter = GetDXGIAdapter();
   if (!adapter) {
     return;
   }
 
   HRESULT hr = E_INVALIDARG;
   MOZ_SEH_TRY {
     hr =
@@ -1992,17 +1996,17 @@ gfxWindowsPlatform::AttemptD3D11DeviceCr
                            D3D11_CREATE_DEVICE_BGRA_SUPPORT | D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
                            mFeatureLevels.Elements(), mFeatureLevels.Length(),
                            D3D11_SDK_VERSION, byRef(mD3D11Device), nullptr, nullptr);
   } MOZ_SEH_EXCEPT (EXCEPTION_EXECUTE_HANDLER) {
     gfxCriticalError() << "Crash during D3D11 device creation";
     return;
   }
 
-  if (FAILED(hr) || !DoesD3D11DeviceWork(mD3D11Device)) {
+  if (FAILED(hr)) {
     gfxCriticalError() << "D3D11 device creation failed" << hexa(hr);
     return;
   }
   if (!mD3D11Device) {
     return;
   }
 
   CheckIfRenderTargetViewNeedsRecreating(mD3D11Device);
@@ -2390,16 +2394,20 @@ gfxWindowsPlatform::InitializeD2D1()
 
   mD2D1Status = FeatureStatus::Available;
   d2d1_1.SetSuccessful();
 }
 
 already_AddRefed<ID3D11Device>
 gfxWindowsPlatform::CreateD3D11DecoderDevice()
 {
+  if (!CouldD3D11DeviceWork()) {
+    return nullptr;
+  }
+
   nsModuleHandle d3d11Module(LoadLibrarySystem32(L"d3d11.dll"));
   decltype(D3D11CreateDevice)* d3d11CreateDevice = (decltype(D3D11CreateDevice)*)
     GetProcAddress(d3d11Module, "D3D11CreateDevice");
 
    if (!d3d11CreateDevice) {
     // We should just be on Windows Vista or XP in this case.
     return nullptr;
   }
@@ -2427,17 +2435,17 @@ gfxWindowsPlatform::CreateD3D11DecoderDe
     hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
                            D3D11_CREATE_DEVICE_VIDEO_SUPPORT,
                            featureLevels.Elements(), featureLevels.Length(),
                            D3D11_SDK_VERSION, byRef(device), nullptr, nullptr);
   } MOZ_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
     return nullptr;
   }
 
-  if (FAILED(hr) || !DoesD3D11DeviceWork(device)) {
+  if (FAILED(hr)) {
     return nullptr;
   }
 
   nsRefPtr<ID3D10Multithread> multi;
   device->QueryInterface(__uuidof(ID3D10Multithread), getter_AddRefs(multi));
 
   multi->SetMultithreadProtected(TRUE);