Просмотр исходного кода

misc: chore: Use collection expressions in Shader project

Evan Husted 1 год назад
Родитель
Сommit
95f9e548ca
38 измененных файлов с 198 добавлено и 204 удалено
  1. 2 2
      src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs
  2. 1 1
      src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs
  3. 10 10
      src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs
  4. 4 4
      src/Ryujinx.Graphics.Shader/Decoders/Block.cs
  5. 1 1
      src/Ryujinx.Graphics.Shader/Decoders/DecodedFunction.cs
  6. 1 1
      src/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs
  7. 4 4
      src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs
  8. 24 24
      src/Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs
  9. 4 4
      src/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs
  10. 10 10
      src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs
  11. 3 3
      src/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs
  12. 1 1
      src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operand.cs
  13. 8 8
      src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operation.cs
  14. 2 2
      src/Ryujinx.Graphics.Shader/IntermediateRepresentation/PhiNode.cs
  15. 1 1
      src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs
  16. 2 2
      src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs
  17. 1 1
      src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs
  18. 1 1
      src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs
  19. 3 2
      src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs
  20. 6 6
      src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs
  21. 2 2
      src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs
  22. 3 4
      src/Ryujinx.Graphics.Shader/SupportBuffer.cs
  23. 2 2
      src/Ryujinx.Graphics.Shader/Translation/AttributeUsage.cs
  24. 2 2
      src/Ryujinx.Graphics.Shader/Translation/ControlFlowGraph.cs
  25. 6 6
      src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs
  26. 4 4
      src/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs
  27. 23 23
      src/Ryujinx.Graphics.Shader/Translation/FunctionMatch.cs
  28. 2 2
      src/Ryujinx.Graphics.Shader/Translation/Optimizations/DoubleToFloat.cs
  29. 10 10
      src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs
  30. 2 2
      src/Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs
  31. 13 15
      src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs
  32. 1 1
      src/Ryujinx.Graphics.Shader/Translation/Transforms/SharedAtomicSignedCas.cs
  33. 1 1
      src/Ryujinx.Graphics.Shader/Translation/Transforms/SharedStoreSmallIntCas.cs
  34. 1 1
      src/Ryujinx.Graphics.Shader/Translation/Transforms/ShufflePass.cs
  35. 17 16
      src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs
  36. 7 7
      src/Ryujinx.Graphics.Shader/Translation/Transforms/VertexToCompute.cs
  37. 10 14
      src/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs
  38. 3 4
      src/Ryujinx.Graphics.Shader/VertexInfoBuffer.cs

+ 2 - 2
src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs

@@ -50,7 +50,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
         private class BlockState
         {
             private int _entryCount;
-            private readonly List<Instruction> _labels = new();
+            private readonly List<Instruction> _labels = [];
 
             public Instruction GetNextLabel(CodeGenContext context)
             {
@@ -147,7 +147,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
 
         public Instruction[] GetMainInterface()
         {
-            List<Instruction> mainInterface = new();
+            List<Instruction> mainInterface = [];
 
             mainInterface.AddRange(Inputs.Values);
             mainInterface.AddRange(Outputs.Values);

+ 1 - 1
src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs

@@ -81,7 +81,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
 
         private static void DeclareBuffers(CodeGenContext context, IEnumerable<BufferDefinition> buffers, bool isBuffer)
         {
-            HashSet<SpvInstruction> decoratedTypes = new();
+            HashSet<SpvInstruction> decoratedTypes = [];
 
             foreach (BufferDefinition buffer in buffers)
             {

+ 10 - 10
src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs

@@ -1242,11 +1242,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
 
             if (hasDerivatives)
             {
-                derivatives = new[]
-                {
+                derivatives =
+                [
                     AssembleDerivativesVector(coordsCount), // dPdx
-                    AssembleDerivativesVector(coordsCount), // dPdy
-                };
+                    AssembleDerivativesVector(coordsCount) // dPdy
+                ];
             }
 
             SpvInstruction sample = null;
@@ -1286,17 +1286,17 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
 
             if (hasOffset)
             {
-                offsets = new[] { AssembleOffsetVector(coordsCount) };
+                offsets = [AssembleOffsetVector(coordsCount)];
             }
             else if (hasOffsets)
             {
-                offsets = new[]
-                {
-                    AssembleOffsetVector(coordsCount),
+                offsets =
+                [
                     AssembleOffsetVector(coordsCount),
                     AssembleOffsetVector(coordsCount),
                     AssembleOffsetVector(coordsCount),
-                };
+                    AssembleOffsetVector(coordsCount)
+                ];
             }
 
             SpvInstruction lodBias = null;
@@ -1327,7 +1327,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
                 compIdx = Src(AggregateType.S32);
             }
 
-            List<SpvInstruction> operandsList = new();
+            List<SpvInstruction> operandsList = [];
             ImageOperandsMask operandsMask = ImageOperandsMask.MaskNone;
 
             if (hasLodBias)

+ 4 - 4
src/Ryujinx.Graphics.Shader/Decoders/Block.cs

@@ -45,11 +45,11 @@ namespace Ryujinx.Graphics.Shader.Decoders
         {
             Address = address;
 
-            Predecessors = new List<Block>();
-            Successors = new List<Block>();
+            Predecessors = [];
+            Successors = [];
 
-            OpCodes = new List<InstOp>();
-            PushOpCodes = new List<PushOpInfo>();
+            OpCodes = [];
+            PushOpCodes = [];
             SyncTargets = new Dictionary<ulong, SyncTarget>();
         }
 

+ 1 - 1
src/Ryujinx.Graphics.Shader/Decoders/DecodedFunction.cs

@@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
         public DecodedFunction(ulong address)
         {
             Address = address;
-            _callers = new HashSet<DecodedFunction>();
+            _callers = [];
             Type = FunctionType.User;
             Id = -1;
         }

+ 1 - 1
src/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs

@@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
         {
             MainFunction = mainFunction;
             _functions = functions;
-            _functionsWithId = new();
+            _functionsWithId = [];
             AttributeUsage = attributeUsage;
             UsedFeatures = usedFeatures;
             ClipDistancesWritten = clipDistancesWritten;

+ 4 - 4
src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs

@@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
 
             while (functionsQueue.TryDequeue(out DecodedFunction currentFunction))
             {
-                List<Block> blocks = new();
+                List<Block> blocks = [];
                 Queue<Block> workQueue = new();
                 Dictionary<ulong, Block> visited = new();
 
@@ -520,7 +520,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
 
                 if (lastOp.Name == InstName.Brx && block.Successors.Count == (hasNext ? 1 : 0))
                 {
-                    HashSet<ulong> visited = new();
+                    HashSet<ulong> visited = [];
 
                     InstBrx opBrx = new(lastOp.RawOpCode);
                     ulong baseOffset = lastOp.GetAbsoluteAddress();
@@ -566,7 +566,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<Block> visited = new();
+            HashSet<Block> visited = [];
 
             BlockLocation ldcLocation = FindFirstRegWrite(visited, new BlockLocation(block, block.OpCodes.Count - 1), brxReg);
             if (ldcLocation.Block == null || ldcLocation.Block.OpCodes[ldcLocation.Index].Name != InstName.Ldc)
@@ -752,7 +752,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
             Block target = blocks[pushOp.GetAbsoluteAddress()];
 
             Stack<PathBlockState> workQueue = new();
-            HashSet<Block> visited = new();
+            HashSet<Block> visited = [];
             Stack<(ulong, MergeType)> branchStack = new();
 
             void Push(PathBlockState pbs)

+ 24 - 24
src/Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs

@@ -107,11 +107,11 @@ namespace Ryujinx.Graphics.Shader.Instructions
             ushort low = (ushort)(immH0 << 6);
             ushort high = (ushort)(immH1 << 6);
 
-            return new Operand[]
-            {
+            return
+            [
                 ConstF((float)Unsafe.As<ushort, Half>(ref low)),
-                ConstF((float)Unsafe.As<ushort, Half>(ref high)),
-            };
+                ConstF((float)Unsafe.As<ushort, Half>(ref high))
+            ];
         }
 
         public static Operand[] GetHalfSrc(EmitterContext context, int imm32)
@@ -119,11 +119,11 @@ namespace Ryujinx.Graphics.Shader.Instructions
             ushort low = (ushort)imm32;
             ushort high = (ushort)(imm32 >> 16);
 
-            return new Operand[]
-            {
+            return
+            [
                 ConstF((float)Unsafe.As<ushort, Half>(ref low)),
-                ConstF((float)Unsafe.As<ushort, Half>(ref high)),
-            };
+                ConstF((float)Unsafe.As<ushort, Half>(ref high))
+            ];
         }
 
         public static Operand[] FPAbsNeg(EmitterContext context, Operand[] operands, bool abs, bool neg)
@@ -140,22 +140,22 @@ namespace Ryujinx.Graphics.Shader.Instructions
         {
             return swizzle switch
             {
-                HalfSwizzle.F16 => new Operand[]
-                                    {
-                        context.UnpackHalf2x16Low (src),
-                        context.UnpackHalf2x16High(src),
-                                    },
-                HalfSwizzle.F32 => new Operand[] { src, src },
-                HalfSwizzle.H0H0 => new Operand[]
-                    {
-                        context.UnpackHalf2x16Low(src),
-                        context.UnpackHalf2x16Low(src),
-                    },
-                HalfSwizzle.H1H1 => new Operand[]
-                    {
-                        context.UnpackHalf2x16High(src),
-                        context.UnpackHalf2x16High(src),
-                    },
+                HalfSwizzle.F16 =>
+                [
+                    context.UnpackHalf2x16Low (src),
+                        context.UnpackHalf2x16High(src)
+                ],
+                HalfSwizzle.F32 => [src, src],
+                HalfSwizzle.H0H0 =>
+                [
+                    context.UnpackHalf2x16Low(src),
+                        context.UnpackHalf2x16Low(src)
+                ],
+                HalfSwizzle.H1H1 =>
+                [
+                    context.UnpackHalf2x16High(src),
+                        context.UnpackHalf2x16High(src)
+                ],
                 _ => throw new ArgumentException($"Invalid swizzle \"{swizzle}\"."),
             };
         }

+ 4 - 4
src/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs

@@ -221,7 +221,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
 
             Operand d = Register(dest, RegisterType.Gpr);
 
-            List<Operand> sourcesList = new();
+            List<Operand> sourcesList = [];
 
             if (isBindless)
             {
@@ -328,7 +328,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
                 return context.Copy(Register(srcA++, RegisterType.Gpr));
             }
 
-            List<Operand> sourcesList = new();
+            List<Operand> sourcesList = [];
 
             if (isBindless)
             {
@@ -500,7 +500,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
                 return context.Copy(Register(srcB++, RegisterType.Gpr));
             }
 
-            List<Operand> sourcesList = new();
+            List<Operand> sourcesList = [];
 
             if (isBindless)
             {
@@ -605,7 +605,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
                 return context.Copy(Register(srcB++, RegisterType.Gpr));
             }
 
-            List<Operand> sourcesList = new();
+            List<Operand> sourcesList = [];
 
             if (isBindless)
             {

+ 10 - 10
src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs

@@ -12,8 +12,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
     {
         private static readonly int[][] _maskLut = new int[][]
         {
-            new int[] { 0b0001, 0b0010, 0b0100, 0b1000, 0b0011, 0b1001, 0b1010, 0b1100 },
-            new int[] { 0b0111, 0b1011, 0b1101, 0b1110, 0b1111, 0b0000, 0b0000, 0b0000 },
+            [0b0001, 0b0010, 0b0100, 0b1000, 0b0011, 0b1001, 0b1010, 0b1100], [0b0111, 0b1011, 0b1101, 0b1110, 0b1111, 0b0000, 0b0000, 0b0000
+            ],
         };
 
         public const bool Sample1DAs2D = true;
@@ -202,7 +202,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
 
             Operand arrayIndex = isArray ? Ra() : null;
 
-            List<Operand> sourcesList = new();
+            List<Operand> sourcesList = [];
 
             if (isBindless)
             {
@@ -339,7 +339,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
                 return;
             }
 
-            List<Operand> sourcesList = new();
+            List<Operand> sourcesList = [];
 
             Operand Ra()
             {
@@ -605,8 +605,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
 
             Operand[] sources = sourcesList.ToArray();
 
-            Operand[] rd0 = new Operand[2] { ConstF(0), ConstF(0) };
-            Operand[] rd1 = new Operand[2] { ConstF(0), ConstF(0) };
+            Operand[] rd0 = [ConstF(0), ConstF(0)];
+            Operand[] rd1 = [ConstF(0), ConstF(0)];
 
             int handle = imm;
             int componentMask = _maskLut[dest2 == RegisterConsts.RegisterZeroIndex ? 0 : 1][writeMask];
@@ -701,7 +701,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
 
             Operand arrayIndex = isArray ? Ra() : null;
 
-            List<Operand> sourcesList = new();
+            List<Operand> sourcesList = [];
 
             SamplerType type = ConvertSamplerType(dimensions);
             TextureFlags flags = TextureFlags.Gather;
@@ -835,7 +835,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
 
             TextureFlags flags = TextureFlags.None;
 
-            List<Operand> sourcesList = new();
+            List<Operand> sourcesList = [];
 
             if (isBindless)
             {
@@ -963,7 +963,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
 
             TextureFlags flags = TextureFlags.Derivatives;
 
-            List<Operand> sourcesList = new();
+            List<Operand> sourcesList = [];
 
             if (isBindless)
             {
@@ -1076,7 +1076,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
                 return context.Copy(Register(srcA++, RegisterType.Gpr));
             }
 
-            List<Operand> sourcesList = new();
+            List<Operand> sourcesList = [];
 
             if (isBindless)
             {

+ 3 - 3
src/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs

@@ -34,11 +34,11 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
 
         public BasicBlock()
         {
-            Operations = new LinkedList<INode>();
+            Operations = [];
 
-            Predecessors = new List<BasicBlock>();
+            Predecessors = [];
 
-            DominanceFrontiers = new HashSet<BasicBlock>();
+            DominanceFrontiers = [];
         }
 
         public BasicBlock(int index) : this()

+ 1 - 1
src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operand.cs

@@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
 
         private Operand()
         {
-            UseOps = new HashSet<INode>();
+            UseOps = [];
         }
 
         public Operand(OperandType type) : this()

+ 8 - 8
src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operation.cs

@@ -27,11 +27,11 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
                         value.AsgOp = this;
                     }
 
-                    _dests = new[] { value };
+                    _dests = [value];
                 }
                 else
                 {
-                    _dests = Array.Empty<Operand>();
+                    _dests = [];
                 }
             }
         }
@@ -82,7 +82,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
             }
             else
             {
-                _dests = Array.Empty<Operand>();
+                _dests = [];
             }
         }
 
@@ -94,11 +94,11 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
             {
                 dest.AsgOp = this;
 
-                _dests = new[] { dest };
+                _dests = [dest];
             }
             else
             {
-                _dests = Array.Empty<Operand>();
+                _dests = [];
             }
         }
 
@@ -111,11 +111,11 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
             {
                 dest.AsgOp = this;
 
-                _dests = new[] { dest };
+                _dests = [dest];
             }
             else
             {
-                _dests = Array.Empty<Operand>();
+                _dests = [];
             }
         }
 
@@ -258,7 +258,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
                 source.UseOps.Add(this);
             }
 
-            _sources = new Operand[] { source };
+            _sources = [source];
         }
 
         public void TurnDoubleIntoFloat()

+ 2 - 2
src/Ryujinx.Graphics.Shader/IntermediateRepresentation/PhiNode.cs

@@ -35,9 +35,9 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
 
         public PhiNode(Operand dest)
         {
-            _blocks = new HashSet<BasicBlock>();
+            _blocks = [];
 
-            _sources = new List<PhiSource>();
+            _sources = [];
 
             dest.AsgOp = this;
 

+ 1 - 1
src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs

@@ -41,7 +41,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
             Type = type;
             Condition = condition;
 
-            _nodes = new LinkedList<IAstNode>();
+            _nodes = [];
         }
 
         public void Add(IAstNode node)

+ 2 - 2
src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs

@@ -17,8 +17,8 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
 
         private AstOperand()
         {
-            Defs = new HashSet<IAstNode>();
-            Uses = new HashSet<IAstNode>();
+            Defs = [];
+            Uses = [];
 
             VarType = AggregateType.S32;
         }

+ 1 - 1
src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs

@@ -429,7 +429,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
         {
             AstBlock block = bottom;
 
-            List<AstBlock> path = new();
+            List<AstBlock> path = [];
 
             while (block != top)
             {

+ 1 - 1
src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs

@@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
             InArguments = inArguments;
             OutArguments = outArguments;
 
-            Locals = new HashSet<AstOperand>();
+            Locals = [];
         }
 
         public AggregateType GetArgumentType(int index)

+ 3 - 2
src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs

@@ -237,7 +237,8 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
 
                     dest.VarType = destElemType;
 
-                    context.AddNode(new AstAssignment(dest, new AstOperation(Instruction.VectorExtract, StorageKind.None, false, new[] { destVec, index }, 2)));
+                    context.AddNode(new AstAssignment(dest, new AstOperation(Instruction.VectorExtract, StorageKind.None, false,
+                        [destVec, index], 2)));
                 }
             }
             else if (operation.Dest != null)
@@ -354,7 +355,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
 
         private static AggregateType GetVarTypeFromUses(Operand dest)
         {
-            HashSet<Operand> visited = new();
+            HashSet<Operand> visited = [];
 
             Queue<Operand> pending = new();
 

+ 6 - 6
src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs

@@ -70,7 +70,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
             AggregateType[] inArguments,
             AggregateType[] outArguments)
         {
-            _loopTails = new HashSet<BasicBlock>();
+            _loopTails = [];
 
             _blockStack = new Stack<(AstBlock, int, int)>();
 
@@ -78,7 +78,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
 
             _gotoTempAsgs = new Dictionary<int, AstAssignment>();
 
-            _gotos = new List<GotoStatement>();
+            _gotos = [];
 
             _currBlock = new AstBlock(AstBlockType.Main);
 
@@ -314,13 +314,13 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
 
                 ResourceManager.SetUsedConstantBufferBinding(binding);
 
-                IAstNode[] sources = new IAstNode[]
-                {
+                IAstNode[] sources =
+                [
                     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);
             }

+ 2 - 2
src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs

@@ -12,9 +12,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
 
         public StructuredProgramInfo(bool precise)
         {
-            Functions = new List<StructuredFunction>();
+            Functions = [];
 
-            IoDefinitions = new HashSet<IoDefinition>();
+            IoDefinitions = [];
 
             if (precise)
             {

+ 3 - 4
src/Ryujinx.Graphics.Shader/SupportBuffer.cs

@@ -72,8 +72,7 @@ namespace Ryujinx.Graphics.Shader
 
         internal static StructureType GetStructureType()
         {
-            return new StructureType(new[]
-            {
+            return new StructureType([
                 new StructureField(AggregateType.U32, "alpha_test"),
                 new StructureField(AggregateType.Array | AggregateType.U32, "is_bgra", FragmentIsBgraCount),
                 new StructureField(AggregateType.Vector4 | AggregateType.FP32, "viewport_inverse"),
@@ -81,8 +80,8 @@ namespace Ryujinx.Graphics.Shader
                 new StructureField(AggregateType.S32, "frag_scale_count"),
                 new StructureField(AggregateType.Array | AggregateType.FP32, "render_scale", RenderScaleMaxCount),
                 new StructureField(AggregateType.Vector4 | AggregateType.S32, "tfe_offset"),
-                new StructureField(AggregateType.S32, "tfe_vertex_count"),
-            });
+                new StructureField(AggregateType.S32, "tfe_vertex_count")
+            ]);
         }
 
         public Vector4<int> FragmentAlphaTest;

+ 2 - 2
src/Ryujinx.Graphics.Shader/Translation/AttributeUsage.cs

@@ -25,8 +25,8 @@ namespace Ryujinx.Graphics.Shader.Translation
         {
             _gpuAccessor = gpuAccessor;
 
-            UsedInputAttributesPerPatch = new();
-            UsedOutputAttributesPerPatch = new();
+            UsedInputAttributesPerPatch = [];
+            UsedOutputAttributesPerPatch = [];
         }
 
         public void SetInputUserAttribute(int index, int component)

+ 2 - 2
src/Ryujinx.Graphics.Shader/Translation/ControlFlowGraph.cs

@@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Shader.Translation
         {
             Blocks = blocks;
 
-            HashSet<BasicBlock> visited = new();
+            HashSet<BasicBlock> visited = [];
 
             Stack<BasicBlock> blockStack = new();
 
@@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.Shader.Translation
         {
             Dictionary<Operand, BasicBlock> labels = new();
 
-            List<BasicBlock> blocks = new();
+            List<BasicBlock> blocks = [];
 
             BasicBlock currentBlock = null;
 

+ 6 - 6
src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs

@@ -54,7 +54,7 @@ namespace Ryujinx.Graphics.Shader.Translation
 
         public EmitterContext()
         {
-            _operations = new List<Operation>();
+            _operations = [];
             _labels = new Dictionary<ulong, BlockLabel>();
         }
 
@@ -127,8 +127,8 @@ namespace Ryujinx.Graphics.Shader.Translation
                         TextureFlags.IntCoords,
                         ResourceManager.Reservations.GetIndexBufferTextureSetAndBinding(),
                         1,
-                        new[] { vertexIndexVr },
-                        new[] { this.IAdd(ibBaseOffset, outputVertexOffset) });
+                        [vertexIndexVr],
+                        [this.IAdd(ibBaseOffset, outputVertexOffset)]);
 
                     this.Store(StorageKind.LocalMemory, ResourceManager.LocalVertexIndexVertexRateMemoryId, this.IAdd(firstVertex, vertexIndexVr));
                     this.Store(StorageKind.LocalMemory, ResourceManager.LocalVertexIndexInstanceRateMemoryId, this.IAdd(firstInstance, outputInstanceOffset));
@@ -148,8 +148,8 @@ namespace Ryujinx.Graphics.Shader.Translation
                             TextureFlags.IntCoords,
                             ResourceManager.Reservations.GetTopologyRemapBufferTextureSetAndBinding(),
                             1,
-                            new[] { vertexIndex },
-                            new[] { this.IAdd(baseVertex, Const(index)) });
+                            [vertexIndex],
+                            [this.IAdd(baseVertex, Const(index))]);
 
                         this.Store(StorageKind.LocalMemory, ResourceManager.LocalTopologyRemapMemoryId, Const(index), vertexIndex);
                     }
@@ -187,7 +187,7 @@ namespace Ryujinx.Graphics.Shader.Translation
 
         public (Operand, Operand) Add(Instruction inst, (Operand, Operand) dest, params Operand[] sources)
         {
-            Operand[] dests = new[] { dest.Item1, dest.Item2 };
+            Operand[] dests = [dest.Item1, dest.Item2];
 
             Operation operation = new(inst, 0, dests, sources);
 

+ 4 - 4
src/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs

@@ -631,7 +631,7 @@ namespace Ryujinx.Graphics.Shader.Translation
                 setAndBinding.SetIndex,
                 setAndBinding.Binding,
                 0,
-                new[] { dest },
+                [dest],
                 sources));
 
             return dest;
@@ -759,7 +759,7 @@ namespace Ryujinx.Graphics.Shader.Translation
                 setAndBinding.SetIndex,
                 setAndBinding.Binding,
                 compIndex,
-                new[] { dest },
+                [dest],
                 sources));
 
             return dest;
@@ -959,7 +959,7 @@ namespace Ryujinx.Graphics.Shader.Translation
                 setAndBinding.SetIndex,
                 setAndBinding.Binding,
                 0,
-                new[] { dest },
+                [dest],
                 sources));
 
             return dest;
@@ -983,7 +983,7 @@ namespace Ryujinx.Graphics.Shader.Translation
                 setAndBinding.SetIndex,
                 setAndBinding.Binding,
                 compIndex,
-                new[] { dest },
+                [dest],
                 sources));
 
             return dest;

+ 23 - 23
src/Ryujinx.Graphics.Shader/Translation/FunctionMatch.cs

@@ -132,7 +132,7 @@ namespace Ryujinx.Graphics.Shader.Translation
             public TreeNode(InstOp op, byte order)
             {
                 Op = op;
-                Uses = new List<TreeNodeUse>();
+                Uses = [];
                 Type = TreeNodeType.Op;
                 Order = order;
             }
@@ -150,7 +150,7 @@ namespace Ryujinx.Graphics.Shader.Translation
 
         private static TreeNode[] BuildTree(Block[] blocks)
         {
-            List<TreeNode> nodes = new();
+            List<TreeNode> nodes = [];
 
             Dictionary<ulong, TreeNode> labels = new();
 
@@ -382,7 +382,7 @@ namespace Ryujinx.Graphics.Shader.Translation
                 Type = type;
                 Order = order;
                 IsImm = isImm;
-                Uses = new List<PatternTreeNodeUse>();
+                Uses = [];
             }
 
             public PatternTreeNode<T> Use(PatternTreeNodeUse use)
@@ -527,8 +527,8 @@ namespace Ryujinx.Graphics.Shader.Translation
                 PatternTreeNodeUse affinityValue = S2r(SReg.Affinity).Use(PT).Out;
                 PatternTreeNodeUse orderingTicketValue = S2r(SReg.OrderingTicket).Use(PT).Out;
 
-                return new IPatternTreeNode[]
-                {
+                return
+                [
                     Iscadd(cc: true, 2, 0, 404)
                         .Use(PT)
                         .Use(Iscadd(cc: false, 8)
@@ -548,8 +548,8 @@ namespace Ryujinx.Graphics.Shader.Translation
                             .Use(PT)
                             .Use(orderingTicketValue).Out),
                     Iadd(x: true, 0, 405).Use(PT).Use(RZ),
-                    Ret().Use(PT),
-                };
+                    Ret().Use(PT)
+                ];
             }
 
             public static IPatternTreeNode[] GetFsiGetAddressV2()
@@ -557,8 +557,8 @@ namespace Ryujinx.Graphics.Shader.Translation
                 PatternTreeNodeUse affinityValue = S2r(SReg.Affinity).Use(PT).Out;
                 PatternTreeNodeUse orderingTicketValue = S2r(SReg.OrderingTicket).Use(PT).Out;
 
-                return new IPatternTreeNode[]
-                {
+                return
+                [
                     ShrU32W(16)
                         .Use(PT)
                         .Use(orderingTicketValue),
@@ -576,8 +576,8 @@ namespace Ryujinx.Graphics.Shader.Translation
                                 .Use(PT)
                                 .Use(orderingTicketValue).Out).Out),
                     Iadd(x: true, 0, 405).Use(PT).Use(RZ),
-                    Ret().Use(PT),
-                };
+                    Ret().Use(PT)
+                ];
             }
 
             public static IPatternTreeNode[] GetFsiIsLastWarpThread()
@@ -585,8 +585,8 @@ namespace Ryujinx.Graphics.Shader.Translation
                 PatternTreeNodeUse threadKillValue = S2r(SReg.ThreadKill).Use(PT).Out;
                 PatternTreeNodeUse laneIdValue = S2r(SReg.LaneId).Use(PT).Out;
 
-                return new IPatternTreeNode[]
-                {
+                return
+                [
                     IsetpU32(IComp.Eq)
                         .Use(PT)
                         .Use(PT)
@@ -603,8 +603,8 @@ namespace Ryujinx.Graphics.Shader.Translation
                                         .Use(threadKillValue).OutAt(1))
                                     .Use(RZ).Out).OutAt(1)).Out)
                         .Use(laneIdValue),
-                    Ret().Use(PT),
-                };
+                    Ret().Use(PT)
+                ];
             }
 
             public static IPatternTreeNode[] GetFsiBeginPattern()
@@ -624,8 +624,8 @@ namespace Ryujinx.Graphics.Shader.Translation
 
                 PatternTreeNode<byte> label;
 
-                return new IPatternTreeNode[]
-                {
+                return
+                [
                     Cal(),
                     Ret().Use(CallArg(0).Inv),
                     Ret()
@@ -638,8 +638,8 @@ namespace Ryujinx.Graphics.Shader.Translation
                             .Use(PT)
                             .Use(addressLowValue).Out).Inv)
                         .Use(label.Out),
-                    Ret().Use(PT),
-                };
+                    Ret().Use(PT)
+                ];
             }
 
             public static IPatternTreeNode[] GetFsiEndPattern()
@@ -652,8 +652,8 @@ namespace Ryujinx.Graphics.Shader.Translation
                 PatternTreeNodeUse addressLowValue = CallArg(1);
                 PatternTreeNodeUse incrementValue = CallArg(2);
 
-                return new IPatternTreeNode[]
-                {
+                return
+                [
                     Cal(),
                     Ret().Use(CallArg(0).Inv),
                     Membar(Decoders.Membar.Vc).Use(PT),
@@ -684,8 +684,8 @@ namespace Ryujinx.Graphics.Shader.Translation
                                 .Use(incrementValue)
                                 .Use(popcResult)
                                 .Use(RZ).Out).Out),
-                    Ret().Use(PT),
-                };
+                    Ret().Use(PT)
+                ];
             }
 
             private static PatternTreeNode<InstBfiI> Bfi(int imm)

+ 2 - 2
src/Ryujinx.Graphics.Shader/Translation/Optimizations/DoubleToFloat.cs

@@ -28,7 +28,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
             {
                 int functionId = hfm.GetOrCreateFunctionId(HelperFunctionName.ConvertDoubleToFloat);
 
-                Operand[] callArgs = new Operand[] { Const(functionId), operation.GetSource(0), operation.GetSource(1) };
+                Operand[] callArgs = [Const(functionId), operation.GetSource(0), operation.GetSource(1)];
 
                 Operand floatValue = operation.Dest;
 
@@ -51,7 +51,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
 
                 operation.Dest = null;
 
-                Operand[] callArgs = new Operand[] { Const(functionId), operation.GetSource(0), resultLow, resultHigh };
+                Operand[] callArgs = [Const(functionId), operation.GetSource(0), resultLow, resultHigh];
 
                 LinkedListNode<INode> newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, (Operand)null, callArgs));
 

+ 10 - 10
src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs

@@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
 
             public GtsContext(HelperFunctionManager hfm)
             {
-                _entries = new List<Entry>();
+                _entries = [];
                 _sharedEntries = new Dictionary<LsKey, Dictionary<uint, SearchResult>>();
                 _hfm = hfm;
             }
@@ -420,22 +420,22 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
 
             if (operation.Inst == Instruction.AtomicCompareAndSwap)
             {
-                sources = new[]
-                {
+                sources =
+                [
                     Const(binding),
                     Const(0),
                     wordOffset,
                     operation.GetSource(operation.SourcesCount - 2),
-                    operation.GetSource(operation.SourcesCount - 1),
-                };
+                    operation.GetSource(operation.SourcesCount - 1)
+                ];
             }
             else if (isStore)
             {
-                sources = new[] { Const(binding), Const(0), wordOffset, operation.GetSource(operation.SourcesCount - 1) };
+                sources = [Const(binding), Const(0), wordOffset, operation.GetSource(operation.SourcesCount - 1)];
             }
             else
             {
-                sources = new[] { Const(binding), Const(0), wordOffset };
+                sources = [Const(binding), Const(0), wordOffset];
             }
 
             Operation shiftOp = new(Instruction.ShiftRightU32, wordOffset, offset, Const(2));
@@ -507,7 +507,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
             SearchResult result,
             out int functionId)
         {
-            List<uint> targetCbs = new() { PackCbSlotAndOffset(result.SbCbSlot, result.SbCbOffset) };
+            List<uint> targetCbs = [PackCbSlotAndOffset(result.SbCbSlot, result.SbCbOffset)];
 
             if (gtsContext.TryGetFunctionId(operation, isMultiTarget: false, targetCbs, out functionId))
             {
@@ -592,8 +592,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
             out int functionId)
         {
             Queue<PhiNode> phis = new();
-            HashSet<PhiNode> visited = new();
-            List<uint> targetCbs = new();
+            HashSet<PhiNode> visited = [];
+            List<uint> targetCbs = [];
 
             Operand globalAddress = operation.GetSource(0);
 

+ 2 - 2
src/Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs

@@ -128,8 +128,8 @@ namespace Ryujinx.Graphics.Shader.Translation
 
         public static FunctionRegisterUsage RunPass(ControlFlowGraph cfg)
         {
-            List<Register> inArguments = new();
-            List<Register> outArguments = new();
+            List<Register> inArguments = [];
+            List<Register> outArguments = [];
 
             // Compute local register inputs and outputs used inside blocks.
             RegisterMask[] localInputs = new RegisterMask[cfg.Blocks.Length];

+ 13 - 15
src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs

@@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Shader.Translation
         private const int DefaultLocalMemorySize = 128;
         private const int DefaultSharedMemorySize = 4096;
 
-        private static readonly string[] _stagePrefixes = new string[] { "cp", "vp", "tcp", "tep", "gp", "fp" };
+        private static readonly string[] _stagePrefixes = ["cp", "vp", "tcp", "tep", "gp", "fp"];
 
         private readonly IGpuAccessor _gpuAccessor;
         private readonly ShaderStage _stage;
@@ -78,15 +78,15 @@ namespace Ryujinx.Graphics.Shader.Translation
             _sbSlots = new();
             _sbSlotsReverse = new();
 
-            _usedConstantBufferBindings = new();
+            _usedConstantBufferBindings = [];
 
             _usedTextures = new();
             _usedImages = new();
 
-            _vacConstantBuffers = new();
-            _vacStorageBuffers = new();
-            _vacTextures = new();
-            _vacImages = new();
+            _vacConstantBuffers = [];
+            _vacStorageBuffers = [];
+            _vacTextures = [];
+            _vacImages = [];
 
             Properties.AddOrUpdateConstantBuffer(new(BufferLayout.Std140, 0, SupportBuffer.Binding, "support_buffer", SupportBuffer.GetStructureType()));
 
@@ -524,7 +524,7 @@ namespace Ryujinx.Graphics.Shader.Translation
 
         private static TextureDescriptor[] GetDescriptors(IReadOnlyDictionary<TextureInfo, TextureMeta> usedResources, bool includeArrays)
         {
-            List<TextureDescriptor> descriptors = new();
+            List<TextureDescriptor> descriptors = [];
 
             bool hasAnyArray = false;
 
@@ -690,20 +690,18 @@ namespace Ryujinx.Graphics.Shader.Translation
 
         private void AddNewConstantBuffer(int setIndex, int binding, string name)
         {
-            StructureType type = new(new[]
-            {
-                new StructureField(AggregateType.Array | AggregateType.Vector4 | AggregateType.FP32, "data", Constants.ConstantBufferSize / 16),
-            });
+            StructureType type = new([
+                new StructureField(AggregateType.Array | AggregateType.Vector4 | AggregateType.FP32, "data", Constants.ConstantBufferSize / 16)
+            ]);
 
             Properties.AddOrUpdateConstantBuffer(new(BufferLayout.Std140, setIndex, binding, name, type));
         }
 
         private void AddNewStorageBuffer(int setIndex, int binding, string name)
         {
-            StructureType type = new(new[]
-            {
-                new StructureField(AggregateType.Array | AggregateType.U32, "data", 0),
-            });
+            StructureType type = new([
+                new StructureField(AggregateType.Array | AggregateType.U32, "data", 0)
+            ]);
 
             Properties.AddOrUpdateStorageBuffer(new(BufferLayout.Std430, setIndex, binding, name, type));
         }

+ 1 - 1
src/Ryujinx.Graphics.Shader/Translation/Transforms/SharedAtomicSignedCas.cs

@@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
 
             int functionId = context.Hfm.GetOrCreateFunctionId(name, memoryId.Value);
 
-            Operand[] callArgs = new Operand[] { Const(functionId), byteOffset, value };
+            Operand[] callArgs = [Const(functionId), byteOffset, value];
 
             LinkedListNode<INode> newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, result, callArgs));
 

+ 1 - 1
src/Ryujinx.Graphics.Shader/Translation/Transforms/SharedStoreSmallIntCas.cs

@@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
 
             int functionId = context.Hfm.GetOrCreateFunctionId(name, memoryId.Value);
 
-            Operand[] callArgs = new Operand[] { Const(functionId), byteOffset, value };
+            Operand[] callArgs = [Const(functionId), byteOffset, value];
 
             LinkedListNode<INode> newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, (Operand)null, callArgs));
 

+ 1 - 1
src/Ryujinx.Graphics.Shader/Translation/Transforms/ShufflePass.cs

@@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
 
             operation.Dest = null;
 
-            Operand[] callArgs = new Operand[] { Const(functionId), value, index, mask, valid };
+            Operand[] callArgs = [Const(functionId), value, index, mask, valid];
 
             LinkedListNode<INode> newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, result, callArgs));
 

+ 17 - 16
src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs

@@ -71,11 +71,12 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
 
                     if (stage == ShaderStage.Fragment)
                     {
-                        callArgs = new Operand[] { Const(functionId), texOp.GetSource(coordsIndex + index), Const(samplerIndex), Const(index) };
+                        callArgs = [Const(functionId), texOp.GetSource(coordsIndex + index), Const(samplerIndex), Const(index)
+                        ];
                     }
                     else
                     {
-                        callArgs = new Operand[] { Const(functionId), texOp.GetSource(coordsIndex + index), Const(samplerIndex) };
+                        callArgs = [Const(functionId), texOp.GetSource(coordsIndex + index), Const(samplerIndex)];
                     }
 
                     node.List.AddBefore(node, new Operation(Instruction.Call, 0, scaledCoord, callArgs));
@@ -127,7 +128,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
                         }
                     }
 
-                    Operand[] callArgs = new Operand[] { Const(functionId), dest, Const(samplerIndex) };
+                    Operand[] callArgs = [Const(functionId), dest, Const(samplerIndex)];
 
                     node.List.AddAfter(node, new Operation(Instruction.Call, 0, unscaledSize, callArgs));
                 }
@@ -175,7 +176,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
             {
                 Operand coordSize = Local();
 
-                Operand[] texSizeSources = new Operand[] { Const(0) };
+                Operand[] texSizeSources = [Const(0)];
 
                 LinkedListNode<INode> textureSizeNode = node.List.AddBefore(node, new TextureOperation(
                     Instruction.TextureQuerySize,
@@ -185,7 +186,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
                     texOp.Set,
                     texOp.Binding,
                     index,
-                    new[] { coordSize },
+                    [coordSize],
                     texSizeSources));
 
                 resourceManager.SetUsageFlagsForTextureQuery(texOp.Binding, texOp.Type);
@@ -240,11 +241,11 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
 
                 if (isBindless || isIndexed)
                 {
-                    texSizeSources = new Operand[] { texOp.GetSource(0), Const(0) };
+                    texSizeSources = [texOp.GetSource(0), Const(0)];
                 }
                 else
                 {
-                    texSizeSources = new Operand[] { Const(0) };
+                    texSizeSources = [Const(0)];
                 }
 
                 node.List.AddBefore(node, new TextureOperation(
@@ -255,7 +256,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
                     texOp.Set,
                     texOp.Binding,
                     index,
-                    new[] { coordSize },
+                    [coordSize],
                     texSizeSources));
 
                 node.List.AddBefore(node, new Operation(
@@ -476,7 +477,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
                         texOp.Set,
                         texOp.Binding,
                         1 << 3, // W component: i=0, j=0
-                        new[] { dests[destIndex++] },
+                        [dests[destIndex++]],
                         newSources);
 
                     node = node.List.AddBefore(node, newTexOp);
@@ -565,11 +566,11 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
 
                 if (bindlessHandle != null)
                 {
-                    texSizeSources = new Operand[] { bindlessHandle, Const(0) };
+                    texSizeSources = [bindlessHandle, Const(0)];
                 }
                 else
                 {
-                    texSizeSources = new Operand[] { Const(0) };
+                    texSizeSources = [Const(0)];
                 }
 
                 node.List.AddBefore(node, new TextureOperation(
@@ -580,7 +581,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
                     texOp.Set,
                     texOp.Binding,
                     index,
-                    new[] { texSizes[index] },
+                    [texSizes[index]],
                     texSizeSources));
             }
 
@@ -611,7 +612,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
                     texOp.Set,
                     texOp.Binding,
                     0,
-                    new[] { lod },
+                    [lod],
                     lodSources));
             }
             else
@@ -627,11 +628,11 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
 
                 if (bindlessHandle != null)
                 {
-                    texSizeSources = new Operand[] { bindlessHandle, GenerateF2i(node, lod) };
+                    texSizeSources = [bindlessHandle, GenerateF2i(node, lod)];
                 }
                 else
                 {
-                    texSizeSources = new Operand[] { GenerateF2i(node, lod) };
+                    texSizeSources = [GenerateF2i(node, lod)];
                 }
 
                 node.List.AddBefore(node, new TextureOperation(
@@ -642,7 +643,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
                     texOp.Set,
                     texOp.Binding,
                     index,
-                    new[] { texSizes[index] },
+                    [texSizes[index]],
                     texSizeSources));
             }
 

+ 7 - 7
src/Ryujinx.Graphics.Shader/Translation/Transforms/VertexToCompute.cs

@@ -66,8 +66,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
                                 setAndBinding.SetIndex,
                                 setAndBinding.Binding,
                                 1 << component,
-                                new[] { temp },
-                                new[] { vertexElemOffset }));
+                                [temp],
+                                [vertexElemOffset]));
 
                             if (needsSextNorm)
                             {
@@ -89,8 +89,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
                                 setAndBinding.SetIndex,
                                 setAndBinding.Binding,
                                 1,
-                                new[] { temp },
-                                new[] { vertexElemOffset }));
+                                [temp],
+                                [vertexElemOffset]));
 
                             if (component > 0)
                             {
@@ -312,21 +312,21 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
 
         private static LinkedListNode<INode> GenerateVertexIdVertexRateLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
         {
-            Operand[] sources = new Operand[] { Const(resourceManager.LocalVertexIndexVertexRateMemoryId) };
+            Operand[] sources = [Const(resourceManager.LocalVertexIndexVertexRateMemoryId)];
 
             return node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.LocalMemory, dest, sources));
         }
 
         private static LinkedListNode<INode> GenerateVertexIdInstanceRateLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
         {
-            Operand[] sources = new Operand[] { Const(resourceManager.LocalVertexIndexInstanceRateMemoryId) };
+            Operand[] sources = [Const(resourceManager.LocalVertexIndexInstanceRateMemoryId)];
 
             return node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.LocalMemory, dest, sources));
         }
 
         private static LinkedListNode<INode> GenerateInstanceIdLoad(LinkedListNode<INode> node, Operand dest)
         {
-            Operand[] sources = new Operand[] { Const((int)IoVariable.GlobalId), Const(1) };
+            Operand[] sources = [Const((int)IoVariable.GlobalId), Const(1)];
 
             return node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.Input, dest, sources));
         }

+ 10 - 14
src/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs

@@ -386,10 +386,9 @@ namespace Ryujinx.Graphics.Shader.Translation
 
             if (IsTransformFeedbackEmulated)
             {
-                StructureType tfeDataStruct = new(new StructureField[]
-                {
+                StructureType tfeDataStruct = new([
                     new(AggregateType.Array | AggregateType.U32, "data", 0)
-                });
+                ]);
 
                 for (int i = 0; i < ResourceReservations.TfeBuffersCount; i++)
                 {
@@ -405,10 +404,9 @@ namespace Ryujinx.Graphics.Shader.Translation
                 BufferDefinition vertexInfoBuffer = new(BufferLayout.Std140, 0, vertexInfoCbBinding, "vb_info", VertexInfoBuffer.GetStructureType());
                 resourceManager.AddVertexAsComputeConstantBuffer(vertexInfoBuffer);
 
-                StructureType vertexOutputStruct = new(new StructureField[]
-                {
+                StructureType vertexOutputStruct = new([
                     new(AggregateType.Array | AggregateType.FP32, "data", 0)
-                });
+                ]);
 
                 int vertexOutputSbBinding = resourceManager.Reservations.VertexOutputStorageBufferBinding;
                 BufferDefinition vertexOutputBuffer = new(BufferLayout.Std430, 1, vertexOutputSbBinding, "vertex_output", vertexOutputStruct);
@@ -442,10 +440,9 @@ namespace Ryujinx.Graphics.Shader.Translation
                     BufferDefinition geometryVbOutputBuffer = new(BufferLayout.Std430, 1, geometryVbOutputSbBinding, "geometry_vb_output", vertexOutputStruct);
                     resourceManager.AddVertexAsComputeStorageBuffer(geometryVbOutputBuffer);
 
-                    StructureType geometryIbOutputStruct = new(new StructureField[]
-                    {
+                    StructureType geometryIbOutputStruct = new([
                         new(AggregateType.Array | AggregateType.U32, "data", 0)
-                    });
+                    ]);
 
                     int geometryIbOutputSbBinding = resourceManager.Reservations.GeometryIndexOutputStorageBufferBinding;
                     BufferDefinition geometryIbOutputBuffer = new(BufferLayout.Std430, 1, geometryIbOutputSbBinding, "geometry_ib_output", geometryIbOutputStruct);
@@ -507,10 +504,9 @@ namespace Ryujinx.Graphics.Shader.Translation
                 resourceManager.AddVertexAsComputeConstantBuffer(vertexInfoBuffer);
             }
 
-            StructureType vertexInputStruct = new(new StructureField[]
-            {
+            StructureType vertexInputStruct = new([
                 new(AggregateType.Array | AggregateType.FP32, "data", 0)
-            });
+            ]);
 
             int vertexDataSbBinding = reservations.VertexOutputStorageBufferBinding;
             BufferDefinition vertexOutputBuffer = new(BufferLayout.Std430, 1, vertexDataSbBinding, "vb_input", vertexInputStruct);
@@ -573,7 +569,7 @@ namespace Ryujinx.Graphics.Shader.Translation
             };
 
             return (Generate(
-                new[] { function },
+                [function],
                 attributeUsage,
                 definitions,
                 definitions,
@@ -669,7 +665,7 @@ namespace Ryujinx.Graphics.Shader.Translation
                 maxOutputVertices);
 
             return Generate(
-                new[] { function },
+                [function],
                 attributeUsage,
                 definitions,
                 definitions,

+ 3 - 4
src/Ryujinx.Graphics.Shader/VertexInfoBuffer.cs

@@ -42,13 +42,12 @@ namespace Ryujinx.Graphics.Shader
 
         internal static StructureType GetStructureType()
         {
-            return new StructureType(new[]
-            {
+            return new StructureType([
                 new StructureField(AggregateType.Vector4 | AggregateType.U32, "vertex_counts"),
                 new StructureField(AggregateType.Vector4 | AggregateType.U32, "geometry_counts"),
                 new StructureField(AggregateType.Array | AggregateType.Vector4 | AggregateType.U32, "vertex_strides", ResourceReservations.MaxVertexBufferTextures),
-                new StructureField(AggregateType.Array | AggregateType.Vector4 | AggregateType.U32, "vertex_offsets", ResourceReservations.MaxVertexBufferTextures),
-            });
+                new StructureField(AggregateType.Array | AggregateType.Vector4 | AggregateType.U32, "vertex_offsets", ResourceReservations.MaxVertexBufferTextures)
+            ]);
         }
 
         public Vector4<int> VertexCounts;