From 97fe141f25655d2debd9f3f9ca278aaa759f15e0 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 4 Jun 2025 09:47:48 +0200 Subject: [PATCH] rhi: metal: Handle MSAA backing textures like other textures ...when it comes to dropping them in the swapchain's createOrResize(). There is no wait for command completion normally, unless the code path that calls destroy() is hit. Therefore, handling msaaTex like the textures behind any normal QRhiTexture is important. Use the deferred release mechanism that QRhiTexture's destroy() would use on its backing textures. This avoids the occasional validation message when resizing Qt Quick windows that have both multisampling and Metal validation enabled. Task-number: QTBUG-112355 Pick-to: 6.10 6.9 6.8 Change-Id: I34549ce47e675d5869239b9330a166b80b40b30d Reviewed-by: Andy Nichols --- src/gui/rhi/qrhimetal.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 42ebd9a5415..e05a6f08e70 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -6566,7 +6566,13 @@ bool QMetalSwapChain::createOrResize() desc.storageMode = MTLStorageModePrivate; desc.usage = MTLTextureUsageRenderTarget; for (int i = 0; i < QMTL_FRAMES_IN_FLIGHT; ++i) { - [d->msaaTex[i] release]; + if (d->msaaTex[i]) { + QRhiMetalData::DeferredReleaseEntry e; + e.type = QRhiMetalData::DeferredReleaseEntry::RenderBuffer; + e.lastActiveFrameSlot = 1; // because currentFrameSlot is reset to 0 + e.renderbuffer.texture = d->msaaTex[i]; + rhiD->d->releaseQueue.append(e); + } d->msaaTex[i] = [rhiD->d->dev newTextureWithDescriptor: desc]; } [desc release];