rhi: Always check and mark the extra buffers for reuse on metal

It's not just with tesselation we're using these buffers, but also for
multiview, which meant we'd continuously grow the pool until we run
out resources when multiview was enabled. Interesting observation
from this is that newBufferWithLength would 'hang' instead of
returning erroneously unable to acquire a new buffer.

Change-Id: Ie30ca44bc7b4b8f29c517fe6c88fafbe46be3d17
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit 3c81c8907633fbc154ec4ae3a89e8d86c9ca0832)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Christian Strømme 2025-02-06 11:29:11 +01:00 committed by Qt Cherry-pick Bot
parent 055b5a83b4
commit 5296136496

View File

@ -1509,18 +1509,18 @@ void QRhiMetal::setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline
cbD->currentComputePipeline = nullptr;
cbD->currentPipelineGeneration = psD->generation;
if (!psD->d->tess.enabled && !psD->d->tess.failed) {
if (!psD->d->tess.enabled && !psD->d->tess.failed)
psD->makeActiveForCurrentRenderPassEncoder(cbD);
} else {
// mark work buffers that can now be safely reused as reusable
for (QMetalBuffer *workBuf : psD->d->extraBufMgr.deviceLocalWorkBuffers) {
if (workBuf && workBuf->lastActiveFrameSlot == currentFrameSlot)
workBuf->lastActiveFrameSlot = -1;
}
for (QMetalBuffer *workBuf : psD->d->extraBufMgr.hostVisibleWorkBuffers) {
if (workBuf && workBuf->lastActiveFrameSlot == currentFrameSlot)
workBuf->lastActiveFrameSlot = -1;
}
// mark work buffers that can now be safely reused as reusable
// NOTE: These are usually empty unless tessellation or mutiview is used.
for (QMetalBuffer *workBuf : psD->d->extraBufMgr.deviceLocalWorkBuffers) {
if (workBuf && workBuf->lastActiveFrameSlot == currentFrameSlot)
workBuf->lastActiveFrameSlot = -1;
}
for (QMetalBuffer *workBuf : psD->d->extraBufMgr.hostVisibleWorkBuffers) {
if (workBuf && workBuf->lastActiveFrameSlot == currentFrameSlot)
workBuf->lastActiveFrameSlot = -1;
}
psD->lastActiveFrameSlot = currentFrameSlot;