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