dispose caches

This commit is contained in:
Samuliak
2024-05-24 20:03:55 +02:00
committed by Evan Husted
parent 2cb5265c8e
commit 1ff81393be
2 changed files with 17 additions and 2 deletions

View File

@@ -1,10 +1,11 @@
using System;
using System.Collections.Generic;
using System.Runtime.Versioning;
namespace Ryujinx.Graphics.Metal
{
[SupportedOSPlatform("macos")]
public abstract class StateCache<T, TDescriptor, THash>
public abstract class StateCache<T, TDescriptor, THash> : IDisposable where T : IDisposable
{
private readonly Dictionary<THash, T> _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);