diff options
| author | TSRBerry <20988865+TSRBerry@users.noreply.github.com> | 2023-07-02 02:47:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-02 02:47:54 +0200 |
| commit | 3b46bb73f781a011705ecbc8a1d3207dfb145829 (patch) | |
| tree | 1d5d2714c7001775b512bc14ce91a1ebbfc808df /src/Ryujinx.Graphics.Gpu/Engine/MME | |
| parent | 2457cfc9118a6ebb6008945c919edfd8b46af5e7 (diff) | |
[Ryujinx.Graphics.Gpu] Address dotnet-format issues (#5367)
* dotnet format style --severity info
Some changes were manually reverted.
* dotnet format analyzers --serverity info
Some changes have been minimally adapted.
* Restore a few unused methods and variables
* Silence dotnet format IDE0060 warnings
* Silence dotnet format IDE0052 warnings
* Address dotnet format CA1816 warnings
* Address or silence dotnet format CA1069 warnings
* Address or silence dotnet format CA2211 warnings
* Address remaining dotnet format analyzer warnings
* Address review comments
* Address most dotnet format whitespace warnings
* Apply dotnet format whitespace formatting
A few of them have been manually reverted and the corresponding warning was silenced
* Format if-blocks correctly
* Run dotnet format whitespace after rebase
* Run dotnet format style after rebase
* Another rebase, another dotnet format run
* Run dotnet format style after rebase
* Run dotnet format after rebase and remove unused usings
- analyzers
- style
- whitespace
* Disable 'prefer switch expression' rule
* Add comments to disabled warnings
* Remove a few unused parameters
* Replace MmeShadowScratch with Array256<uint>
* Simplify properties and array initialization, Use const when possible, Remove trailing commas
* Start working on disabled warnings
* Fix and silence a few dotnet-format warnings again
* Run dotnet format after rebase
* Address IDE0251 warnings
* Silence IDE0060 in .editorconfig
* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"
This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.
* dotnet format whitespace after rebase
* First pass of dotnet format
* Add unsafe dotnet format changes
* Fix typos
* Add trailing commas
* Disable formatting for FormatTable
* Address review feedback
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu/Engine/MME')
11 files changed, 33 insertions, 27 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/AluOperation.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/AluOperation.cs index eeef9c67..43faa788 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/AluOperation.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/AluOperation.cs @@ -10,6 +10,6 @@ BitfieldReplace = 2, BitfieldExtractLslImm = 3, BitfieldExtractLslReg = 4, - ReadImmediate = 5 + ReadImmediate = 5, } } diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/AluRegOperation.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/AluRegOperation.cs index f3e05d38..c878bd41 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/AluRegOperation.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/AluRegOperation.cs @@ -13,6 +13,6 @@ BitwiseOr = 9, BitwiseAnd = 10, BitwiseAndNot = 11, - BitwiseNotAnd = 12 + BitwiseNotAnd = 12, } } diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/AssignmentOperation.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/AssignmentOperation.cs index dc336026..592aa5a6 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/AssignmentOperation.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/AssignmentOperation.cs @@ -12,6 +12,6 @@ MoveAndSend = 4, FetchAndSetMaddr = 5, MoveAndSetMaddrThenFetchAndSend = 6, - MoveAndSetMaddrThenSendHigh = 7 + MoveAndSetMaddrThenSendHigh = 7, } } diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs index 12a3ac02..65c6aab4 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs @@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME if (_executionEngine == null) { - if (GraphicsConfig.EnableMacroHLE && MacroHLETable.TryGetMacroHLEFunction(code.Slice(Position), context.Capabilities, out _hleFunction)) + if (GraphicsConfig.EnableMacroHLE && MacroHLETable.TryGetMacroHLEFunction(code[Position..], context.Capabilities, out _hleFunction)) { _executionEngine = new MacroHLE(processor, _hleFunction); } @@ -84,7 +84,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME if (_executionPending) { _executionPending = false; - _executionEngine?.Execute(code.Slice(Position), state, _argument); + _executionEngine?.Execute(code[Position..], state, _argument); } } @@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// </summary> /// <param name="gpuVa">GPU virtual address where the command word is located</param> /// <param name="argument">Argument to be pushed</param> - public void PushArgument(ulong gpuVa, int argument) + public readonly void PushArgument(ulong gpuVa, int argument) { _executionEngine?.Fifo.Enqueue(new FifoWord(gpuVa, argument)); } diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs index 8630bbc4..a4c4dd10 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs @@ -16,7 +16,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME private const int ColorStructSize = 0x40; private const int ZetaLayerCountOffset = 0x1230; - private const int IndirectDataEntrySize = 0x10; private const int IndirectIndexedDataEntrySize = 0x14; private readonly GPFifoProcessor _processor; @@ -262,10 +261,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME for (int i = 0; i < maxDrawCount; i++) { var count = FetchParam(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment var instanceCount = FetchParam(); var firstIndex = FetchParam(); var firstVertex = FetchParam(); var firstInstance = FetchParam(); +#pragma warning restore IDE0059 if (i == 0) { diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLEFunctionName.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLEFunctionName.cs index 751867fc..9e71761b 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLEFunctionName.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLEFunctionName.cs @@ -11,6 +11,6 @@ DrawArraysInstanced, DrawElementsInstanced, DrawElementsIndirect, - MultiDrawElementsIndirectCount + MultiDrawElementsIndirectCount, } } diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs index 719e170f..5630756c 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs @@ -46,12 +46,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME private static readonly TableEntry[] _table = new TableEntry[] { - new TableEntry(MacroHLEFunctionName.ClearColor, new Hash128(0xA9FB28D1DC43645A, 0xB177E5D2EAE67FB0), 0x28), - new TableEntry(MacroHLEFunctionName.ClearDepthStencil, new Hash128(0x1B96CB77D4879F4F, 0x8557032FE0C965FB), 0x24), - new TableEntry(MacroHLEFunctionName.DrawArraysInstanced, new Hash128(0x197FB416269DBC26, 0x34288C01DDA82202), 0x48), - new TableEntry(MacroHLEFunctionName.DrawElementsInstanced, new Hash128(0x1A501FD3D54EC8E0, 0x6CF570CF79DA74D6), 0x5c), - new TableEntry(MacroHLEFunctionName.DrawElementsIndirect, new Hash128(0x86A3E8E903AF8F45, 0xD35BBA07C23860A4), 0x7c), - new TableEntry(MacroHLEFunctionName.MultiDrawElementsIndirectCount, new Hash128(0x890AF57ED3FB1C37, 0x35D0C95C61F5386F), 0x19C) + new(MacroHLEFunctionName.ClearColor, new Hash128(0xA9FB28D1DC43645A, 0xB177E5D2EAE67FB0), 0x28), + new(MacroHLEFunctionName.ClearDepthStencil, new Hash128(0x1B96CB77D4879F4F, 0x8557032FE0C965FB), 0x24), + new(MacroHLEFunctionName.DrawArraysInstanced, new Hash128(0x197FB416269DBC26, 0x34288C01DDA82202), 0x48), + new(MacroHLEFunctionName.DrawElementsInstanced, new Hash128(0x1A501FD3D54EC8E0, 0x6CF570CF79DA74D6), 0x5c), + new(MacroHLEFunctionName.DrawElementsIndirect, new Hash128(0x86A3E8E903AF8F45, 0xD35BBA07C23860A4), 0x7c), + new(MacroHLEFunctionName.MultiDrawElementsIndirectCount, new Hash128(0x890AF57ED3FB1C37, 0x35D0C95C61F5386F), 0x19C), }; /// <summary> @@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME { ref var entry = ref _table[i]; - var hash = XXHash128.ComputeHash(mc.Slice(0, entry.Length)); + var hash = XXHash128.ComputeHash(mc[..entry.Length]); if (hash == entry.Hash) { if (IsMacroHLESupported(caps, entry.Name)) diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs index df6ee040..dd60688d 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs @@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// </summary> public Queue<FifoWord> Fifo { get; } - private int[] _gprs; + private readonly int[] _gprs; private int _methAddr; private int _methIncr; @@ -291,11 +291,16 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME return (int)result; - case AluRegOperation.BitwiseExclusiveOr: return a ^ b; - case AluRegOperation.BitwiseOr: return a | b; - case AluRegOperation.BitwiseAnd: return a & b; - case AluRegOperation.BitwiseAndNot: return a & ~b; - case AluRegOperation.BitwiseNotAnd: return ~(a & b); + case AluRegOperation.BitwiseExclusiveOr: + return a ^ b; + case AluRegOperation.BitwiseOr: + return a | b; + case AluRegOperation.BitwiseAnd: + return a & b; + case AluRegOperation.BitwiseAndNot: + return a & ~b; + case AluRegOperation.BitwiseNotAnd: + return ~(a & b); } throw new InvalidOperationException($"Invalid operation \"{aluOp}\" on instruction 0x{_opCode:X8}."); @@ -380,7 +385,7 @@ 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(IDeviceState state, int reg) + private static int Read(IDeviceState state, int reg) { return state.Read(reg * 4); } @@ -397,4 +402,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME _methAddr += _methIncr; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs index 4077f74e..a23bfef1 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs @@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// </summary> class MacroJit : IMacroEE { - private readonly MacroJitContext _context = new MacroJitContext(); + private readonly MacroJitContext _context = new(); /// <summary> /// Arguments FIFO. @@ -28,7 +28,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME { if (_execute == null) { - MacroJitCompiler compiler = new MacroJitCompiler(); + MacroJitCompiler compiler = new(); _execute = compiler.Compile(code); } diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs index f8d839fa..d9c26c58 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs @@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// <returns>Delegate of the host compiled code</returns> public MacroExecute Compile(ReadOnlySpan<int> code) { - Dictionary<int, Label> labels = new Dictionary<int, Label>(); + Dictionary<int, Label> labels = new(); int lastTarget = 0; int i; diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs index 52c2a11b..5a71e3f4 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs @@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// <summary> /// Arguments FIFO. /// </summary> - public Queue<FifoWord> Fifo { get; } = new Queue<FifoWord>(); + public Queue<FifoWord> Fifo { get; } = new(); /// <summary> /// Fetches a arguments from the arguments FIFO. |
