summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi
diff options
context:
space:
mode:
authorYuhang Zhao <2546789017@qq.com>2022-11-01 16:51:06 +0800
committerYuhang Zhao <2546789017@qq.com>2022-11-03 12:03:29 +0800
commit17b542c2d2545924f4d36f6705352e5b2489aa10 (patch)
tree6746537e7814a46f7edf3878b1e47293a98351c0 /src/gui/rhi
parent3a8980304f313bc82f0a079bc0239172036ba3ea (diff)
D3D11Rhi: change default swap effect to FLIP_DISCARD
The original comments are misreading Microsoft documents. It seems Microsoft uses FLIP_SEQUENTIAL to refer to the flip model, not just FLIP_SEQUENTIAL itself. And according to my experiments, DXGI_SCALING_NONE can be used with FLIP_DISCARD indeed. The swap chain can be created successfully and I didn't get any failed HRESULTs. So there's no need to use FLIP_SEQUENTIAL as the default swap effect anymore. Let's change it back to FLIP_DISCARD. Change-Id: I6001e2070d3ff00268299e81f6a310394e62c464 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/rhi')
-rw-r--r--src/gui/rhi/qrhid3d11.cpp24
-rw-r--r--src/gui/rhi/qrhid3d11_p_p.h1
2 files changed, 5 insertions, 20 deletions
diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp
index da7089edf9..5fed1dedd5 100644
--- a/src/gui/rhi/qrhid3d11.cpp
+++ b/src/gui/rhi/qrhid3d11.cpp
@@ -173,8 +173,8 @@ bool QRhiD3D11::create(QRhi::Flags flags)
factory5->Release();
}
- // if we default to FLIP_SEQUENTIAL, have a way to request FLIP_DISCARD
- forceFlipDiscard = qEnvironmentVariableIntValue("QT_D3D_FLIP_DISCARD");
+ if (qEnvironmentVariableIntValue("QT_D3D_FLIP_DISCARD"))
+ qWarning("The default swap effect is FLIP_DISCARD, QT_D3D_FLIP_DISCARD is now ignored");
if (qEnvironmentVariableIntValue("QT_D3D_NO_FLIP"))
qWarning("Non-FLIP swapchains are no longer supported, QT_D3D_NO_FLIP is now ignored");
@@ -182,8 +182,7 @@ bool QRhiD3D11::create(QRhi::Flags flags)
qCDebug(QRHI_LOG_INFO, "FLIP_* swapchain supported = true, ALLOW_TEARING supported = %s",
supportsAllowTearing ? "true" : "false");
- qCDebug(QRHI_LOG_INFO, "Default swap effect: %s",
- forceFlipDiscard ? "FLIP_DISCARD" : "FLIP_SEQUENTIAL");
+ qCDebug(QRHI_LOG_INFO, "Default swap effect: FLIP_DISCARD");
if (!importedDeviceAndContext) {
IDXGIAdapter1 *adapter;
@@ -4873,21 +4872,8 @@ bool QD3D11SwapChain::createOrResize()
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
desc.BufferCount = BUFFER_COUNT;
desc.Flags = swapChainFlags;
-
- // Normally we'd want FLIP_DISCARD, but that comes with the default
- // SCALING_STRETCH, as SCALING_NONE is documented to be only
- // available for FLIP_SEQUENTIAL. The problem with stretch is that
- // Qt Quick and similar apps typically running in resizable windows
- // will not like how that looks in practice: the content will
- // appear to be "jumping" around during a window resize. So choose
- // sequential/none by default.
- if (rhiD->forceFlipDiscard) {
- desc.Scaling = DXGI_SCALING_STRETCH;
- desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
- } else {
- desc.Scaling = DXGI_SCALING_NONE;
- desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
- }
+ desc.Scaling = DXGI_SCALING_NONE;
+ desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
if (dcompVisual) {
// With DirectComposition setting AlphaMode to STRAIGHT fails the
diff --git a/src/gui/rhi/qrhid3d11_p_p.h b/src/gui/rhi/qrhid3d11_p_p.h
index 96c7818ee9..857ab2a2aa 100644
--- a/src/gui/rhi/qrhid3d11_p_p.h
+++ b/src/gui/rhi/qrhid3d11_p_p.h
@@ -737,7 +737,6 @@ public:
IDXGIFactory1 *dxgiFactory = nullptr;
IDCompositionDevice *dcompDevice = nullptr;
bool supportsAllowTearing = false;
- bool forceFlipDiscard = false;
bool deviceLost = false;
QRhiD3D11NativeHandles nativeHandlesStruct;
QRhiDriverInfo driverInfoStruct;