using Ryujinx.Graphics.Gpu.State; using System; 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 IMacroEE _executionEngine; /// /// Creates a new instance of the GPU cached macro program. /// /// Macro code start position 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. /// /// 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(ReadOnlySpan code, GpuState state) { if (_executionPending) { _executionPending = false; _executionEngine?.Execute(code.Slice(Position), state, _argument); } } /// /// Pushes an argument to the macro call argument FIFO. /// /// Argument to be pushed public void PushArgument(int argument) { _executionEngine?.Fifo.Enqueue(argument); } } }