rhi: d3d11: Avoid 1 sec timeout when skipping present
endFrame(SkipPresent) followed by beginFrame() would sometimes end up waiting up to a second. We should not wait at all in this case. D3D12 patch will follow separately. Pick-to: 6.9 6.8 Change-Id: I3a5605c3fb672f9d68f2afb69645c5c47a5214b3 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
parent
66fae045cd
commit
f2437c9d8c
@ -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)
|
||||
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;
|
||||
|
||||
|
@ -626,6 +626,7 @@ struct QD3D11SwapChain : public QRhiSwapChain
|
||||
QD3D11SwapChainTimestamps timestamps;
|
||||
int currentTimestampPairIndex = 0;
|
||||
HANDLE frameLatencyWaitableObject = nullptr;
|
||||
int lastFrameLatencyWaitSlot = -1;
|
||||
};
|
||||
|
||||
class QD3D11Adapter : public QRhiAdapter
|
||||
|
Loading…
x
Reference in New Issue
Block a user