Bug 1244735: Preference to override the default behaviour for partial present. r?jrmuizel draft
authorMilan Sreckovic <milan@mozilla.com>
Mon, 01 Feb 2016 11:36:58 -0500
changeset 327730 68f80893896662ff3440e6183ad03d66eb2f30fe
parent 327605 d07dbd40dcd209124149f331f60dd55c8da33fbe
child 513731 5e73f3d07ba6bf5fb7ca6d6842ffa2b6546e0b49
push id10272
push usermsreckovic@mozilla.com
push dateMon, 01 Feb 2016 16:37:08 +0000
reviewersjrmuizel
bugs1244735
milestone47.0a1
Bug 1244735: Preference to override the default behaviour for partial present. r?jrmuizel
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/thebes/gfxPrefs.h
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -1124,20 +1124,24 @@ CompositorD3D11::EndFrame()
   }
 
   if (oldSize == mSize) {
     RefPtr<IDXGISwapChain1> chain;
     HRESULT hr = mSwapChain->QueryInterface((IDXGISwapChain1**)getter_AddRefs(chain));
     nsString vendorID;
     nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
     gfxInfo->GetAdapterVendorID(vendorID);
-    bool isNvidia = vendorID.EqualsLiteral("0x10de") && !gfxWindowsPlatform::GetPlatform()->IsWARP();
-    if (SUCCEEDED(hr) && chain && !isNvidia) {
-        // Avoid partial present on Nvidia hardware to try to work around
-        // bug 1189940
+    // We can force partial present or block partial present, based on the value of
+    // this preference; the default is to disable it on Nvidia (bug 1189940)
+    int32_t partialPresentPref = gfxPrefs::PartialPresent();
+    bool allowPartialPresent = (partialPresentPref > 0) ? true :
+                                partialPresentPref < 0 ? false :
+                                     (!vendorID.EqualsLiteral("0x10de") ||
+                                      gfxWindowsPlatform::GetPlatform()->IsWARP());
+    if (SUCCEEDED(hr) && chain && allowPartialPresent) {
       DXGI_PRESENT_PARAMETERS params;
       PodZero(&params);
       params.DirtyRectsCount = mInvalidRegion.GetNumRects();
       StackArray<RECT, 4> rects(params.DirtyRectsCount);
 
       uint32_t i = 0;
       for (auto iter = mInvalidRegion.RectIter(); !iter.Done(); iter.Next()) {
         const IntRect& r = iter.Get();
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -252,16 +252,17 @@ private:
   DECL_GFX_PREF(Live, "gfx.gralloc.fence-with-readpixels",     GrallocFenceWithReadPixels, bool, false);
   DECL_GFX_PREF(Live, "gfx.layerscope.enabled",                LayerScopeEnabled, bool, false);
   DECL_GFX_PREF(Live, "gfx.layerscope.port",                   LayerScopePort, int32_t, 23456);
   // Note that        "gfx.logging.level" is defined in Logging.h
   DECL_GFX_PREF(Once, "gfx.logging.crash.length",              GfxLoggingCrashLength, uint32_t, 6);
   // The maximums here are quite conservative, we can tighten them if problems show up.
   DECL_GFX_PREF(Once, "gfx.max-alloc-size",                    MaxAllocSize, int32_t, (int32_t)500000000);
   DECL_GFX_PREF(Once, "gfx.max-texture-size",                  MaxTextureSize, int32_t, (int32_t)32767);
+  DECL_GFX_PREF(Live, "gfx.partialpresent.force",              PartialPresent, int32_t, 0);
   DECL_GFX_PREF(Live, "gfx.perf-warnings.enabled",             PerfWarnings, bool, false);
   DECL_GFX_PREF(Live, "gfx.SurfaceTexture.detach.enabled",     SurfaceTextureDetachEnabled, bool, true);
   DECL_GFX_PREF(Live, "gfx.testing.device-reset",              DeviceResetForTesting, int32_t, 0);
   DECL_GFX_PREF(Live, "gfx.testing.device-fail",               DeviceFailForTesting, bool, false);
 
   DECL_GFX_PREF(Live, "gfx.content.use-native-pushlayer",      UseNativePushLayer, bool, false);
 
   // These times should be in milliseconds