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 <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2025-06-04 09:47:48 +02:00
parent 21616e1447
commit 97fe141f25

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