1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-24 07:16:04 +00:00

Use Stack instead of List

This commit is contained in:
Isaac Marovitz 2024-05-25 12:21:42 -04:00 committed by Isaac Marovitz
parent 0e095c778a
commit bbcd05aacf

View file

@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Metal
private readonly DepthStencilCache _depthStencilCache; private readonly DepthStencilCache _depthStencilCache;
private EncoderState _currentState = new(); private EncoderState _currentState = new();
private List<EncoderState> _backStates = new(); private readonly Stack<EncoderState> _backStates = [];
public readonly MTLBuffer IndexBuffer => _currentState.IndexBuffer; public readonly MTLBuffer IndexBuffer => _currentState.IndexBuffer;
public readonly MTLIndexType IndexType => _currentState.IndexType; public readonly MTLIndexType IndexType => _currentState.IndexType;
@ -44,17 +44,16 @@ namespace Ryujinx.Graphics.Metal
_depthStencilCache.Dispose(); _depthStencilCache.Dispose();
} }
public void SaveState() public readonly void SaveState()
{ {
_backStates.Add(_currentState); _backStates.Push(_currentState);
} }
public void RestoreState() public void RestoreState()
{ {
if (_backStates.Count > 0) if (_backStates.Count > 0)
{ {
_currentState = _backStates[_backStates.Count - 1]; _currentState = _backStates.Pop();
_backStates.RemoveAt(_backStates.Count - 1);
// Set all the inline state, since it might have changed // Set all the inline state, since it might have changed
var renderCommandEncoder = _pipeline.GetOrCreateRenderEncoder(); var renderCommandEncoder = _pipeline.GetOrCreateRenderEncoder();