mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-20 11:52:00 +00:00
dispose caches
This commit is contained in:
parent
41fb433495
commit
c26df1f7a3
2 changed files with 17 additions and 2 deletions
|
@ -10,7 +10,7 @@ using System.Runtime.Versioning;
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
struct EncoderStateManager
|
struct EncoderStateManager : IDisposable
|
||||||
{
|
{
|
||||||
private readonly Pipeline _pipeline;
|
private readonly Pipeline _pipeline;
|
||||||
|
|
||||||
|
@ -34,6 +34,12 @@ namespace Ryujinx.Graphics.Metal
|
||||||
_depthStencilCache = new(device);
|
_depthStencilCache = new(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_renderPipelineCache.Dispose();
|
||||||
|
_depthStencilCache.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
public void SaveState()
|
public void SaveState()
|
||||||
{
|
{
|
||||||
_backStates.Add(_currentState);
|
_backStates.Add(_currentState);
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
[SupportedOSPlatform("macos")]
|
[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();
|
private readonly Dictionary<THash, T> _cache = new();
|
||||||
|
|
||||||
|
@ -12,6 +13,14 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
protected abstract T CreateValue(TDescriptor descriptor);
|
protected abstract T CreateValue(TDescriptor descriptor);
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
foreach (T value in _cache.Values)
|
||||||
|
{
|
||||||
|
value.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public T GetOrCreate(TDescriptor descriptor)
|
public T GetOrCreate(TDescriptor descriptor)
|
||||||
{
|
{
|
||||||
var hash = GetHash(descriptor);
|
var hash = GetHash(descriptor);
|
||||||
|
|
Loading…
Reference in a new issue