using Ryujinx.Graphics.Gpu.State;
namespace Ryujinx.Graphics.Gpu.Engine.MME
{
///
/// GPU macro program.
///
struct Macro
{
///
/// Word offset of the code on the code memory.
///
public int Position { get; }
private bool _executionPending;
private int _argument;
private readonly MacroInterpreter _interpreter;
///
/// Creates a new instance of the GPU cached macro program.
///
/// Macro code start position
public Macro(int position)
{
Position = position;
_executionPending = false;
_argument = 0;
_interpreter = new MacroInterpreter();
}
///
/// Sets the first argument for the macro call.
///
/// First argument
public void StartExecution(int argument)
{
_argument = argument;
_executionPending = true;
}
///
/// Starts executing the macro program code.
///
/// Program code
/// Current GPU state
public void Execute(int[] mme, ShadowRamControl shadowCtrl, GpuState state)
{
if (_executionPending)
{
_executionPending = false;
_interpreter?.Execute(mme, Position, _argument, shadowCtrl, state);
}
}
///
/// Pushes an argument to the macro call argument FIFO.
///
/// Argument to be pushed
public void PushArgument(int argument)
{
_interpreter?.Fifo.Enqueue(argument);
}
}
}