rhi: d3d11: Revive non-flip swapchain model support
Make the QT_D3D_NO_FLIP env.var. have an effect again. This env.var. has the following effects: - SwapEffect is set to DXGI_SWAP_EFFECT_DISCARD - Scaling is set to DXGI_SCALING_STRETCH (no other option with the blitting legacy model) - Alpha works without having to deal with DirectComposition, the dcomp code path is therefore skipped completely in legacy mode - Requesting a HDR mode behaves incorrectly (there's an unwanted conversion to SDR or something like that) - Different window resizing artifacts. Instead of the big black/white bars, that is typical with the modern, efficient flip swapchains in non-Qt applications as well, there is a bit of shimmering on the right side esp. when resizing on the left side. The option of using the legacy is model provided mainly for users where this is important. - Reduced performance due the using the old blitting model, although that probably won't be visible for many typical Qt applications on desktop PCs. Only for D3D11, because D3D12 does not support non-flip swapchains. Note: this is incompatible with QT_QPA_DISABLE_REDIRECTION_SURFACE. The reason to reintroduce this option is to provide a way, even if just as a developer-focused environment variable, to get a behavior that is identical to other frameworks and non-Qt applications that still use D3D11 with the legacy swapchain modes in their rendering engines. This applies first and foremost to window resizing, where the visual artifacts common with flip model swapchains may be misunderstood to be caused by Qt. Having a way to opt-in to the legacy model allows avoiding/clarifying Apples-to-Oranges comparisons. Pick-to: 6.5 Change-Id: I04e46f71a96fa56cace38703e0e9b93b43bfebc7 Reviewed-by: Christian Strømme <christian.stromme@qt.io> (cherry picked from commit 8a175f4ae231e54fafbd97f4da6b5db0fb66d47f) Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
192c343582
commit
bd76a9a86f
@ -192,13 +192,14 @@ bool QRhiD3D11::create(QRhi::Flags flags)
|
||||
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");
|
||||
// Support for flip model swapchains is required now (since we are
|
||||
// targeting Windows 10+), but the option for using the old model is still
|
||||
// there. (some features are not supported then, however)
|
||||
useLegacySwapchainModel = qEnvironmentVariableIntValue("QT_D3D_NO_FLIP");
|
||||
|
||||
qCDebug(QRHI_LOG_INFO, "FLIP_* swapchain supported = true, ALLOW_TEARING supported = %s",
|
||||
supportsAllowTearing ? "true" : "false");
|
||||
|
||||
qCDebug(QRHI_LOG_INFO, "Default swap effect: FLIP_DISCARD");
|
||||
qCDebug(QRHI_LOG_INFO, "FLIP_* swapchain supported = true, ALLOW_TEARING supported = %s, use legacy (non-FLIP) model = %s",
|
||||
supportsAllowTearing ? "true" : "false",
|
||||
useLegacySwapchainModel ? "true" : "false");
|
||||
|
||||
if (!importedDeviceAndContext) {
|
||||
IDXGIAdapter1 *adapter;
|
||||
@ -5021,7 +5022,7 @@ bool QD3D11SwapChain::createOrResize()
|
||||
QRHI_RES_RHI(QRhiD3D11);
|
||||
|
||||
if (m_flags.testFlag(SurfaceHasPreMulAlpha) || m_flags.testFlag(SurfaceHasNonPreMulAlpha)) {
|
||||
if (rhiD->ensureDirectCompositionDevice()) {
|
||||
if (!rhiD->useLegacySwapchainModel && rhiD->ensureDirectCompositionDevice()) {
|
||||
if (!dcompTarget) {
|
||||
hr = rhiD->dcompDevice->CreateTargetForHwnd(hwnd, true, &dcompTarget);
|
||||
if (FAILED(hr)) {
|
||||
@ -5100,8 +5101,8 @@ bool QD3D11SwapChain::createOrResize()
|
||||
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
desc.BufferCount = BUFFER_COUNT;
|
||||
desc.Flags = swapChainFlags;
|
||||
desc.Scaling = DXGI_SCALING_NONE;
|
||||
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||
desc.Scaling = rhiD->useLegacySwapchainModel ? DXGI_SCALING_STRETCH : DXGI_SCALING_NONE;
|
||||
desc.SwapEffect = rhiD->useLegacySwapchainModel ? DXGI_SWAP_EFFECT_DISCARD : DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||
|
||||
if (dcompVisual) {
|
||||
// With DirectComposition setting AlphaMode to STRAIGHT fails the
|
||||
|
@ -757,6 +757,7 @@ public:
|
||||
IDXGIFactory1 *dxgiFactory = nullptr;
|
||||
IDCompositionDevice *dcompDevice = nullptr;
|
||||
bool supportsAllowTearing = false;
|
||||
bool useLegacySwapchainModel = false;
|
||||
bool deviceLost = false;
|
||||
QRhiD3D11NativeHandles nativeHandlesStruct;
|
||||
QRhiDriverInfo driverInfoStruct;
|
||||
|
Loading…
x
Reference in New Issue
Block a user