From efd63925d730bccb548d773c5cf5170da9d27d4d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 21 Jun 2023 14:01:08 +0200 Subject: [PATCH] rhi: d3d: Skip MakeWindowAssoc. when using dcomp It has no purpose (like Alt+Enter is not functional anyway when we created the swapchain for composition), and with D3D12 there is a warning printed (with the debug layer enabled?) about this. So move the call to the appropriate branch. Change-Id: I266ae6835bcc49b3ba8d84e5d08ab9115c6401e0 Reviewed-by: Andy Nichols (cherry picked from commit 300da03e3a0b80797e8cb9ddae90233244704691) Reviewed-by: Qt Cherry-pick Bot --- src/gui/rhi/qrhid3d11.cpp | 4 +++- src/gui/rhi/qrhid3d12.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 92fc9640b46..45bedc7bbf5 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -5136,6 +5136,9 @@ bool QD3D11SwapChain::createOrResize() qWarning("Failed to set content for Direct Composition visual: %s", qPrintable(QSystemError::windowsComString(hr))); } + } else { + // disable Alt+Enter; not relevant when using DirectComposition + rhiD->dxgiFactory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_WINDOW_CHANGES); } } if (FAILED(hr)) { @@ -5143,7 +5146,6 @@ bool QD3D11SwapChain::createOrResize() qPrintable(QSystemError::windowsComString(hr))); return false; } - rhiD->dxgiFactory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_WINDOW_CHANGES); } else { releaseBuffers(); // flip model -> buffer count is the real buffer count, not 1 like with the legacy modes diff --git a/src/gui/rhi/qrhid3d12.cpp b/src/gui/rhi/qrhid3d12.cpp index 7dcd26f3565..2c3fdf4b8b3 100644 --- a/src/gui/rhi/qrhid3d12.cpp +++ b/src/gui/rhi/qrhid3d12.cpp @@ -5982,13 +5982,15 @@ bool QD3D12SwapChain::createOrResize() qWarning("Failed to set content for Direct Composition visual: %s", qPrintable(QSystemError::windowsComString(hr))); } + } else { + // disable Alt+Enter; not relevant when using DirectComposition + rhiD->dxgiFactory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_WINDOW_CHANGES); } } if (FAILED(hr)) { qWarning("Failed to create D3D12 swapchain: %s", qPrintable(QSystemError::windowsComString(hr))); return false; } - rhiD->dxgiFactory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_WINDOW_CHANGES); for (int i = 0; i < QD3D12_FRAMES_IN_FLIGHT; ++i) { hr = rhiD->dev->CreateFence(0,