diff --git a/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs b/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs index 313d380f4..ab9b362ba 100644 --- a/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs +++ b/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs @@ -10,7 +10,7 @@ using System.Runtime.Versioning; namespace Ryujinx.Graphics.Metal { [SupportedOSPlatform("macos")] - struct EncoderStateManager + struct EncoderStateManager : IDisposable { private readonly Pipeline _pipeline; @@ -34,6 +34,12 @@ namespace Ryujinx.Graphics.Metal _depthStencilCache = new(device); } + public void Dispose() + { + _renderPipelineCache.Dispose(); + _depthStencilCache.Dispose(); + } + public void SaveState() { _backStates.Add(_currentState); diff --git a/src/Ryujinx.Graphics.Metal/StateCache.cs b/src/Ryujinx.Graphics.Metal/StateCache.cs index 2abf5f528..4b2c6c5a4 100644 --- a/src/Ryujinx.Graphics.Metal/StateCache.cs +++ b/src/Ryujinx.Graphics.Metal/StateCache.cs @@ -1,10 +1,11 @@ +using System; using System.Collections.Generic; using System.Runtime.Versioning; namespace Ryujinx.Graphics.Metal { [SupportedOSPlatform("macos")] - public abstract class StateCache + public abstract class StateCache : IDisposable where T : IDisposable { private readonly Dictionary _cache = new(); @@ -12,6 +13,14 @@ namespace Ryujinx.Graphics.Metal protected abstract T CreateValue(TDescriptor descriptor); + public void Dispose() + { + foreach (T value in _cache.Values) + { + value.Dispose(); + } + } + public T GetOrCreate(TDescriptor descriptor) { var hash = GetHash(descriptor);