Bug 1118322: Block explicitly for vblank when presenting when using WARP. r=jrmuizel
--- 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(¶ms);
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, ¶ms);
+ chain->Present1(presentInterval, mDisableSequenceForNextFrame ? DXGI_PRESENT_DO_NOT_SEQUENCE : 0, ¶ms);
} 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;