diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 603ada99d71..f7477ca1053 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -1396,8 +1396,13 @@ QRhi::FrameOpResult QRhiD3D11::beginFrame(QRhiSwapChain *swapChain, QRhi::BeginF const int currentFrameSlot = swapChainD->currentFrameSlot; // if we have a waitable object, now is the time to wait on it - if (swapChainD->frameLatencyWaitableObject) - WaitForSingleObjectEx(swapChainD->frameLatencyWaitableObject, 1000, true); + if (swapChainD->frameLatencyWaitableObject) { + // only wait when endFrame() called Present(), otherwise this would become a 1 sec timeout + if (swapChainD->lastFrameLatencyWaitSlot != currentFrameSlot) { + WaitForSingleObjectEx(swapChainD->frameLatencyWaitableObject, 1000, true); + swapChainD->lastFrameLatencyWaitSlot = currentFrameSlot; + } + } swapChainD->cb.resetState(); @@ -5442,6 +5447,7 @@ bool QD3D11SwapChain::createOrResize() } currentFrameSlot = 0; + lastFrameLatencyWaitSlot = -1; // wait already in the first frame, as instructed in the dxgi docs frameCount = 0; ds = m_depthStencil ? QRHI_RES(QD3D11RenderBuffer, m_depthStencil) : nullptr; diff --git a/src/gui/rhi/qrhid3d11_p.h b/src/gui/rhi/qrhid3d11_p.h index 1612111e243..9de4e780eec 100644 --- a/src/gui/rhi/qrhid3d11_p.h +++ b/src/gui/rhi/qrhid3d11_p.h @@ -626,6 +626,7 @@ struct QD3D11SwapChain : public QRhiSwapChain QD3D11SwapChainTimestamps timestamps; int currentTimestampPairIndex = 0; HANDLE frameLatencyWaitableObject = nullptr; + int lastFrameLatencyWaitSlot = -1; }; class QRhiD3D11 : public QRhiImplementation