From 6bc91a025cd61c4f3cc9eb89a2b9365b3252af68 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Mon, 8 Apr 2024 20:11:47 -0300 Subject: [PATCH] metal: fix backbuffer discarding its contents in some situations. fixes #1975. --- src/modules/graphics/metal/Graphics.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/graphics/metal/Graphics.mm b/src/modules/graphics/metal/Graphics.mm index 6fbe01a69..0c2380073 100644 --- a/src/modules/graphics/metal/Graphics.mm +++ b/src/modules/graphics/metal/Graphics.mm @@ -1459,10 +1459,15 @@ void Graphics::setRenderTargetsInternal(const RenderTargets &rts, int /*pixelw*/ } for (size_t i = rts.colors.size(); i < MAX_COLOR_RENDER_TARGETS; i++) + { passDesc.colorAttachments[i] = nil; + passDesc.colorAttachments[i].loadAction = MTLLoadActionLoad; + } passDesc.depthAttachment = nil; + passDesc.depthAttachment.loadAction = MTLLoadActionLoad; passDesc.stencilAttachment = nil; + passDesc.stencilAttachment.loadAction = MTLLoadActionLoad; auto ds = rts.depthStencil.texture; if (isbackbuffer && ds == nullptr)