From 3b46bb73f781a011705ecbc8a1d3207dfb145829 Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Sun, 2 Jul 2023 02:47:54 +0200 Subject: [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 * 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 --- .../Engine/GPFifo/CompressedMethod.cs | 24 +++--- src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPEntry.cs | 22 +++--- .../Engine/GPFifo/GPFifoClass.cs | 3 +- .../Engine/GPFifo/GPFifoClassState.cs | 92 +++++++++++----------- .../Engine/GPFifo/GPFifoDevice.cs | 12 ++- .../Engine/GPFifo/GPFifoProcessor.cs | 2 +- 6 files changed, 76 insertions(+), 79 deletions(-) (limited to 'src/Ryujinx.Graphics.Gpu/Engine/GPFifo') diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/CompressedMethod.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/CompressedMethod.cs index d082ee9d..afa4db5e 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/CompressedMethod.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/CompressedMethod.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo Grp0SetSubDevMask = 1, Grp0StoreSubDevMask = 2, Grp0UseSubDevMask = 3, - Grp2NonIncMethod = 0 + Grp2NonIncMethod = Grp0IncMethod, } enum SecOp @@ -20,22 +20,22 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo ImmdDataMethod = 4, OneInc = 5, Reserved6 = 6, - EndPbSegment = 7 + EndPbSegment = 7, } struct CompressedMethod { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public uint Method; #pragma warning restore CS0649 - public int MethodAddressOld => (int)((Method >> 2) & 0x7FF); - public int MethodAddress => (int)(Method & 0xFFF); - public int SubdeviceMask => (int)((Method >> 4) & 0xFFF); - public int MethodSubchannel => (int)((Method >> 13) & 0x7); - public TertOp TertOp => (TertOp)((Method >> 16) & 0x3); - public int MethodCountOld => (int)((Method >> 18) & 0x7FF); - public int MethodCount => (int)((Method >> 16) & 0x1FFF); - public int ImmdData => (int)((Method >> 16) & 0x1FFF); - public SecOp SecOp => (SecOp)((Method >> 29) & 0x7); + public readonly int MethodAddressOld => (int)((Method >> 2) & 0x7FF); + public readonly int MethodAddress => (int)(Method & 0xFFF); + public readonly int SubdeviceMask => (int)((Method >> 4) & 0xFFF); + public readonly int MethodSubchannel => (int)((Method >> 13) & 0x7); + public readonly TertOp TertOp => (TertOp)((Method >> 16) & 0x3); + public readonly int MethodCountOld => (int)((Method >> 18) & 0x7FF); + public readonly int MethodCount => (int)((Method >> 16) & 0x1FFF); + public readonly int ImmdData => (int)((Method >> 16) & 0x1FFF); + public readonly SecOp SecOp => (SecOp)((Method >> 29) & 0x7); } } diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPEntry.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPEntry.cs index 31ba3217..81e28acf 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPEntry.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPEntry.cs @@ -36,20 +36,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo struct GPEntry { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public uint Entry0; #pragma warning restore CS0649 - public Entry0Fetch Entry0Fetch => (Entry0Fetch)(Entry0 & 0x1); - public int Entry0Get => (int)((Entry0 >> 2) & 0x3FFFFFFF); - public int Entry0Operand => (int)(Entry0); -#pragma warning disable CS0649 + public readonly Entry0Fetch Entry0Fetch => (Entry0Fetch)(Entry0 & 0x1); + public readonly int Entry0Get => (int)((Entry0 >> 2) & 0x3FFFFFFF); + public readonly int Entry0Operand => (int)(Entry0); +#pragma warning disable CS0649 // Field is never assigned to public uint Entry1; #pragma warning restore CS0649 - public int Entry1GetHi => (int)(Entry1 & 0xFF); - public Entry1Priv Entry1Priv => (Entry1Priv)((Entry1 >> 8) & 0x1); - public Entry1Level Entry1Level => (Entry1Level)((Entry1 >> 9) & 0x1); - public int Entry1Length => (int)((Entry1 >> 10) & 0x1FFFFF); - public Entry1Sync Entry1Sync => (Entry1Sync)((Entry1 >> 31) & 0x1); - public Entry1Opcode Entry1Opcode => (Entry1Opcode)(Entry1 & 0xFF); + public readonly int Entry1GetHi => (int)(Entry1 & 0xFF); + public readonly Entry1Priv Entry1Priv => (Entry1Priv)((Entry1 >> 8) & 0x1); + public readonly Entry1Level Entry1Level => (Entry1Level)((Entry1 >> 9) & 0x1); + public readonly int Entry1Length => (int)((Entry1 >> 10) & 0x1FFFFF); + public readonly Entry1Sync Entry1Sync => (Entry1Sync)((Entry1 >> 31) & 0x1); + public readonly Entry1Opcode Entry1Opcode => (Entry1Opcode)(Entry1 & 0xFF); } } diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClass.cs index 7a11c649..4bdbd1a0 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClass.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClass.cs @@ -16,7 +16,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo private readonly GPFifoProcessor _parent; private readonly DeviceState _state; - private int _previousSubChannel; private bool _createSyncPending; private const int MacrosCount = 0x80; @@ -45,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo { nameof(GPFifoClassState.SetReference), new RwCallback(SetReference, null) }, { nameof(GPFifoClassState.LoadMmeInstructionRam), new RwCallback(LoadMmeInstructionRam, null) }, { nameof(GPFifoClassState.LoadMmeStartAddressRam), new RwCallback(LoadMmeStartAddressRam, null) }, - { nameof(GPFifoClassState.SetMmeShadowRamControl), new RwCallback(SetMmeShadowRamControl, null) } + { nameof(GPFifoClassState.SetMmeShadowRamControl), new RwCallback(SetMmeShadowRamControl, null) }, }); _macros = new Macro[MacrosCount]; diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClassState.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClassState.cs index ebfe1566..dd6ae1b4 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClassState.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClassState.cs @@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo Release = 2, AcqGeq = 4, AcqAnd = 8, - Reduction = 16 + Reduction = 16, } /// @@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo enum SemaphoredAcquireSwitch { Disabled = 0, - Enabled = 1 + Enabled = 1, } /// @@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo enum SemaphoredReleaseWfi { En = 0, - Dis = 1 + Dis = 1, } /// @@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo enum SemaphoredReleaseSize { SixteenBytes = 0, - FourBytes = 1 + FourBytes = 1, } /// @@ -55,7 +55,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo Or = 4, Add = 5, Inc = 6, - Dec = 7 + Dec = 7, } /// @@ -64,7 +64,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo enum SemaphoredFormat { Signed = 0, - Unsigned = 1 + Unsigned = 1, } /// @@ -73,7 +73,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo enum MemOpCTlbInvalidatePdb { One = 0, - All = 1 + All = 1, } /// @@ -82,7 +82,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo enum MemOpCTlbInvalidateGpc { Enable = 0, - Disable = 1 + Disable = 1, } /// @@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo { VidMem = 0, SysMemCoherent = 2, - SysMemNoncoherent = 3 + SysMemNoncoherent = 3, } /// @@ -105,7 +105,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo L2PeermemInvalidate = 13, L2SysmemInvalidate = 14, L2CleanComptags = 15, - L2FlushDirty = 16 + L2FlushDirty = 16, } /// @@ -114,7 +114,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo enum SyncpointbOperation { Wait = 0, - Incr = 1 + Incr = 1, } /// @@ -123,7 +123,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo enum SyncpointbWaitSwitch { Dis = 0, - En = 1 + En = 1, } /// @@ -132,7 +132,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo enum WfiScope { CurrentScgType = 0, - All = 1 + All = 1, } /// @@ -143,7 +143,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo Nop = 0, PbdmaTimeslice = 1, RunlistTimeslice = 2, - Tsg = 3 + Tsg = 3, } /// @@ -151,44 +151,44 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo /// struct GPFifoClassState { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public uint SetObject; - public int SetObjectNvclass => (int)(SetObject & 0xFFFF); - public int SetObjectEngine => (int)((SetObject >> 16) & 0x1F); + public readonly int SetObjectNvclass => (int)(SetObject & 0xFFFF); + public readonly int SetObjectEngine => (int)((SetObject >> 16) & 0x1F); public uint Illegal; - public int IllegalHandle => (int)(Illegal); + public readonly int IllegalHandle => (int)(Illegal); public uint Nop; - public int NopHandle => (int)(Nop); + public readonly int NopHandle => (int)(Nop); public uint Reserved0C; public uint Semaphorea; - public int SemaphoreaOffsetUpper => (int)(Semaphorea & 0xFF); + public readonly int SemaphoreaOffsetUpper => (int)(Semaphorea & 0xFF); public uint Semaphoreb; - public int SemaphorebOffsetLower => (int)((Semaphoreb >> 2) & 0x3FFFFFFF); + public readonly int SemaphorebOffsetLower => (int)((Semaphoreb >> 2) & 0x3FFFFFFF); public uint Semaphorec; - public int SemaphorecPayload => (int)(Semaphorec); + public readonly int SemaphorecPayload => (int)(Semaphorec); public uint Semaphored; - public SemaphoredOperation SemaphoredOperation => (SemaphoredOperation)(Semaphored & 0x1F); - public SemaphoredAcquireSwitch SemaphoredAcquireSwitch => (SemaphoredAcquireSwitch)((Semaphored >> 12) & 0x1); - public SemaphoredReleaseWfi SemaphoredReleaseWfi => (SemaphoredReleaseWfi)((Semaphored >> 20) & 0x1); - public SemaphoredReleaseSize SemaphoredReleaseSize => (SemaphoredReleaseSize)((Semaphored >> 24) & 0x1); - public SemaphoredReduction SemaphoredReduction => (SemaphoredReduction)((Semaphored >> 27) & 0xF); - public SemaphoredFormat SemaphoredFormat => (SemaphoredFormat)((Semaphored >> 31) & 0x1); + public readonly SemaphoredOperation SemaphoredOperation => (SemaphoredOperation)(Semaphored & 0x1F); + public readonly SemaphoredAcquireSwitch SemaphoredAcquireSwitch => (SemaphoredAcquireSwitch)((Semaphored >> 12) & 0x1); + public readonly SemaphoredReleaseWfi SemaphoredReleaseWfi => (SemaphoredReleaseWfi)((Semaphored >> 20) & 0x1); + public readonly SemaphoredReleaseSize SemaphoredReleaseSize => (SemaphoredReleaseSize)((Semaphored >> 24) & 0x1); + public readonly SemaphoredReduction SemaphoredReduction => (SemaphoredReduction)((Semaphored >> 27) & 0xF); + public readonly SemaphoredFormat SemaphoredFormat => (SemaphoredFormat)((Semaphored >> 31) & 0x1); public uint NonStallInterrupt; - public int NonStallInterruptHandle => (int)(NonStallInterrupt); + public readonly int NonStallInterruptHandle => (int)(NonStallInterrupt); public uint FbFlush; - public int FbFlushHandle => (int)(FbFlush); + public readonly int FbFlushHandle => (int)(FbFlush); public uint Reserved28; public uint Reserved2C; public uint MemOpC; - public int MemOpCOperandLow => (int)((MemOpC >> 2) & 0x3FFFFFFF); - public MemOpCTlbInvalidatePdb MemOpCTlbInvalidatePdb => (MemOpCTlbInvalidatePdb)(MemOpC & 0x1); - public MemOpCTlbInvalidateGpc MemOpCTlbInvalidateGpc => (MemOpCTlbInvalidateGpc)((MemOpC >> 1) & 0x1); - public MemOpCTlbInvalidateTarget MemOpCTlbInvalidateTarget => (MemOpCTlbInvalidateTarget)((MemOpC >> 10) & 0x3); - public int MemOpCTlbInvalidateAddrLo => (int)((MemOpC >> 12) & 0xFFFFF); + public readonly int MemOpCOperandLow => (int)((MemOpC >> 2) & 0x3FFFFFFF); + public readonly MemOpCTlbInvalidatePdb MemOpCTlbInvalidatePdb => (MemOpCTlbInvalidatePdb)(MemOpC & 0x1); + public readonly MemOpCTlbInvalidateGpc MemOpCTlbInvalidateGpc => (MemOpCTlbInvalidateGpc)((MemOpC >> 1) & 0x1); + public readonly MemOpCTlbInvalidateTarget MemOpCTlbInvalidateTarget => (MemOpCTlbInvalidateTarget)((MemOpC >> 10) & 0x3); + public readonly int MemOpCTlbInvalidateAddrLo => (int)((MemOpC >> 12) & 0xFFFFF); public uint MemOpD; - public int MemOpDOperandHigh => (int)(MemOpD & 0xFF); - public MemOpDOperation MemOpDOperation => (MemOpDOperation)((MemOpD >> 27) & 0x1F); - public int MemOpDTlbInvalidateAddrHi => (int)(MemOpD & 0xFF); + public readonly int MemOpDOperandHigh => (int)(MemOpD & 0xFF); + public readonly MemOpDOperation MemOpDOperation => (MemOpDOperation)((MemOpD >> 27) & 0x1F); + public readonly int MemOpDTlbInvalidateAddrHi => (int)(MemOpD & 0xFF); public uint Reserved38; public uint Reserved3C; public uint Reserved40; @@ -196,7 +196,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo public uint Reserved48; public uint Reserved4C; public uint SetReference; - public int SetReferenceCount => (int)(SetReference); + public readonly int SetReferenceCount => (int)(SetReference); public uint Reserved54; public uint Reserved58; public uint Reserved5C; @@ -205,17 +205,17 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo public uint Reserved68; public uint Reserved6C; public uint Syncpointa; - public int SyncpointaPayload => (int)(Syncpointa); + public readonly int SyncpointaPayload => (int)(Syncpointa); public uint Syncpointb; - public SyncpointbOperation SyncpointbOperation => (SyncpointbOperation)(Syncpointb & 0x1); - public SyncpointbWaitSwitch SyncpointbWaitSwitch => (SyncpointbWaitSwitch)((Syncpointb >> 4) & 0x1); - public int SyncpointbSyncptIndex => (int)((Syncpointb >> 8) & 0xFFF); + public readonly SyncpointbOperation SyncpointbOperation => (SyncpointbOperation)(Syncpointb & 0x1); + public readonly SyncpointbWaitSwitch SyncpointbWaitSwitch => (SyncpointbWaitSwitch)((Syncpointb >> 4) & 0x1); + public readonly int SyncpointbSyncptIndex => (int)((Syncpointb >> 8) & 0xFFF); public uint Wfi; - public WfiScope WfiScope => (WfiScope)(Wfi & 0x1); + public readonly WfiScope WfiScope => (WfiScope)(Wfi & 0x1); public uint CrcCheck; - public int CrcCheckValue => (int)(CrcCheck); + public readonly int CrcCheckValue => (int)(CrcCheck); public uint Yield; - public YieldOp YieldOp => (YieldOp)(Yield & 0x3); + public readonly YieldOp YieldOp => (YieldOp)(Yield & 0x3); // TODO: Eventually move this to per-engine state. public Array31 Reserved84; public uint NoOperation; diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs index 09bcdec1..bb5bc21c 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs @@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo private enum CommandBufferType { Prefetch, - NoPrefetch + NoPrefetch, } /// @@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo /// The memory manager used to fetch the data /// If true, flushes potential GPU written data before reading the command buffer /// The fetched data - private ReadOnlySpan GetWords(MemoryManager memoryManager, bool flush) + private readonly ReadOnlySpan GetWords(MemoryManager memoryManager, bool flush) { return MemoryMarshal.Cast(memoryManager.GetSpan(EntryAddress, (int)EntryCount * 4, flush)); } @@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo /// The memory manager used to fetch the data /// If true, flushes potential GPU written data before reading the command buffer /// The command buffer words - public ReadOnlySpan Fetch(MemoryManager memoryManager, bool flush) + public readonly ReadOnlySpan Fetch(MemoryManager memoryManager, bool flush) { return Words ?? GetWords(memoryManager, flush); } @@ -85,7 +85,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo private readonly ConcurrentQueue _commandBufferQueue; - private CommandBuffer _currentCommandBuffer; private GPFifoProcessor _prevChannelProcessor; private readonly bool _ibEnable; @@ -129,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo Type = CommandBufferType.Prefetch, Words = commandBuffer, EntryAddress = ulong.MaxValue, - EntryCount = (uint)commandBuffer.Length + EntryCount = (uint)commandBuffer.Length, }); } @@ -156,7 +155,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo Type = type, Words = null, EntryAddress = startAddress, - EntryCount = (uint)entry.Entry1Length + EntryCount = (uint)entry.Entry1Length, }; } @@ -217,7 +216,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo flushCommandBuffer = false; } - _currentCommandBuffer = entry; ReadOnlySpan words = entry.Fetch(entry.Processor.MemoryManager, flushCommandBuffer); // If we are changing the current channel, diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs index 3fb3feee..6ba1bc22 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs @@ -243,7 +243,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo { 0 => _3dClass, 3 => _2dClass, - _ => null + _ => null, }; if (state != null) -- cgit v1.2.3