QRhiD3D11: do not crash on endFrame() when IDXGISwapChain is null
There are reports on crashes in QRhiD3D11::endFrame() due to nullptr access to swapChain (IDXGISwapChain). It's still not clear under what conditions this might happen, but we can make a speculative fix (as a last chance) by simply adding a check that the swapChain is not null. Instead of crashing in such cases, we will warn now and return QRhi::FrameOpError, similar to the case when IDXGISwapChain::Present() failed. Task-number: QTBUG-109708 Pick-to: 6.5 Change-Id: I2b0430347a229a618176a38ce3dc9c6e5a33a60c Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> (cherry picked from commit 2581bed66be114ae106696a0321f99fba1c4d6f9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
6990f51553
commit
758e249f67
@ -1339,6 +1339,10 @@ QRhi::FrameOpResult QRhiD3D11::endFrame(QRhiSwapChain *swapChain, QRhi::EndFrame
|
|||||||
UINT presentFlags = 0;
|
UINT presentFlags = 0;
|
||||||
if (swapChainD->swapInterval == 0 && (swapChainD->swapChainFlags & DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING))
|
if (swapChainD->swapInterval == 0 && (swapChainD->swapChainFlags & DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING))
|
||||||
presentFlags |= DXGI_PRESENT_ALLOW_TEARING;
|
presentFlags |= DXGI_PRESENT_ALLOW_TEARING;
|
||||||
|
if (!swapChainD->swapChain) {
|
||||||
|
qWarning("Failed to present: IDXGISwapChain is unavailable");
|
||||||
|
return QRhi::FrameOpError;
|
||||||
|
}
|
||||||
HRESULT hr = swapChainD->swapChain->Present(swapChainD->swapInterval, presentFlags);
|
HRESULT hr = swapChainD->swapChain->Present(swapChainD->swapInterval, presentFlags);
|
||||||
if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) {
|
if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) {
|
||||||
qWarning("Device loss detected in Present()");
|
qWarning("Device loss detected in Present()");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user