From 01f41b8b0e532ef323cc19903823361745145746 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Mon, 5 Aug 2024 13:18:00 +0100 Subject: [PATCH] Get render command encoder after finalising buffers Fixes crash in Fire Emblem: Houses --- src/Ryujinx.Graphics.Metal/Pipeline.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Ryujinx.Graphics.Metal/Pipeline.cs b/src/Ryujinx.Graphics.Metal/Pipeline.cs index a4654d36a..8fb407905 100644 --- a/src/Ryujinx.Graphics.Metal/Pipeline.cs +++ b/src/Ryujinx.Graphics.Metal/Pipeline.cs @@ -315,8 +315,6 @@ namespace Ryujinx.Graphics.Metal return; } - var renderCommandEncoder = GetOrCreateRenderEncoder(true); - if (TopologyUnsupported(_encoderStateManager.Topology)) { var pattern = GetIndexBufferPattern(); @@ -326,6 +324,7 @@ namespace Ryujinx.Graphics.Metal var mtlBuffer = buffer.Get(Cbs, 0, indexCount * sizeof(int)).Value; var primitiveType = TopologyRemap(_encoderStateManager.Topology).Convert(); + var renderCommandEncoder = GetOrCreateRenderEncoder(true); renderCommandEncoder.DrawIndexedPrimitives( primitiveType, @@ -337,6 +336,7 @@ namespace Ryujinx.Graphics.Metal else { var primitiveType = TopologyRemap(_encoderStateManager.Topology).Convert(); + var renderCommandEncoder = GetOrCreateRenderEncoder(true); renderCommandEncoder.DrawPrimitives( primitiveType, @@ -449,8 +449,6 @@ namespace Ryujinx.Graphics.Metal public void DrawIndirect(BufferRange indirectBuffer) { - var renderCommandEncoder = GetOrCreateRenderEncoder(true); - if (TopologyUnsupported(_encoderStateManager.Topology)) { // TODO: Reindex unsupported topologies @@ -462,6 +460,7 @@ namespace Ryujinx.Graphics.Metal .Get(Cbs, indirectBuffer.Offset, indirectBuffer.Size).Value; var primitiveType = TopologyRemap(_encoderStateManager.Topology).Convert(); + var renderCommandEncoder = GetOrCreateRenderEncoder(true); renderCommandEncoder.DrawPrimitives( primitiveType,