Use Stack instead of List

This commit is contained in:
Isaac Marovitz 2024-05-25 12:21:42 -04:00
parent c19dee2f8e
commit a14ca383b2
No known key found for this signature in database
GPG Key ID: 97250B2B09A132E1
1 changed files with 4 additions and 5 deletions

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();