Bug 1596630 - Remove mSyncObject->Synchronize() in RenderCompositorANGLE::BeginFrame() r=nical
authorsotaro <sotaro.ikeda.g@gmail.com>
Mon, 18 Nov 2019 09:49:15 +0000
changeset 502406 f0dfc557b20c1dd9c2865df1db2a34dc783c92f8
parent 502405 a0e0c81e36237ce624a44897278ea842bb04ed0a
child 502407 d25c3e100157884a8f83aab9b563e7f0e0316875
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1596630
milestone72.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 1596630 - Remove mSyncObject->Synchronize() in RenderCompositorANGLE::BeginFrame() r=nical mSyncObject->Synchronize() was necessary to handle a case that D3D Texture was created on main thread of content process and the Texture does not have a keyed mutex. But with WebRender, the situation does not happen often. Further the Synchronize() is sometimes very slow. Therefore it is better to remove it from RenderCompositorANGLE::BeginFrame(). Canvas 2d does not use keyed mutex yet. Then the change adds keyed mutex usage for the canvas 2d. D3D11DXVA2Manager still uses the Synchronize(). In this case, the Synchronize() is manually called in D3D11DXVA2Manager::CopyToImage(). Then RenderCompositorANGLE still needs to create SyncObjectHost. Differential Revision: https://phabricator.services.mozilla.com/D53168
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/wr/WebRenderLayerManager.cpp
gfx/webrender_bindings/RenderCompositorANGLE.cpp
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -443,17 +443,19 @@ D3D11TextureData* D3D11TextureData::Crea
     newDesc.Format = DXGI_FORMAT_NV12;
   } else if (aFormat == SurfaceFormat::P010) {
     newDesc.Format = DXGI_FORMAT_P010;
   } else if (aFormat == SurfaceFormat::P016) {
     newDesc.Format = DXGI_FORMAT_P016;
   }
 
   newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED;
-  if (!NS_IsMainThread() || !!(aFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT)) {
+  // WebRender requests keyed mutex.
+  if (gfxVars::UseWebRender() || !NS_IsMainThread() ||
+      !!(aFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT)) {
     // On the main thread we use the syncobject to handle synchronization.
     if (!(aFlags & ALLOC_MANUAL_SYNCHRONIZATION)) {
       newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX;
     }
   }
 
   if (aSurface && newDesc.MiscFlags == D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX &&
       !DeviceManagerDx::Get()->CanInitializeKeyedMutexTextures()) {
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -222,25 +222,16 @@ bool WebRenderLayerManager::EndEmptyTran
 
   // Get the time of when the refresh driver start its tick (if available),
   // otherwise use the time of when LayerManager::BeginTransaction was called.
   TimeStamp refreshStart = mTransactionIdAllocator->GetTransactionStart();
   if (!refreshStart) {
     refreshStart = mTransactionStart;
   }
 
-  // Skip the synchronization for buffer since we also skip the painting during
-  // device-reset status.
-  if (!gfxPlatform::GetPlatform()->DidRenderingDeviceReset()) {
-    if (WrBridge()->GetSyncObject() &&
-        WrBridge()->GetSyncObject()->IsSyncObjectValid()) {
-      WrBridge()->GetSyncObject()->Synchronize();
-    }
-  }
-
   GetCompositorBridgeChild()->EndCanvasTransaction();
 
   AutoTArray<RenderRootUpdates, wr::kRenderRootCount> renderRootUpdates;
   for (auto& stateManager : mStateManagers) {
     auto renderRoot = stateManager.GetRenderRoot();
     if (stateManager.mAsyncResourceUpdates ||
         !mPendingScrollUpdates[renderRoot].IsEmpty() ||
         WrBridge()->HasWebRenderParentCommands(renderRoot)) {
@@ -408,25 +399,16 @@ void WebRenderLayerManager::EndTransacti
   }
 
   for (auto renderRoot : wr::kRenderRoots) {
     if (resourceUpdates.HasSubQueue(renderRoot)) {
       WrBridge()->RemoveExpiredFontKeys(resourceUpdates.SubQueue(renderRoot));
     }
   }
 
-  // Skip the synchronization for buffer since we also skip the painting during
-  // device-reset status.
-  if (!gfxPlatform::GetPlatform()->DidRenderingDeviceReset()) {
-    if (WrBridge()->GetSyncObject() &&
-        WrBridge()->GetSyncObject()->IsSyncObjectValid()) {
-      WrBridge()->GetSyncObject()->Synchronize();
-    }
-  }
-
   GetCompositorBridgeChild()->EndCanvasTransaction();
 
   {
     AUTO_PROFILER_TRACING("Paint", "ForwardDPTransaction", GRAPHICS);
     nsTArray<RenderRootDisplayListData> renderRootDLs;
     for (auto renderRoot : wr::kRenderRoots) {
       if (builder.GetSendSubBuilderDisplayList(renderRoot)) {
         auto renderRootDL = renderRootDLs.AppendElement();
--- a/gfx/webrender_bindings/RenderCompositorANGLE.cpp
+++ b/gfx/webrender_bindings/RenderCompositorANGLE.cpp
@@ -241,16 +241,17 @@ bool RenderCompositorANGLE::Initialize()
     if (SUCCEEDED(hr)) {
       mSwapChain1 = swapChain1;
     }
   }
 
   // We need this because we don't want DXGI to respond to Alt+Enter.
   dxgiFactory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_WINDOW_CHANGES);
 
+  // SyncObject is used only by D3D11DXVA2Manager
   mSyncObject = layers::SyncObjectHost::CreateSyncObjectHost(mDevice);
   if (!mSyncObject->Init()) {
     // Some errors occur. Clear the mSyncObject here.
     // Then, there will be no texture synchronization.
     return false;
   }
 
   if (!UseCompositor()) {
@@ -397,23 +398,16 @@ bool RenderCompositorANGLE::BeginFrame()
     }
   }
 
   if (!MakeCurrent()) {
     gfxCriticalNote << "Failed to make render context current, can't draw.";
     return false;
   }
 
-  if (mSyncObject) {
-    if (!mSyncObject->Synchronize(/* aFallible */ true)) {
-      // It's timeout or other error. Handle the device-reset here.
-      RenderThread::Get()->HandleDeviceReset("SyncObject", /* aNotify */ true);
-      return false;
-    }
-  }
   return true;
 }
 
 RenderedFrameId RenderCompositorANGLE::EndFrame(
     const FfiVec<DeviceIntRect>& aDirtyRects) {
   RenderedFrameId frameId = GetNextRenderFrameId();
   InsertPresentWaitQuery(frameId);