2021-07-11 20:20:40 +00:00
|
|
|
|
using Ryujinx.Graphics.Device;
|
2020-08-03 01:36:57 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Gpu.Engine.MME
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents a execution engine that uses a Just-in-Time compiler for fast execution.
|
|
|
|
|
/// </summary>
|
|
|
|
|
class MacroJit : IMacroEE
|
|
|
|
|
{
|
|
|
|
|
private readonly MacroJitContext _context = new MacroJitContext();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Arguments FIFO.
|
|
|
|
|
/// </summary>
|
2021-08-26 21:50:28 +00:00
|
|
|
|
public Queue<FifoWord> Fifo => _context.Fifo;
|
2020-08-03 01:36:57 +00:00
|
|
|
|
|
|
|
|
|
private MacroJitCompiler.MacroExecute _execute;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Executes a macro program until it exits.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="code">Code of the program to execute</param>
|
|
|
|
|
/// <param name="state">Current GPU state</param>
|
|
|
|
|
/// <param name="arg0">Optional argument passed to the program, 0 if not used</param>
|
2021-07-11 20:20:40 +00:00
|
|
|
|
public void Execute(ReadOnlySpan<int> code, IDeviceState state, int arg0)
|
2020-08-03 01:36:57 +00:00
|
|
|
|
{
|
|
|
|
|
if (_execute == null)
|
|
|
|
|
{
|
|
|
|
|
MacroJitCompiler compiler = new MacroJitCompiler();
|
|
|
|
|
|
|
|
|
|
_execute = compiler.Compile(code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_execute(_context, state, arg0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|