diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index da27500995b..b79a1b9b8a9 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -1439,8 +1439,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(); @@ -5499,6 +5504,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 11927a5a3bb..48f99280c7a 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 QD3D11Adapter : public QRhiAdapter