From 4e6abb0191a298eaa9d870aba696cc9ad38016de Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 16 May 2024 20:29:37 -0400 Subject: [PATCH] Set Depth Attachment Texture --- src/Ryujinx.Graphics.Metal/Pipeline.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Ryujinx.Graphics.Metal/Pipeline.cs b/src/Ryujinx.Graphics.Metal/Pipeline.cs index 961512c1f8..3fbfc07bf5 100644 --- a/src/Ryujinx.Graphics.Metal/Pipeline.cs +++ b/src/Ryujinx.Graphics.Metal/Pipeline.cs @@ -30,6 +30,7 @@ namespace Ryujinx.Graphics.Metal private MTLCommandEncoder? _currentEncoder; private EncoderType _currentEncoderType = EncoderType.None; private MTLTexture[] _renderTargets = []; + private MTLTexture _depthTarget; private RenderEncoderState _renderEncoderState; private readonly MTLVertexDescriptor _vertexDescriptor = new(); @@ -136,6 +137,10 @@ namespace Ryujinx.Graphics.Metal } } + var depthAttachment = descriptor.DepthAttachment; + depthAttachment.Texture = _depthTarget; + depthAttachment.LoadAction = MTLLoadAction.Load; + var renderCommandEncoder = _commandBuffer.RenderCommandEncoder(descriptor); _renderEncoderState.SetEncoderState(renderCommandEncoder, descriptor, _vertexDescriptor); @@ -523,6 +528,11 @@ namespace Ryujinx.Graphics.Metal } } + if (depthStencil is Texture depthTexture) + { + _depthTarget = depthTexture.MTLTexture; + } + // Recreate Render Command Encoder BeginRenderPass(); }