Bug 1026893 - "crash in @0x0 | CContext::ID3D11DeviceContext1_SetSamplers_<int, 5>(ID3D11DeviceContext1*, unsigned int, unsigned int, ID3D11SamplerState* const*)". r=jmuizelaar a=sledru
authorBas Schouten <bas@basschouten.com>
Fri, 17 Oct 2014 09:32:00 +0200
changeset 218088 b9e31f93e53c
parent 218086 946f61c00aa0
child 218090 b4f691bf543e
push id534
push usercbook@mozilla.com
push date2014-10-20 15:03 +0000
treeherdermozilla-release@b9e31f93e53c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmuizelaar, sledru
bugs1026893
milestone33.0
Bug 1026893 - "crash in @0x0 | CContext::ID3D11DeviceContext1_SetSamplers_<int, 5>(ID3D11DeviceContext1*, unsigned int, unsigned int, ID3D11SamplerState* const*)". r=jmuizelaar a=sledru
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -382,17 +382,17 @@ gfxWindowsPlatform::UpdateRenderMode()
     // Do not ever try if d2d is explicitly disabled,
     // or if we're not using DWrite fonts.
     if (d2dDisabled || mUsingGDIFonts) {
         tryD2D = false;
     }
 
     if (isVistaOrHigher  && !safeMode && tryD2D) {
         VerifyD2DDevice(d2dForceEnabled);
-        if (mD2DDevice) {
+        if (mD2DDevice && GetD3D11Device()) {
             mRenderMode = RENDER_DIRECT2D;
             mUseDirectWrite = true;
         }
     } else {
         mD2DDevice = nullptr;
     }
 #endif
 
@@ -1380,20 +1380,26 @@ gfxWindowsPlatform::GetD3D11Device()
   featureLevels.AppendElement(D3D_FEATURE_LEVEL_9_3);
 
   RefPtr<IDXGIAdapter1> adapter = GetDXGIAdapter();
 
   if (!adapter) {
     return nullptr;
   }
 
-  HRESULT hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
-                                 D3D11_CREATE_DEVICE_BGRA_SUPPORT,
-                                 featureLevels.Elements(), featureLevels.Length(),
-                                 D3D11_SDK_VERSION, byRef(mD3D11Device), nullptr, nullptr);
+  HRESULT hr = E_INVALIDARG;
+  __try {
+    hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
+                                    D3D11_CREATE_DEVICE_BGRA_SUPPORT,
+                                    featureLevels.Elements(), featureLevels.Length(),
+                                    D3D11_SDK_VERSION, byRef(mD3D11Device), nullptr, nullptr);
+  } __except (EXCEPTION_EXECUTE_HANDLER) {
+    mD3D11Device = nullptr;
+    return nullptr;
+  }
 
   // We leak these everywhere and we need them our entire runtime anyway, let's
   // leak it here as well.
   d3d11Module.disown();
 
   if (SUCCEEDED(hr)) {
     mD3D11Device->SetExceptionMode(0);
   }