Bug 1118322: Block explicitly for vblank when presenting when using WARP. r=jrmuizel
authorBas Schouten <bschouten@mozilla.com>
Mon, 09 Feb 2015 16:35:48 +0100
changeset 241787 9105c55dbaee558a9bb2229bddf4171cf4d8c5bc
parent 241786 6260a7224a2d2b9214dcd1764b8e6e59e9e67f5f
child 241788 c939ab0df211d84ef373983acccb761eb0579572
push id619
push usercliu@mozilla.com
push dateMon, 09 Feb 2015 21:57:21 +0000
reviewersjrmuizel
bugs1118322
milestone38.0a1
Bug 1118322: Block explicitly for vblank when presenting when using WARP. r=jrmuizel
gfx/layers/d3d11/CompositorD3D11.cpp
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -1115,16 +1115,25 @@ CompositorD3D11::BeginFrame(const nsIntR
 
 void
 CompositorD3D11::EndFrame()
 {
   mContext->Flush();
 
   nsIntSize oldSize = mSize;
   EnsureSize();
+  UINT presentInterval = 0;
+
+  if (gfxWindowsPlatform::GetPlatform()->IsWARP()) {
+    // When we're using WARP we cannot present immediately as it causes us
+    // to tear when rendering. When not using WARP it appears the DWM takes
+    // care of tearing for us.
+    presentInterval = 1;
+  }
+
   if (oldSize == mSize) {
     RefPtr<IDXGISwapChain1> chain;
     HRESULT hr = mSwapChain->QueryInterface((IDXGISwapChain1**)byRef(chain));
     if (SUCCEEDED(hr) && chain) {
       DXGI_PRESENT_PARAMETERS params;
       PodZero(&params);
       params.DirtyRectsCount = mInvalidRegion.GetNumRects();
       std::vector<RECT> rects;
@@ -1139,19 +1148,19 @@ CompositorD3D11::EndFrame()
         rect.top = r->y;
         rect.bottom = r->YMost();
         rect.right = r->XMost();
 
         rects.push_back(rect);
       }
 
       params.pDirtyRects = &rects.front();
-      chain->Present1(0, mDisableSequenceForNextFrame ? DXGI_PRESENT_DO_NOT_SEQUENCE : 0, &params);
+      chain->Present1(presentInterval, mDisableSequenceForNextFrame ? DXGI_PRESENT_DO_NOT_SEQUENCE : 0, &params);
     } else {
-      mSwapChain->Present(0, mDisableSequenceForNextFrame ? DXGI_PRESENT_DO_NOT_SEQUENCE : 0);
+      mSwapChain->Present(presentInterval, mDisableSequenceForNextFrame ? DXGI_PRESENT_DO_NOT_SEQUENCE : 0);
     }
     mDisableSequenceForNextFrame = false;
     if (mTarget) {
       PaintToTarget();
     }
   }
 
   mCurrentRT = nullptr;