using Ryujinx.Graphics.Device;
using System;
namespace Ryujinx.Graphics.Gpu.Engine.MME
{
/// <summary>
/// GPU macro program.
/// </summary>
struct Macro
/// Word offset of the code on the code memory.
public int Position { get; }
private bool _executionPending;
private int _argument;
private readonly IMacroEE _executionEngine;
/// Creates a new instance of the GPU cached macro program.
/// <param name="position">Macro code start position</param>
public Macro(int position)
Position = position;
_executionPending = false;
_argument = 0;
if (GraphicsConfig.EnableMacroJit)
_executionEngine = new MacroJit();
}
else
_executionEngine = new MacroInterpreter();
/// Sets the first argument for the macro call.
/// <param name="argument">First argument</param>
public void StartExecution(int argument)
_argument = argument;
_executionPending = true;
/// Starts executing the macro program code.
/// <param name="code">Program code</param>
/// <param name="state">Current GPU state</param>
public void Execute(ReadOnlySpan<int> code, IDeviceState state)
if (_executionPending)
_executionEngine?.Execute(code.Slice(Position), state, _argument);
/// Pushes an argument to the macro call argument FIFO.
/// <param name="argument">Argument to be pushed</param>
public void PushArgument(int argument)
_executionEngine?.Fifo.Enqueue(argument);