Implement MME shadow RAM (#987)
This commit is contained in:
parent
d904706fc0
commit
ff2bac9c90
4 changed files with 90 additions and 20 deletions
|
@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Gpu
|
|||
BitwiseNotAnd = 12
|
||||
}
|
||||
|
||||
public Queue<int> Fifo { get; private set; }
|
||||
public Queue<int> Fifo { get; }
|
||||
|
||||
private int[] _gprs;
|
||||
|
||||
|
@ -62,6 +62,8 @@ namespace Ryujinx.Graphics.Gpu
|
|||
|
||||
private int _pc;
|
||||
|
||||
private ShadowRamControl _shadowCtrl;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the macro code interpreter.
|
||||
/// </summary>
|
||||
|
@ -78,8 +80,10 @@ namespace Ryujinx.Graphics.Gpu
|
|||
/// <param name="mme">Code of the program to execute</param>
|
||||
/// <param name="position">Start position to execute</param>
|
||||
/// <param name="param">Optional argument passed to the program, 0 if not used</param>
|
||||
/// <param name="shadowCtrl">Shadow RAM control register value</param>
|
||||
/// <param name="state">Current GPU state</param>
|
||||
public void Execute(int[] mme, int position, int param, GpuState state)
|
||||
/// <param name="shadowState">Shadow GPU state</param>
|
||||
public void Execute(int[] mme, int position, int param, ShadowRamControl shadowCtrl, GpuState state, GpuState shadowState)
|
||||
{
|
||||
Reset();
|
||||
|
||||
|
@ -87,13 +91,15 @@ namespace Ryujinx.Graphics.Gpu
|
|||
|
||||
_pc = position;
|
||||
|
||||
_shadowCtrl = shadowCtrl;
|
||||
|
||||
FetchOpCode(mme);
|
||||
|
||||
while (Step(mme, state));
|
||||
while (Step(mme, state, shadowState));
|
||||
|
||||
// Due to the delay slot, we still need to execute
|
||||
// one more instruction before we actually exit.
|
||||
Step(mme, state);
|
||||
Step(mme, state, shadowState);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -118,8 +124,9 @@ namespace Ryujinx.Graphics.Gpu
|
|||
/// </summary>
|
||||
/// <param name="mme">Program code to execute</param>
|
||||
/// <param name="state">Current GPU state</param>
|
||||
/// <param name="shadowState">Shadow GPU state</param>
|
||||
/// <returns>True to continue execution, false if the program exited</returns>
|
||||
private bool Step(int[] mme, GpuState state)
|
||||
private bool Step(int[] mme, GpuState state, GpuState shadowState)
|
||||
{
|
||||
int baseAddr = _pc - 1;
|
||||
|
||||
|
@ -165,7 +172,7 @@ namespace Ryujinx.Graphics.Gpu
|
|||
{
|
||||
SetDstGpr(FetchParam());
|
||||
|
||||
Send(state, result);
|
||||
Send(state, shadowState, result);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -175,7 +182,7 @@ namespace Ryujinx.Graphics.Gpu
|
|||
{
|
||||
SetDstGpr(result);
|
||||
|
||||
Send(state, result);
|
||||
Send(state, shadowState, result);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -197,7 +204,7 @@ namespace Ryujinx.Graphics.Gpu
|
|||
|
||||
SetMethAddr(result);
|
||||
|
||||
Send(state, FetchParam());
|
||||
Send(state, shadowState, FetchParam());
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -209,7 +216,7 @@ namespace Ryujinx.Graphics.Gpu
|
|||
|
||||
SetMethAddr(result);
|
||||
|
||||
Send(state, (result >> 12) & 0x3f);
|
||||
Send(state, shadowState,(result >> 12) & 0x3f);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -482,9 +489,21 @@ namespace Ryujinx.Graphics.Gpu
|
|||
/// Performs a GPU method call.
|
||||
/// </summary>
|
||||
/// <param name="state">Current GPU state</param>
|
||||
/// <param name="shadowState">Shadow GPU state</param>
|
||||
/// <param name="value">Call argument</param>
|
||||
private void Send(GpuState state, int value)
|
||||
private void Send(GpuState state, GpuState shadowState, int value)
|
||||
{
|
||||
// TODO: Figure out what TrackWithFilter does, compared to Track.
|
||||
if (_shadowCtrl == ShadowRamControl.Track ||
|
||||
_shadowCtrl == ShadowRamControl.TrackWithFilter)
|
||||
{
|
||||
shadowState.Write(_methAddr, value);
|
||||
}
|
||||
else if (_shadowCtrl == ShadowRamControl.Replay)
|
||||
{
|
||||
value = shadowState.Read(_methAddr);
|
||||
}
|
||||
|
||||
MethodParams meth = new MethodParams(_methAddr, value);
|
||||
|
||||
state.CallMethod(meth);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue