rhi: d3d12: Fix finish() when called outside a frame

Pick-to: 6.9 6.8
Fixes: QTBUG-133454
Change-Id: I447610917966a9dcd4b80dc8b84156ce985f9ca9
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2025-02-03 14:37:40 +01:00
parent 68e48ac60a
commit 01308ff18e

View File

@ -1949,10 +1949,8 @@ QRhi::FrameOpResult QRhiD3D12::endOffscreenFrame(QRhi::EndFrameFlags flags)
QRhi::FrameOpResult QRhiD3D12::finish()
{
if (!inFrame)
return QRhi::FrameOpSuccess;
QD3D12CommandBuffer *cbD = nullptr;
if (inFrame) {
if (offscreenActive) {
Q_ASSERT(!currentSwapChain);
cbD = offscreenCb[currentFrameSlot];
@ -1977,18 +1975,20 @@ QRhi::FrameOpResult QRhiD3D12::finish()
cmdQueue->ExecuteCommandLists(1, execList);
releaseQueue.activatePendingDeferredReleaseRequests(currentFrameSlot);
}
// full blocking wait for everything, frame slots do not matter now
waitGpu();
hr = cmdAllocators[currentFrameSlot]->Reset();
if (inFrame) {
HRESULT hr = cmdAllocators[currentFrameSlot]->Reset();
if (FAILED(hr)) {
qWarning("Failed to reset command allocator: %s",
qPrintable(QSystemError::windowsComString(hr)));
return QRhi::FrameOpError;
}
if (!startCommandListForCurrentFrameSlot(&cmdList))
if (!startCommandListForCurrentFrameSlot(&cbD->cmdList))
return QRhi::FrameOpError;
cbD->resetState();
@ -1997,9 +1997,9 @@ QRhi::FrameOpResult QRhiD3D12::finish()
smallStagingAreas[currentFrameSlot].head = 0;
bindShaderVisibleHeaps(cbD);
}
releaseQueue.executeDeferredReleases(currentFrameSlot);
releaseQueue.releaseAll();
finishActiveReadbacks(true);
return QRhi::FrameOpSuccess;