From 9becbd7d728fc2002c176dfd9d1d1aae86f86b12 Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Wed, 28 Jun 2023 08:59:13 +0200 Subject: [Ryujinx.Graphics.Shader] Address dotnet-format issues (#5373) * dotnet format style --severity info Some changes were manually reverted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0052 warnings * Silence dotnet format IDE0059 warnings * Address or silence dotnet format CA1069 warnings * Address or silence dotnet format CA2211 warnings * Address review comments * Fix formatting for switch expressions * 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 * Run dotnet format whitespace after rebase * 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 * Fix naming rule violation, Convert shader properties to auto-property and convert values to const * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Run dotnet format after rebase * Address IDE0251 warnings * Address a few disabled IDE0060 warnings * Silence IDE0060 in .editorconfig * Run dotnet format after rebase * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Fix naming rule violations * Add trailing commas * Remove unused members and most unnecessary value assignments * Remove more unnecessary assignments * Remove NRE suppressor --- src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs | 73 ++++++++++++------------- 1 file changed, 36 insertions(+), 37 deletions(-) (limited to 'src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs') diff --git a/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs b/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs index 4e6c6a5d..ba31c020 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; - using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; namespace Ryujinx.Graphics.Shader.Decoders @@ -12,8 +11,8 @@ namespace Ryujinx.Graphics.Shader.Decoders { public static DecodedProgram Decode(ShaderConfig config, ulong startAddress) { - Queue functionsQueue = new Queue(); - Dictionary functionsVisited = new Dictionary(); + Queue functionsQueue = new(); + Dictionary functionsVisited = new(); DecodedFunction EnqueueFunction(ulong address) { @@ -30,9 +29,9 @@ namespace Ryujinx.Graphics.Shader.Decoders while (functionsQueue.TryDequeue(out DecodedFunction currentFunction)) { - List blocks = new List(); - Queue workQueue = new Queue(); - Dictionary visited = new Dictionary(); + List blocks = new(); + Queue workQueue = new(); + Dictionary visited = new(); Block GetBlock(ulong blkAddress) { @@ -168,7 +167,7 @@ namespace Ryujinx.Graphics.Shader.Decoders { index = 0; - int left = 0; + int left = 0; int right = blocks.Count - 1; while (left <= right) @@ -273,12 +272,12 @@ namespace Ryujinx.Graphics.Shader.Decoders int offset; int count = 1; bool isStore = false; - bool indexed = false; + bool indexed; bool perPatch = false; if (name == InstName.Ast) { - InstAst opAst = new InstAst(opCode); + InstAst opAst = new(opCode); count = (int)opAst.AlSize + 1; offset = opAst.Imm11; indexed = opAst.Phys; @@ -287,7 +286,7 @@ namespace Ryujinx.Graphics.Shader.Decoders } else if (name == InstName.Ald) { - InstAld opAld = new InstAld(opCode); + InstAld opAld = new(opCode); count = (int)opAld.AlSize + 1; offset = opAld.Imm11; indexed = opAld.Phys; @@ -296,7 +295,7 @@ namespace Ryujinx.Graphics.Shader.Decoders } else /* if (name == InstName.Ipa) */ { - InstIpa opIpa = new InstIpa(opCode); + InstIpa opIpa = new(opCode); offset = opIpa.Imm10; indexed = opIpa.Idx; } @@ -370,7 +369,7 @@ namespace Ryujinx.Graphics.Shader.Decoders private static bool IsUnconditional(ref InstOp op) { - InstConditional condOp = new InstConditional(op.RawOpCode); + InstConditional condOp = new(op.RawOpCode); if ((op.Name == InstName.Bra || op.Name == InstName.Exit) && condOp.Ccc != Ccc.T) { @@ -391,9 +390,9 @@ namespace Ryujinx.Graphics.Shader.Decoders if (lastOp.Name == InstName.Brx && block.Successors.Count == (hasNext ? 1 : 0)) { - HashSet visited = new HashSet(); + HashSet visited = new(); - InstBrx opBrx = new InstBrx(lastOp.RawOpCode); + InstBrx opBrx = new(lastOp.RawOpCode); ulong baseOffset = lastOp.GetAbsoluteAddress(); // An indirect branch could go anywhere, @@ -437,7 +436,7 @@ namespace Ryujinx.Graphics.Shader.Decoders // On a successful match, "BaseOffset" is the offset in bytes where the jump offsets are // located on the constant buffer, and "UpperBound" is the total number of offsets for the BRX, minus 1. - HashSet visited = new HashSet(); + HashSet visited = new(); var ldcLocation = FindFirstRegWrite(visited, new BlockLocation(block, block.OpCodes.Count - 1), brxReg); if (ldcLocation.Block == null || ldcLocation.Block.OpCodes[ldcLocation.Index].Name != InstName.Ldc) @@ -507,7 +506,7 @@ namespace Ryujinx.Graphics.Shader.Decoders private static BlockLocation FindFirstRegWrite(HashSet visited, BlockLocation location, int regIndex) { - Queue toVisit = new Queue(); + Queue toVisit = new(); toVisit.Enqueue(location); visited.Add(location.Block); @@ -554,10 +553,10 @@ namespace Ryujinx.Graphics.Shader.Decoders { Brk, Cont, - Sync + Sync, } - private struct PathBlockState + private readonly struct PathBlockState { public Block Block { get; } @@ -565,37 +564,37 @@ namespace Ryujinx.Graphics.Shader.Decoders { None, PopPushOp, - PushBranchOp + PushBranchOp, } - private RestoreType _restoreType; + private readonly RestoreType _restoreType; - private ulong _restoreValue; - private MergeType _restoreMergeType; + private readonly ulong _restoreValue; + private readonly MergeType _restoreMergeType; public bool ReturningFromVisit => _restoreType != RestoreType.None; public PathBlockState(Block block) { - Block = block; - _restoreType = RestoreType.None; - _restoreValue = 0; + Block = block; + _restoreType = RestoreType.None; + _restoreValue = 0; _restoreMergeType = default; } public PathBlockState(int oldStackSize) { - Block = null; - _restoreType = RestoreType.PopPushOp; - _restoreValue = (ulong)oldStackSize; + Block = null; + _restoreType = RestoreType.PopPushOp; + _restoreValue = (ulong)oldStackSize; _restoreMergeType = default; } public PathBlockState(ulong syncAddress, MergeType mergeType) { - Block = null; - _restoreType = RestoreType.PushBranchOp; - _restoreValue = syncAddress; + Block = null; + _restoreType = RestoreType.PushBranchOp; + _restoreValue = syncAddress; _restoreMergeType = mergeType; } @@ -622,9 +621,9 @@ namespace Ryujinx.Graphics.Shader.Decoders Block target = blocks[pushOp.GetAbsoluteAddress()]; - Stack workQueue = new Stack(); - HashSet visited = new HashSet(); - Stack<(ulong, MergeType)> branchStack = new Stack<(ulong, MergeType)>(); + Stack workQueue = new(); + HashSet visited = new(); + Stack<(ulong, MergeType)> branchStack = new(); void Push(PathBlockState pbs) { @@ -759,7 +758,7 @@ namespace Ryujinx.Graphics.Shader.Decoders { InstName.Pbk => MergeType.Brk, InstName.Pcnt => MergeType.Cont, - _ => MergeType.Sync + _ => MergeType.Sync, }; } @@ -769,8 +768,8 @@ namespace Ryujinx.Graphics.Shader.Decoders { InstName.Brk => MergeType.Brk, InstName.Cont => MergeType.Cont, - _ => MergeType.Sync + _ => MergeType.Sync, }; } } -} \ No newline at end of file +} -- cgit v1.2.3