Browse Source

metal: fix backbuffer discarding its contents in some situations.

fixes #1975.
Sasha Szpakowski 1 year ago
parent
commit
6bc91a025c
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/modules/graphics/metal/Graphics.mm

+ 5 - 0
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)