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.9 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>
This commit is contained in:
Laszlo Agocs 2025-06-04 09:47:48 +02:00 committed by Qt Cherry-pick Bot
parent af519f5d8a
commit d7b80c9c9b

View File

@ -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];