From 3c81c8907633fbc154ec4ae3a89e8d86c9ca0832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Thu, 6 Feb 2025 11:29:11 +0100 Subject: [PATCH] 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. Pick-to: 6.9 Change-Id: Ie30ca44bc7b4b8f29c517fe6c88fafbe46be3d17 Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhimetal.mm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 6f7db39e987..62a116cac26 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -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;