diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2021-07-11 17:20:40 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-11 17:20:40 -0300 |
| commit | 40b21cc3c4d2622bbd4f88d43073341854d9a671 (patch) | |
| tree | 6e9dc6a42e7c0bae5b03db468481771d5a6937ef /Ryujinx.Graphics.Gpu/Engine/MME | |
| parent | b5190f16810eb77388c861d1d1773e19644808db (diff) | |
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
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Engine/MME')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MME/IMacroEE.cs | 6 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs | 4 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs | 22 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs | 4 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs | 6 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs | 12 |
6 files changed, 26 insertions, 28 deletions
diff --git a/Ryujinx.Graphics.Gpu/Engine/MME/IMacroEE.cs b/Ryujinx.Graphics.Gpu/Engine/MME/IMacroEE.cs index b056ecc8..b957de08 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MME/IMacroEE.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MME/IMacroEE.cs @@ -1,4 +1,4 @@ -using Ryujinx.Graphics.Gpu.State; +using Ryujinx.Graphics.Device; using System; using System.Collections.Generic; @@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// <summary> /// Arguments FIFO. /// </summary> - public Queue<int> Fifo { get; } + Queue<int> Fifo { get; } /// <summary> /// Should execute the GPU Macro code being passed. @@ -20,6 +20,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// <param name="code">Code to be executed</param> /// <param name="state">GPU state at the time of the call</param> /// <param name="arg0">First argument to be passed to the GPU Macro</param> - void Execute(ReadOnlySpan<int> code, GpuState state, int arg0); + void Execute(ReadOnlySpan<int> code, IDeviceState state, int arg0); } } diff --git a/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs b/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs index 9847f4c0..1a79afb9 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs @@ -1,4 +1,4 @@ -using Ryujinx.Graphics.Gpu.State; +using Ryujinx.Graphics.Device; using System; namespace Ryujinx.Graphics.Gpu.Engine.MME @@ -55,7 +55,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// </summary> /// <param name="code">Program code</param> /// <param name="state">Current GPU state</param> - public void Execute(ReadOnlySpan<int> code, GpuState state) + public void Execute(ReadOnlySpan<int> code, IDeviceState state) { if (_executionPending) { diff --git a/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs b/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs index 9a834ca6..0173a7fb 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs @@ -1,5 +1,5 @@ using Ryujinx.Common.Logging; -using Ryujinx.Graphics.Gpu.State; +using Ryujinx.Graphics.Device; using System; using System.Collections.Generic; @@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// <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> - public void Execute(ReadOnlySpan<int> code, GpuState state, int arg0) + public void Execute(ReadOnlySpan<int> code, IDeviceState state, int arg0) { Reset(); @@ -55,7 +55,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME FetchOpCode(code); - while (Step(code, state)) ; + while (Step(code, state)) + { + } // Due to the delay slot, we still need to execute // one more instruction before we actually exit. @@ -85,7 +87,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// <param name="code">Program code to execute</param> /// <param name="state">Current GPU state</param> /// <returns>True to continue execution, false if the program exited</returns> - private bool Step(ReadOnlySpan<int> code, GpuState state) + private bool Step(ReadOnlySpan<int> code, IDeviceState state) { int baseAddr = _pc - 1; @@ -193,7 +195,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// </summary> /// <param name="state">Current GPU state</param> /// <returns>Operation result</returns> - private int GetAluResult(GpuState state) + private int GetAluResult(IDeviceState state) { AluOperation op = (AluOperation)(_opCode & 7); @@ -378,9 +380,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// <param name="state">Current GPU state</param> /// <param name="reg">Register offset to read</param> /// <returns>GPU register value</returns> - private int Read(GpuState state, int reg) + private int Read(IDeviceState state, int reg) { - return state.Read(reg); + return state.Read(reg * 4); } /// <summary> @@ -388,11 +390,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// </summary> /// <param name="state">Current GPU state</param> /// <param name="value">Call argument</param> - private void Send(GpuState state, int value) + private void Send(IDeviceState state, int value) { - MethodParams meth = new MethodParams(_methAddr, value); - - state.CallMethod(meth); + state.Write(_methAddr * 4, value); _methAddr += _methIncr; } diff --git a/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs b/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs index 346ae6cf..f0393dd1 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs @@ -1,4 +1,4 @@ -using Ryujinx.Graphics.Gpu.State; +using Ryujinx.Graphics.Device; using System; using System.Collections.Generic; @@ -24,7 +24,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// <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> - public void Execute(ReadOnlySpan<int> code, GpuState state, int arg0) + public void Execute(ReadOnlySpan<int> code, IDeviceState state, int arg0) { if (_execute == null) { diff --git a/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs b/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs index e752b9dc..d281a75a 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs @@ -1,4 +1,4 @@ -using Ryujinx.Graphics.Gpu.State; +using Ryujinx.Graphics.Device; using System; using System.Collections.Generic; using System.Reflection.Emit; @@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// </summary> public MacroJitCompiler() { - _meth = new DynamicMethod("Macro", typeof(void), new Type[] { typeof(MacroJitContext), typeof(GpuState), typeof(int) }); + _meth = new DynamicMethod("Macro", typeof(void), new Type[] { typeof(MacroJitContext), typeof(IDeviceState), typeof(int) }); _ilGen = _meth.GetILGenerator(); _gprs = new LocalBuilder[8]; @@ -39,7 +39,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME _ilGen.Emit(OpCodes.Stloc, _gprs[1]); } - public delegate void MacroExecute(MacroJitContext context, GpuState state, int arg0); + public delegate void MacroExecute(MacroJitContext context, IDeviceState state, int arg0); /// <summary> /// Translates a new piece of GPU Macro code into host executable code. diff --git a/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs b/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs index ba426dc0..aa31c9ee 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs @@ -1,5 +1,5 @@ using Ryujinx.Common.Logging; -using Ryujinx.Graphics.Gpu.State; +using Ryujinx.Graphics.Device; using System.Collections.Generic; namespace Ryujinx.Graphics.Gpu.Engine.MME @@ -36,9 +36,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// <param name="state">Current GPU state</param> /// <param name="reg">Register offset to read</param> /// <returns>GPU register value</returns> - public static int Read(GpuState state, int reg) + public static int Read(IDeviceState state, int reg) { - return state.Read(reg); + return state.Read(reg * 4); } /// <summary> @@ -47,11 +47,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// <param name="value">Call argument</param> /// <param name="state">Current GPU state</param> /// <param name="methAddr">Address, in words, of the method</param> - public static void Send(int value, GpuState state, int methAddr) + public static void Send(int value, IDeviceState state, int methAddr) { - MethodParams meth = new MethodParams(methAddr, value); - - state.CallMethod(meth); + state.Write(methAddr * 4, value); } } } |
