Bug 1399247: Limit the scope of D3D11MTAutoEnter in order to avoid holding it while grabbing the D2D lock. r=mchang draft
authorBas Schouten <bschouten@mozilla.com>
Tue, 12 Sep 2017 20:46:53 +0000
changeset 663202 1f5808b63e4e53bc9e0daf1f9abb2770a5e477b4
parent 662414 8b224e79a2f34574c2df460e8f92e67054c71fc3
child 731152 8da77766f8d9665d1ff745c5c66ed0fa26cd7374
push id79382
push userbschouten@mozilla.com
push dateTue, 12 Sep 2017 20:47:18 +0000
reviewersmchang
bugs1399247
milestone57.0a1
Bug 1399247: Limit the scope of D3D11MTAutoEnter in order to avoid holding it while grabbing the D2D lock. r=mchang MozReview-Commit-ID: KFKEIZBOIiy
gfx/layers/d3d11/TextureD3D11.cpp
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -484,36 +484,39 @@ D3D11TextureData::Create(IntSize aSize, 
 
     uploadDataPtr = &uploadData;
   }
 
   // See bug 1397040
   RefPtr<ID3D10Multithread> mt;
   device->QueryInterface((ID3D10Multithread**)getter_AddRefs(mt));
 
-  D3D11MTAutoEnter lock(mt.forget());
+  RefPtr<ID3D11Texture2D> texture11;
 
-  RefPtr<ID3D11Texture2D> texture11;
-  HRESULT hr = device->CreateTexture2D(&newDesc, uploadDataPtr, getter_AddRefs(texture11));
+  {
+    D3D11MTAutoEnter lock(mt.forget());
+
+    HRESULT hr = device->CreateTexture2D(&newDesc, uploadDataPtr, getter_AddRefs(texture11));
 
-  if (FAILED(hr) || !texture11) {
-    gfxCriticalNote << "[D3D11] 2 CreateTexture2D failure Size: " << aSize
-      << "texture11: " << texture11 << " Code: " << gfx::hexa(hr);
-    return nullptr;
-  }
+    if (FAILED(hr) || !texture11) {
+      gfxCriticalNote << "[D3D11] 2 CreateTexture2D failure Size: " << aSize
+        << "texture11: " << texture11 << " Code: " << gfx::hexa(hr);
+      return nullptr;
+    }
 
-  if (srcSurf && DeviceManagerDx::Get()->HasCrashyInitData()) {
-    D3D11_BOX box;
-    box.front = box.top = box.left = 0;
-    box.back = 1;
-    box.right = aSize.width;
-    box.bottom = aSize.height;
-    RefPtr<ID3D11DeviceContext> ctx;
-    device->GetImmediateContext(getter_AddRefs(ctx));
-    ctx->UpdateSubresource(texture11, 0, &box, sourceMap.mData, sourceMap.mStride, 0);
+    if (srcSurf && DeviceManagerDx::Get()->HasCrashyInitData()) {
+      D3D11_BOX box;
+      box.front = box.top = box.left = 0;
+      box.back = 1;
+      box.right = aSize.width;
+      box.bottom = aSize.height;
+      RefPtr<ID3D11DeviceContext> ctx;
+      device->GetImmediateContext(getter_AddRefs(ctx));
+      ctx->UpdateSubresource(texture11, 0, &box, sourceMap.mData, sourceMap.mStride, 0);
+    }
   }
 
   if (srcSurf) {
     srcSurf->Unmap();
   }
 
   // If we created the texture with a keyed mutex, then we expect all operations
   // on it to be synchronized using it. If we did an initial upload using aSurface