Implement MME shadow RAM (#987)

This commit is contained in:
gdkchan 2020-03-12 22:30:26 -03:00 committed by GitHub
parent d904706fc0
commit ff2bac9c90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 90 additions and 20 deletions

View file

@ -1,4 +1,5 @@
using Ryujinx.Graphics.Gpu.State;
using System.IO;
namespace Ryujinx.Graphics.Gpu
{
@ -61,13 +62,13 @@ namespace Ryujinx.Graphics.Gpu
/// </summary>
/// <param name="mme">Program code</param>
/// <param name="state">Current GPU state</param>
public void Execute(int[] mme, GpuState state)
public void Execute(int[] mme, ShadowRamControl shadowCtrl, GpuState state, GpuState shadowState)
{
if (_executionPending)
{
_executionPending = false;
_interpreter?.Execute(mme, Position, _argument, state);
_interpreter?.Execute(mme, Position, _argument, shadowCtrl, state, shadowState);
}
}
@ -84,6 +85,8 @@ namespace Ryujinx.Graphics.Gpu
private int _currMacroPosition;
private int _currMacroBindIndex;
private ShadowRamControl _shadowCtrl;
private CachedMacro[] _macros;
private int[] _mme;
@ -98,6 +101,11 @@ namespace Ryujinx.Graphics.Gpu
/// </summary>
public GpuState State { get; }
/// <summary>
/// Sub-channel shadow GPU state (used as backup storage to restore MME changes).
/// </summary>
public GpuState ShadowState { get; }
/// <summary>
/// Engine bound to the sub-channel.
/// </summary>
@ -109,6 +117,7 @@ namespace Ryujinx.Graphics.Gpu
public SubChannel()
{
State = new GpuState();
ShadowState = new GpuState();
}
}
@ -188,11 +197,22 @@ namespace Ryujinx.Graphics.Gpu
break;
}
case NvGpuFifoMeth.SetMmeShadowRamControl:
{
_shadowCtrl = (ShadowRamControl)meth.Argument;
break;
}
}
}
else if (meth.Method < 0xe00)
{
_subChannels[meth.SubChannel].State.CallMethod(meth);
SubChannel sc = _subChannels[meth.SubChannel];
sc.ShadowState.Write(meth.Method, meth.Argument);
sc.State.CallMethod(meth);
}
else
{
@ -209,7 +229,9 @@ namespace Ryujinx.Graphics.Gpu
if (meth.IsLastCall)
{
_macros[macroIndex].Execute(_mme, _subChannels[meth.SubChannel].State);
SubChannel sc = _subChannels[meth.SubChannel];
_macros[macroIndex].Execute(_mme, _shadowCtrl, sc.State, sc.ShadowState);
_context.Methods.PerformDeferredDraws();
}