summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2024-02-26 10:36:56 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2024-02-28 19:15:51 +0100
commitc738a349d2d6fa27e994657ce38fe9027c96a251 (patch)
treea427c1f7e2d18ba9818605bdb51a7c3e9a2c4a22
parent4d55feb7435117fe0889ba95eb3a3aa1a19aa1f5 (diff)
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.7 6.6 Task-number: QTBUG-109708 Change-Id: I6f8039bcf27fa20e4bebcdf01ac3feaa14249b4d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r--src/gui/rhi/qrhid3d11.cpp7
-rw-r--r--src/gui/rhi/qrhid3d12.cpp12
2 files changed, 15 insertions, 4 deletions
diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp
index 58a8221a11..9f13784426 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 881f769710..9b139d5e56 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, false, &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;
}