Bug 1399247: Limit the scope of D3D11MTAutoEnter in order to avoid holding it while grabbing the D2D lock. r=mchang
authorBas Schouten <bschouten@mozilla.com>
Tue, 12 Sep 2017 20:46:53 +0000
changeset 429948 a98262b2acc13985e94e73cb91498d82f57034d6
parent 429947 d928c61a691f6508eb93c42beee2cb59081ede30
child 429949 be5cbdf6f42084a2399e0a85458a37f617aed597
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmchang
bugs1399247
milestone57.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 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