/ src / Ryujinx.Graphics.Gpu / Engine / MME / MacroJit.cs
MacroJit.cs
 1  using Ryujinx.Graphics.Device;
 2  using System;
 3  using System.Collections.Generic;
 4  
 5  namespace Ryujinx.Graphics.Gpu.Engine.MME
 6  {
 7      /// <summary>
 8      /// Represents a execution engine that uses a Just-in-Time compiler for fast execution.
 9      /// </summary>
10      class MacroJit : IMacroEE
11      {
12          private readonly MacroJitContext _context = new();
13  
14          /// <summary>
15          /// Arguments FIFO.
16          /// </summary>
17          public Queue<FifoWord> Fifo => _context.Fifo;
18  
19          private MacroJitCompiler.MacroExecute _execute;
20  
21          /// <summary>
22          /// Executes a macro program until it exits.
23          /// </summary>
24          /// <param name="code">Code of the program to execute</param>
25          /// <param name="state">Current GPU state</param>
26          /// <param name="arg0">Optional argument passed to the program, 0 if not used</param>
27          public void Execute(ReadOnlySpan<int> code, IDeviceState state, int arg0)
28          {
29              if (_execute == null)
30              {
31                  MacroJitCompiler compiler = new();
32  
33                  _execute = compiler.Compile(code);
34              }
35  
36              _execute(_context, state, arg0);
37          }
38      }
39  }