From 300da03e3a0b80797e8cb9ddae90233244704691 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. Pick-to: 6.6 Change-Id: I266ae6835bcc49b3ba8d84e5d08ab9115c6401e0 Reviewed-by: Andy Nichols --- 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 388291de3e..feda195c51 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -5157,6 +5157,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)) { @@ -5164,7 +5167,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 7ae3398fdb..7c55ff9f5c 100644 --- a/src/gui/rhi/qrhid3d12.cpp +++ b/src/gui/rhi/qrhid3d12.cpp @@ -6003,13 +6003,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,