aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Shader/StructuredIr
diff options
context:
space:
mode:
authorTSRBerry <20988865+TSRBerry@users.noreply.github.com>2023-06-28 08:59:13 +0200
committerGitHub <noreply@github.com>2023-06-28 08:59:13 +0200
commit9becbd7d728fc2002c176dfd9d1d1aae86f86b12 (patch)
tree4aa3e608f438e706856ec8482c5053c13611caa4 /src/Ryujinx.Graphics.Shader/StructuredIr
parente055217292e034e46ebadd2e839b301b996d7064 (diff)
[Ryujinx.Graphics.Shader] Address dotnet-format issues (#5373)1.1.929
* 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
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/StructuredIr')
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/AstAssignment.cs4
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs6
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockType.cs4
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockVisitor.cs2
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/AstComment.cs2
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/AstHelper.cs9
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/AstNode.cs2
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs6
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/AstOperation.cs16
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/AstOptimizer.cs8
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/AstTextureOperation.cs2
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/BufferDefinition.cs2
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/BufferLayout.cs4
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs39
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/GotoStatement.cs8
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/HelperFunctionsMask.cs14
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/IAstNode.cs2
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs6
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/IoDefinition.cs2
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs2
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/OperandInfo.cs4
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/PhiFunctions.cs4
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs2
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/StructureType.cs2
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs2
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs35
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs15
-rw-r--r--src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs2
28 files changed, 109 insertions, 97 deletions
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstAssignment.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstAssignment.cs
index bb3fe7af..efda774c 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstAssignment.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstAssignment.cs
@@ -27,9 +27,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
public AstAssignment(IAstNode destination, IAstNode source)
{
Destination = destination;
- Source = source;
+ Source = source;
AddDef(destination, this);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs
index 2f34bee8..826dbff8 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs
@@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
}
}
- private LinkedList<IAstNode> _nodes;
+ private readonly LinkedList<IAstNode> _nodes;
public IAstNode First => _nodes.First?.Value;
public IAstNode Last => _nodes.Last?.Value;
@@ -38,7 +38,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
public AstBlock(AstBlockType type, IAstNode condition = null)
{
- Type = type;
+ Type = type;
Condition = condition;
_nodes = new LinkedList<IAstNode>();
@@ -114,4 +114,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
return GetEnumerator();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockType.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockType.cs
index c12efda9..a7dcc72a 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockType.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockType.cs
@@ -7,6 +7,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Else,
ElseIf,
Main,
- While
+ While,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockVisitor.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockVisitor.cs
index 10d5dce0..16efeff7 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockVisitor.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockVisitor.cs
@@ -65,4 +65,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstComment.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstComment.cs
index dabe623f..1c82e646 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstComment.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstComment.cs
@@ -9,4 +9,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Comment = comment;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstHelper.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstHelper.cs
index 7aa0409b..06d13c90 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstHelper.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstHelper.cs
@@ -49,9 +49,10 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
public static AstOperand Local(AggregateType type)
{
- AstOperand local = new AstOperand(OperandType.LocalVariable);
-
- local.VarType = type;
+ AstOperand local = new(OperandType.LocalVariable)
+ {
+ VarType = type,
+ };
return local;
}
@@ -71,4 +72,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
return node.LLNode.Previous?.Value;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstNode.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstNode.cs
index c667aac9..0b824617 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstNode.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstNode.cs
@@ -8,4 +8,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
public LinkedListNode<IAstNode> LLNode { get; set; }
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs
index 473aa2e7..b64b96b8 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs
@@ -29,10 +29,10 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Value = operand.Value;
}
- public AstOperand(OperandType type, int value = 0) : this()
+ public AstOperand(OperandType type, int value = 0) : this()
{
- Type = type;
+ Type = type;
Value = value;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperation.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperation.cs
index 4cf729d0..46555a85 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperation.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperation.cs
@@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
public int Index { get; }
- private IAstNode[] _sources;
+ private readonly IAstNode[] _sources;
public int SourcesCount => _sources.Length;
@@ -77,12 +77,18 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
switch (componentsCount)
{
- case 2: type |= AggregateType.Vector2; break;
- case 3: type |= AggregateType.Vector3; break;
- case 4: type |= AggregateType.Vector4; break;
+ case 2:
+ type |= AggregateType.Vector2;
+ break;
+ case 3:
+ type |= AggregateType.Vector3;
+ break;
+ case 4:
+ type |= AggregateType.Vector4;
+ break;
}
return type;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOptimizer.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOptimizer.cs
index b71ae2c4..4fb5d02b 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOptimizer.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOptimizer.cs
@@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
// (this makes comparison with the disassembly easier).
if (!context.Config.Options.Flags.HasFlag(TranslationFlags.DebugMode))
{
- AstBlockVisitor visitor = new AstBlockVisitor(mainBlock);
+ AstBlockVisitor visitor = new(mainBlock);
foreach (IAstNode node in visitor.Visit())
{
@@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
private static bool IsWorthPropagating(IAstNode source)
{
- if (!(source is AstOperation srcOp))
+ if (source is not AstOperation srcOp)
{
return false;
}
@@ -87,7 +87,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
private static void RemoveEmptyBlocks(AstBlock mainBlock)
{
- Queue<AstBlock> pending = new Queue<AstBlock>();
+ Queue<AstBlock> pending = new();
pending.Enqueue(mainBlock);
@@ -152,4 +152,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstTextureOperation.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstTextureOperation.cs
index a4e097eb..4ff2035a 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstTextureOperation.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstTextureOperation.cs
@@ -28,4 +28,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Handle = handle;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/BufferDefinition.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/BufferDefinition.cs
index 5afebc75..e2759480 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/BufferDefinition.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/BufferDefinition.cs
@@ -17,4 +17,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Type = type;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/BufferLayout.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/BufferLayout.cs
index 43a86662..1c25ed34 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/BufferLayout.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/BufferLayout.cs
@@ -3,6 +3,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
enum BufferLayout
{
Std140,
- Std430
+ Std430,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs
index 8bcf9d9c..3ca1266f 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs
@@ -1,7 +1,6 @@
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using System;
using System.Collections.Generic;
-
using static Ryujinx.Graphics.Shader.StructuredIr.AstHelper;
namespace Ryujinx.Graphics.Shader.StructuredIr
@@ -110,16 +109,16 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
if (lLevel > rLevel)
{
- block = lBlock;
+ block = lBlock;
blockLvl = lLevel;
- other = rBlock;
+ other = rBlock;
otherLvl = rLevel;
}
else /* if (rLevel > lLevel) */
{
- block = rBlock;
+ block = rBlock;
blockLvl = rLevel;
- other = lBlock;
+ other = lBlock;
otherLvl = lLevel;
}
@@ -144,7 +143,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
AstBlock[] path = BackwardsPath(block, ParentBlock(stmt.Label));
- AstBlock loopFirstStmt = path[path.Length - 1];
+ AstBlock loopFirstStmt = path[^1];
if (loopFirstStmt.Type == AstBlockType.Else)
{
@@ -194,7 +193,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
loopBlock.AddAfter(child, stmt.Goto);
- block = loopBlock;
+ block = loopBlock;
gLevel = loopLevel;
}
}
@@ -252,7 +251,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
for (int index = path.Length - 1; index >= 0; index--)
{
AstBlock child = path[index];
- AstBlock last = child;
+ AstBlock last = child;
if (child.Type == AstBlockType.If)
{
@@ -265,7 +264,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
else if (child.Type == AstBlockType.Else)
{
// Modify the matching if condition to force the else to be entered by the goto.
- if (!(Previous(child) is AstBlock ifBlock) || ifBlock.Type != AstBlockType.If)
+ if (Previous(child) is not AstBlock ifBlock || ifBlock.Type != AstBlockType.If)
{
throw new InvalidOperationException("Found an else without a matching if.");
}
@@ -332,7 +331,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
AstBlock block = ParentBlock(stmt.Goto);
- AstBlock newBlock = new AstBlock(AstBlockType.If, stmt.Condition);
+ AstBlock newBlock = new(AstBlockType.If, stmt.Condition);
block.AddAfter(stmt.Goto, newBlock);
@@ -340,11 +339,11 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
}
private static AstBlock Enclose(
- AstBlock block,
+ AstBlock block,
AstBlockType type,
- IAstNode cond,
- IAstNode first,
- IAstNode last = null)
+ IAstNode cond,
+ IAstNode first,
+ IAstNode last = null)
{
if (first == last)
{
@@ -367,7 +366,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
return first as AstBlock;
}
- AstBlock newBlock = new AstBlock(type, cond);
+ AstBlock newBlock = new(type, cond);
block.AddBefore(first, newBlock);
@@ -387,7 +386,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
private static bool BlockMatches(IAstNode node, AstBlockType type, IAstNode cond)
{
- if (!(node is AstBlock block))
+ if (node is not AstBlock block)
{
return false;
}
@@ -399,7 +398,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
if (lCond is AstOperation lCondOp && lCondOp.Inst == Instruction.LogicalNot)
{
- if (!(rCond is AstOperation rCondOp) || rCondOp.Inst != lCondOp.Inst)
+ if (rCond is not AstOperation rCondOp || rCondOp.Inst != lCondOp.Inst)
{
return false;
}
@@ -418,7 +417,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
return block.Parent;
}
- while (!(node is AstBlock))
+ while (node is not AstBlock)
{
node = node.Parent;
}
@@ -430,7 +429,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
AstBlock block = bottom;
- List<AstBlock> path = new List<AstBlock>();
+ List<AstBlock> path = new();
while (block != top)
{
@@ -456,4 +455,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
return level;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/GotoStatement.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/GotoStatement.cs
index 25216e55..4607a16c 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/GotoStatement.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/GotoStatement.cs
@@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
class GotoStatement
{
- public AstOperation Goto { get; }
+ public AstOperation Goto { get; }
public AstAssignment Label { get; }
public IAstNode Condition => Label.Destination;
@@ -15,9 +15,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
public GotoStatement(AstOperation branch, AstAssignment label, bool isLoop)
{
- Goto = branch;
- Label = label;
+ Goto = branch;
+ Label = label;
IsLoop = isLoop;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/HelperFunctionsMask.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/HelperFunctionsMask.cs
index ed910f96..73ce9082 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/HelperFunctionsMask.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/HelperFunctionsMask.cs
@@ -7,11 +7,11 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
MultiplyHighS32 = 1 << 2,
MultiplyHighU32 = 1 << 3,
- Shuffle = 1 << 4,
- ShuffleDown = 1 << 5,
- ShuffleUp = 1 << 6,
- ShuffleXor = 1 << 7,
- SwizzleAdd = 1 << 10,
- FSI = 1 << 11
+ Shuffle = 1 << 4,
+ ShuffleDown = 1 << 5,
+ ShuffleUp = 1 << 6,
+ ShuffleXor = 1 << 7,
+ SwizzleAdd = 1 << 10,
+ FSI = 1 << 11,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/IAstNode.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/IAstNode.cs
index 5ececbb5..248d8d69 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/IAstNode.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/IAstNode.cs
@@ -8,4 +8,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
LinkedListNode<IAstNode> LLNode { get; set; }
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs
index b08478ad..6cd0fd08 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs
@@ -19,12 +19,13 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
}
}
- private static InstInfo[] _infoTbl;
+ private static readonly InstInfo[] _infoTbl;
static InstructionInfo()
{
_infoTbl = new InstInfo[(int)Instruction.Count];
+#pragma warning disable IDE0055 // Disable formatting
// Inst Destination type Source 1 type Source 2 type Source 3 type Source 4 type
Add(Instruction.AtomicAdd, AggregateType.U32, AggregateType.S32, AggregateType.S32, AggregateType.U32);
Add(Instruction.AtomicAnd, AggregateType.U32, AggregateType.S32, AggregateType.S32, AggregateType.U32);
@@ -130,6 +131,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Add(Instruction.VoteAll, AggregateType.Bool, AggregateType.Bool);
Add(Instruction.VoteAllEqual, AggregateType.Bool, AggregateType.Bool);
Add(Instruction.VoteAny, AggregateType.Bool, AggregateType.Bool);
+#pragma warning restore IDE0055v
}
private static void Add(Instruction inst, AggregateType destType, params AggregateType[] srcTypes)
@@ -201,4 +203,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
return _infoTbl[(int)(inst & Instruction.Mask)].SrcTypes.Length == 1;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/IoDefinition.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/IoDefinition.cs
index 21a1b3f0..0a0681fa 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/IoDefinition.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/IoDefinition.cs
@@ -41,4 +41,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
return $"{StorageKind}.{IoVariable}.{Location}.{Component}";
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs
index c0bb750e..3ea69fde 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs
@@ -15,4 +15,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
ArrayLength = arrayLength;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/OperandInfo.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/OperandInfo.cs
index 48060f6b..638a5298 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/OperandInfo.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/OperandInfo.cs
@@ -25,8 +25,8 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
OperandType.Argument => AggregateType.S32,
OperandType.Constant => AggregateType.S32,
OperandType.Undefined => AggregateType.S32,
- _ => throw new ArgumentException($"Invalid operand type \"{type}\".")
+ _ => throw new ArgumentException($"Invalid operand type \"{type}\"."),
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/PhiFunctions.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/PhiFunctions.cs
index 541ca298..8b1cb9c5 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/PhiFunctions.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/PhiFunctions.cs
@@ -30,7 +30,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
BasicBlock srcBlock = phi.GetBlock(index);
- Operation copyOp = new Operation(Instruction.Copy, phi.Dest, src);
+ Operation copyOp = new(Instruction.Copy, phi.Dest, src);
srcBlock.Append(copyOp);
}
@@ -42,4 +42,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs
index c6132ef8..1da5cb65 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs
@@ -48,4 +48,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
return id;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructureType.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructureType.cs
index 17f49738..fdf824f5 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructureType.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructureType.cs
@@ -2,7 +2,7 @@ using Ryujinx.Graphics.Shader.Translation;
namespace Ryujinx.Graphics.Shader.StructuredIr
{
- struct StructureField
+ readonly struct StructureField
{
public AggregateType Type { get; }
public string Name { get; }
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs
index 61c4fed7..aa5e1386 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs
@@ -39,4 +39,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
: InArguments[index];
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs
index 9d12a73c..a4e6444b 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs
@@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
public static StructuredProgramInfo MakeStructuredProgram(IReadOnlyList<Function> functions, ShaderConfig config)
{
- StructuredProgramContext context = new StructuredProgramContext(config);
+ StructuredProgramContext context = new(config);
for (int funcIndex = 0; funcIndex < functions.Count; funcIndex++)
{
@@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
AggregateType returnType = function.ReturnsValue ? AggregateType.S32 : AggregateType.Void;
- AggregateType[] inArguments = new AggregateType[function.InArgumentsCount];
+ AggregateType[] inArguments = new AggregateType[function.InArgumentsCount];
AggregateType[] outArguments = new AggregateType[function.OutArgumentsCount];
for (int i = 0; i < inArguments.Length; i++)
@@ -79,7 +79,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
IoVariable ioVariable = (IoVariable)operation.GetSource(0).Value;
bool isOutput = storageKind.IsOutput();
- bool perPatch = storageKind.IsPerPatch();
int location = 0;
int component = 0;
@@ -169,9 +168,15 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
switch (componentsCount)
{
- case 2: destType |= AggregateType.Vector2; break;
- case 3: destType |= AggregateType.Vector3; break;
- case 4: destType |= AggregateType.Vector4; break;
+ case 2:
+ destType |= AggregateType.Vector2;
+ break;
+ case 3:
+ destType |= AggregateType.Vector3;
+ break;
+ case 4:
+ destType |= AggregateType.Vector4;
+ break;
}
AstOperand destVec = context.NewTemp(destType);
@@ -181,7 +186,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
for (int i = 0; i < operation.DestsCount; i++)
{
AstOperand dest = context.GetOperand(operation.GetDest(i));
- AstOperand index = new AstOperand(OperandType.Constant, i);
+ AstOperand index = new(OperandType.Constant, i);
dest.VarType = destElemType;
@@ -202,7 +207,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
}
bool isCondSel = inst == Instruction.ConditionalSelect;
- bool isCopy = inst == Instruction.Copy;
+ bool isCopy = inst == Instruction.Copy;
if (isCondSel || isCopy)
{
@@ -304,9 +309,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
private static AggregateType GetVarTypeFromUses(Operand dest)
{
- HashSet<Operand> visited = new HashSet<Operand>();
+ HashSet<Operand> visited = new();
- Queue<Operand> pending = new Queue<Operand>();
+ Queue<Operand> pending = new();
bool Enqueue(Operand operand)
{
@@ -385,7 +390,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
Instruction.ImageLoad or
Instruction.TextureSample => true,
- _ => false
+ _ => false,
};
}
@@ -396,7 +401,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Instruction.Branch or
Instruction.BranchIfFalse or
Instruction.BranchIfTrue => true,
- _ => false
+ _ => false,
};
}
@@ -408,7 +413,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Instruction.BitwiseExclusiveOr or
Instruction.BitwiseNot or
Instruction.BitwiseOr => true,
- _ => false
+ _ => false,
};
}
@@ -420,8 +425,8 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Instruction.BitwiseExclusiveOr => Instruction.LogicalExclusiveOr,
Instruction.BitwiseNot => Instruction.LogicalNot,
Instruction.BitwiseOr => Instruction.LogicalOr,
- _ => throw new ArgumentException($"Unexpected instruction \"{inst}\".")
+ _ => throw new ArgumentException($"Unexpected instruction \"{inst}\"."),
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs
index a4d07991..019fc332 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs
@@ -3,7 +3,6 @@ using Ryujinx.Graphics.Shader.Translation;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
-
using static Ryujinx.Graphics.Shader.StructuredIr.AstHelper;
namespace Ryujinx.Graphics.Shader.StructuredIr
@@ -165,7 +164,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
// this is not valid as the loop condition would be evaluated,
// and it could erroneously jump back to the start of the loop.
bool inRange =
- block.Branch.Index < _currEndIndex ||
+ block.Branch.Index < _currEndIndex ||
(block.Branch.Index == _currEndIndex && block.Branch.Index < _loopEndIndex);
bool isLoop = block.Branch.Index <= block.Index;
@@ -184,11 +183,11 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
AddNode(Assign(gotoTempAsg.Destination, cond));
- AstOperation branch = new AstOperation(branchOp.Inst);
+ AstOperation branch = new(branchOp.Inst);
AddNode(branch);
- GotoStatement gotoStmt = new GotoStatement(branch, gotoTempAsg, isLoop);
+ GotoStatement gotoStmt = new(branch, gotoTempAsg, isLoop);
_gotos.Add(gotoStmt);
}
@@ -236,13 +235,13 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
private void NewBlock(AstBlockType type, IAstNode cond, int endIndex)
{
- AstBlock childBlock = new AstBlock(type, cond);
+ AstBlock childBlock = new(type, cond);
AddNode(childBlock);
_blockStack.Push((_currBlock, _currEndIndex, _loopEndIndex));
- _currBlock = childBlock;
+ _currBlock = childBlock;
_currEndIndex = endIndex;
if (type == AstBlockType.DoWhile)
@@ -316,7 +315,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
new AstOperand(OperandType.Constant, binding),
new AstOperand(OperandType.Constant, 0),
new AstOperand(OperandType.Constant, vecIndex),
- new AstOperand(OperandType.Constant, elemIndex)
+ new AstOperand(OperandType.Constant, elemIndex),
};
return new AstOperation(Instruction.Load, StorageKind.ConstantBuffer, false, sources, sources.Length);
@@ -349,4 +348,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
return astOperand;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs
index c5104146..4f18c7fd 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs
@@ -33,4 +33,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
IoDefinitions = new HashSet<IoDefinition>();
}
}
-} \ No newline at end of file
+}