From 20b1f6a6eef9e84b59cb2acb0c01ce3921a3d59b Mon Sep 17 00:00:00 2001 From: SamoZ256 <96914946+SamoZ256@users.noreply.github.com> Date: Sat, 25 May 2024 19:46:51 +0200 Subject: [PATCH] Fix Scott Pilgrim (#15) * check for null vertex functions * format * Format --------- Co-authored-by: Isaac Marovitz --- .../EncoderStateManager.cs | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs b/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs index a6c931bc16..a15b23a692 100644 --- a/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs +++ b/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs @@ -227,29 +227,38 @@ namespace Ryujinx.Graphics.Metal var vertexDescriptor = BuildVertexDescriptor(_currentState.VertexBuffers, _currentState.VertexAttribs); renderPipelineDescriptor.VertexDescriptor = vertexDescriptor; - if (_currentState.VertexFunction != null) + try { - renderPipelineDescriptor.VertexFunction = _currentState.VertexFunction.Value; - } + if (_currentState.VertexFunction != null) + { + renderPipelineDescriptor.VertexFunction = _currentState.VertexFunction.Value; + } + else + { + return; + } - if (_currentState.FragmentFunction != null) + if (_currentState.FragmentFunction != null) + { + renderPipelineDescriptor.FragmentFunction = _currentState.FragmentFunction.Value; + } + + var pipelineState = _renderPipelineCache.GetOrCreate(renderPipelineDescriptor); + + renderCommandEncoder.SetRenderPipelineState(pipelineState); + + renderCommandEncoder.SetBlendColor( + _currentState.BlendColor.Red, + _currentState.BlendColor.Green, + _currentState.BlendColor.Blue, + _currentState.BlendColor.Alpha); + } + finally { - renderPipelineDescriptor.FragmentFunction = _currentState.FragmentFunction.Value; + // Cleanup + renderPipelineDescriptor.Dispose(); + vertexDescriptor.Dispose(); } - - var pipelineState = _renderPipelineCache.GetOrCreate(renderPipelineDescriptor); - - renderCommandEncoder.SetRenderPipelineState(pipelineState); - - renderCommandEncoder.SetBlendColor( - _currentState.BlendColor.Red, - _currentState.BlendColor.Green, - _currentState.BlendColor.Blue, - _currentState.BlendColor.Alpha); - - // Cleanup - renderPipelineDescriptor.Dispose(); - vertexDescriptor.Dispose(); } public void UpdateIndexBuffer(BufferRange buffer, IndexType type)