Bug 1160295 - Part 2. Make sure the DLLs are loaded before checking the version. r=bas
authorMilan Sreckovic <milan@mozilla.com>
Fri, 04 Sep 2015 08:52:00 +0200
changeset 294131 60cc73ec40532d2d92e8d11e49bf5fdf5d5efd64
parent 294130 63d9b41521e90bb8cef3c2f86c05a274436d9384
child 294132 d1d9d161eacd79b8e6d678ef588ed17cf6a2347f
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas
bugs1160295
milestone43.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 1160295 - Part 2. Make sure the DLLs are loaded before checking the version. r=bas
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -1647,17 +1647,17 @@ gfxWindowsPlatform::GetDXGIAdapter()
   }
 
   // We leak this module everywhere, we might as well do so here as well.
   dxgiModule.disown();
 
   return mAdapter;
 }
 
-bool CouldD3D11DeviceWork()
+bool DoesD3D11DeviceWork()
 {
   static bool checked = false;
   static bool result = false;
 
   if (checked)
       return result;
   checked = true;
 
@@ -1990,21 +1990,16 @@ 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()) {
-    mD3D11Device = nullptr;
-    return;
-  }
-
   RefPtr<IDXGIAdapter1> adapter = GetDXGIAdapter();
   if (!adapter) {
     return;
   }
 
   HRESULT hr = E_INVALIDARG;
   MOZ_SEH_TRY {
     hr =
@@ -2015,18 +2010,19 @@ 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)) {
+  if (FAILED(hr) || !DoesD3D11DeviceWork()) {
     gfxCriticalError() << "D3D11 device creation failed" << hexa(hr);
+    mD3D11Device = nullptr;
     return;
   }
   if (!mD3D11Device) {
     return;
   }
 
   // Only test this when not using WARP since it can fail and cause
   // GetDeviceRemovedReason to return weird values.
@@ -2445,20 +2441,16 @@ 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;
   }
@@ -2486,17 +2478,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)) {
+  if (FAILED(hr) || !DoesD3D11DeviceWork()) {
     return nullptr;
   }
 
   nsRefPtr<ID3D10Multithread> multi;
   device->QueryInterface(__uuidof(ID3D10Multithread), getter_AddRefs(multi));
 
   multi->SetMultithreadProtected(TRUE);