State and cache optimization (#27)

* WIP pipeline/depth state cache rework

* Fix some issues

* Fix some more default values

* Reduce allocations for state changes

* fix helpershader stuff

* explanation comment

* fix depth bias
This commit is contained in:
riperiperi 2024-06-28 21:14:53 +01:00 committed by Isaac Marovitz
parent 9d26aa8d06
commit e02df72323
14 changed files with 1142 additions and 565 deletions

View file

@ -57,19 +57,19 @@ namespace Ryujinx.Graphics.Metal
TriFanToTrisPattern = new IndexBufferPattern(_renderer, 3, 3, 2, [int.MinValue, -1, 0], 1, true);
}
public void SaveState()
public EncoderState SwapState(EncoderState state, DirtyFlags flags = DirtyFlags.All)
{
_encoderStateManager.SaveState();
return _encoderStateManager.SwapState(state, flags);
}
public void SaveAndResetState()
public PredrawState SavePredrawState()
{
_encoderStateManager.SaveAndResetState();
return _encoderStateManager.SavePredrawState();
}
public void RestoreState()
public void RestorePredrawState(PredrawState state)
{
_encoderStateManager.RestoreState();
_encoderStateManager.RestorePredrawState(state);
}
public void SetClearLoadAction(bool clear)
@ -240,8 +240,6 @@ namespace Ryujinx.Graphics.Metal
public void FlushCommandsImpl()
{
SaveState();
EndCurrentPass();
_byteWeight = 0;
@ -254,8 +252,6 @@ namespace Ryujinx.Graphics.Metal
CommandBuffer = (Cbs = _renderer.CommandBufferPool.ReturnAndRent(Cbs)).CommandBuffer;
_renderer.RegisterFlush();
RestoreState();
}
public void BlitColor(
@ -511,7 +507,14 @@ namespace Ryujinx.Graphics.Metal
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
{
_encoderStateManager.UpdateDepthBias(units, factor, clamp);
if (enables == 0)
{
_encoderStateManager.UpdateDepthBias(0, 0, 0);
}
else
{
_encoderStateManager.UpdateDepthBias(units, factor, clamp);
}
}
public void SetDepthClamp(bool clamp)