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.8
Change-Id: I34549ce47e675d5869239b9330a166b80b40b30d
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit 97fe141f25655d2debd9f3f9ca278aaa759f15e0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit d7b80c9c9bb09e6c51301318d192f054f5b1d70e)
This commit is contained in:
Laszlo Agocs 2025-06-04 09:47:48 +02:00 committed by Qt Cherry-pick Bot
parent 1fe3a3c059
commit 3a980cfd94

View File

@ -6535,7 +6535,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];