From 17b542c2d2545924f4d36f6705352e5b2489aa10 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Tue, 1 Nov 2022 16:51:06 +0800 Subject: 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 --- src/gui/rhi/qrhid3d11.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'src/gui/rhi/qrhid3d11.cpp') 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 -- cgit v1.2.3