Bug 1244735: Preference to override the default behaviour for partial present. r?jrmuizel
--- 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(¶ms);
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