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 <andy.nichols@qt.io>
(cherry picked from commit c738a349d2d6fa27e994657ce38fe9027c96a251)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Laszlo Agocs 2024-02-26 10:36:56 +01:00 committed by Qt Cherry-pick Bot
parent e5a8b36704
commit 965c237aa2
2 changed files with 15 additions and 4 deletions

View File

@ -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 {

View File

@ -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;
}