0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-23 17:25:48 +00:00
Ryujinx/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs
gdkchan 40b21cc3c4
Separate GPU engines (part 2/2) (#2440)
* 3D engine now uses DeviceState too, plus new state modification tracking

* Remove old methods code

* Remove GpuState and friends

* Optimize DeviceState, force inline some functions

* This change was not supposed to go in

* Proper channel initialization

* Optimize state read/write methods even more

* Fix debug build

* Do not dirty state if the write is redundant

* The YControl register should dirty either the viewport or front face state too, to update the host origin

* Avoid redundant vertex buffer updates

* Move state and get rid of the Ryujinx.Graphics.Gpu.State namespace

* Comments and nits

* Fix rebase

* PR feedback

* Move changed = false to improve codegen

* PR feedback

* Carry RyuJIT a bit more
2021-07-11 17:20:40 -03:00

77 lines
2.1 KiB
C#

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