From 965c237aa229271e13e72aafd60c8293179b0c20 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 26 Feb 2024 10:36:56 +0100 Subject: [PATCH] rhi: d3d: Print more details on swapchain creation failure Do it both for d3d11 and 12. Also add a bail out when presenting to the latter (it is already there for d3d11). Pick-to: 6.6 Task-number: QTBUG-109708 Change-Id: I6f8039bcf27fa20e4bebcdf01ac3feaa14249b4d Reviewed-by: Andy Nichols (cherry picked from commit c738a349d2d6fa27e994657ce38fe9027c96a251) Reviewed-by: Qt Cherry-pick Bot --- src/gui/rhi/qrhid3d11.cpp | 7 +++++-- src/gui/rhi/qrhid3d12.cpp | 12 ++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index e2dc53f3394..92e4cacc164 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -5200,8 +5200,11 @@ bool QD3D11SwapChain::createOrResize() } } if (FAILED(hr)) { - qWarning("Failed to create D3D11 swapchain: %s", - qPrintable(QSystemError::windowsComString(hr))); + qWarning("Failed to create D3D11 swapchain: %s" + " (Width=%u Height=%u Format=%u SampleCount=%u BufferCount=%u Scaling=%u SwapEffect=%u Stereo=%u)", + qPrintable(QSystemError::windowsComString(hr)), + desc.Width, desc.Height, UINT(desc.Format), desc.SampleDesc.Count, + desc.BufferCount, UINT(desc.Scaling), UINT(desc.SwapEffect), UINT(desc.Stereo)); return false; } } else { diff --git a/src/gui/rhi/qrhid3d12.cpp b/src/gui/rhi/qrhid3d12.cpp index 15b076aa351..ce9c5dcbdb5 100644 --- a/src/gui/rhi/qrhid3d12.cpp +++ b/src/gui/rhi/qrhid3d12.cpp @@ -1607,6 +1607,10 @@ QRhi::FrameOpResult QRhiD3D12::endFrame(QRhiSwapChain *swapChain, QRhi::EndFrame { presentFlags |= DXGI_PRESENT_ALLOW_TEARING; } + if (!swapChainD->swapChain) { + qWarning("Failed to present, no swapchain"); + return QRhi::FrameOpError; + } HRESULT hr = swapChainD->swapChain->Present(swapChainD->swapInterval, presentFlags); if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) { qWarning("Device loss detected in Present()"); @@ -6239,7 +6243,7 @@ bool QD3D12SwapChain::createOrResize() if (!dcompTarget) { hr = rhiD->dcompDevice->CreateTargetForHwnd(hwnd, true, &dcompTarget); if (FAILED(hr)) { - qWarning("Failed to create Direct Compsition target for the window: %s", + qWarning("Failed to create Direct Composition target for the window: %s", qPrintable(QSystemError::windowsComString(hr))); } } @@ -6336,7 +6340,11 @@ bool QD3D12SwapChain::createOrResize() } } if (FAILED(hr)) { - qWarning("Failed to create D3D12 swapchain: %s", qPrintable(QSystemError::windowsComString(hr))); + qWarning("Failed to create D3D12 swapchain: %s" + " (Width=%u Height=%u Format=%u SampleCount=%u BufferCount=%u Scaling=%u SwapEffect=%u Stereo=%u)", + qPrintable(QSystemError::windowsComString(hr)), + desc.Width, desc.Height, UINT(desc.Format), desc.SampleDesc.Count, + desc.BufferCount, UINT(desc.Scaling), UINT(desc.SwapEffect), UINT(desc.Stereo)); return false; }