rhi: d3d12: Avoid 1 sec timeout when skipping present
Follow the d3d11 change. Pick-to: 6.8 Change-Id: I06ef9e64f37fba72c2ab6adc84ad9058f22ae1e4 Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit d8fb42bb790f468ad1b5304b743dbff297582ddd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
f07a3e07d1
commit
7cd1dbce12
@ -1647,8 +1647,13 @@ QRhi::FrameOpResult QRhiD3D12::beginFrame(QRhiSwapChain *swapChain, QRhi::BeginF
|
||||
for (QD3D12SwapChain *sc : std::as_const(swapchains))
|
||||
sc->waitCommandCompletionForFrameSlot(currentFrameSlot); // note: swapChainD->currentFrameSlot, not sc's
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT hr = cmdAllocators[currentFrameSlot]->Reset();
|
||||
if (FAILED(hr)) {
|
||||
@ -6759,6 +6764,7 @@ bool QD3D12SwapChain::createOrResize()
|
||||
|
||||
currentBackBufferIndex = swapChain->GetCurrentBackBufferIndex();
|
||||
currentFrameSlot = 0;
|
||||
lastFrameLatencyWaitSlot = -1; // wait already in the first frame, as instructed in the dxgi docs
|
||||
|
||||
rtWrapper.setRenderPassDescriptor(m_renderPassDesc); // for the public getter in QRhiRenderTarget
|
||||
QD3D12SwapChainRenderTarget *rtD = QRHI_RES(QD3D12SwapChainRenderTarget, &rtWrapper);
|
||||
|
@ -1079,6 +1079,7 @@ struct QD3D12SwapChain : public QRhiSwapChain
|
||||
} frameRes[QD3D12_FRAMES_IN_FLIGHT];
|
||||
|
||||
int currentFrameSlot = 0; // index in frameRes
|
||||
int lastFrameLatencyWaitSlot = -1;
|
||||
};
|
||||
|
||||
template<typename T, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type>
|
||||
|
Loading…
x
Reference in New Issue
Block a user