MacroJit.cs 1.2 KB

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