From 95f9e548cae3358a1b79e121a8c8851749040a6d Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Sun, 26 Jan 2025 15:50:50 -0600 Subject: [PATCH] misc: chore: Use collection expressions in Shader project --- .../CodeGen/Spirv/CodeGenContext.cs | 4 +- .../CodeGen/Spirv/Declarations.cs | 2 +- .../CodeGen/Spirv/Instructions.cs | 20 ++++---- src/Ryujinx.Graphics.Shader/Decoders/Block.cs | 8 ++-- .../Decoders/DecodedFunction.cs | 2 +- .../Decoders/DecodedProgram.cs | 2 +- .../Decoders/Decoder.cs | 8 ++-- .../Instructions/InstEmitHelper.cs | 48 +++++++++---------- .../Instructions/InstEmitSurface.cs | 8 ++-- .../Instructions/InstEmitTexture.cs | 20 ++++---- .../IntermediateRepresentation/BasicBlock.cs | 6 +-- .../IntermediateRepresentation/Operand.cs | 2 +- .../IntermediateRepresentation/Operation.cs | 16 +++---- .../IntermediateRepresentation/PhiNode.cs | 4 +- .../StructuredIr/AstBlock.cs | 2 +- .../StructuredIr/AstOperand.cs | 4 +- .../StructuredIr/GotoElimination.cs | 2 +- .../StructuredIr/StructuredFunction.cs | 2 +- .../StructuredIr/StructuredProgram.cs | 5 +- .../StructuredIr/StructuredProgramContext.cs | 12 ++--- .../StructuredIr/StructuredProgramInfo.cs | 4 +- src/Ryujinx.Graphics.Shader/SupportBuffer.cs | 7 ++- .../Translation/AttributeUsage.cs | 4 +- .../Translation/ControlFlowGraph.cs | 4 +- .../Translation/EmitterContext.cs | 12 ++--- .../Translation/EmitterContextInsts.cs | 8 ++-- .../Translation/FunctionMatch.cs | 46 +++++++++--------- .../Optimizations/DoubleToFloat.cs | 4 +- .../Optimizations/GlobalToStorage.cs | 20 ++++---- .../Translation/RegisterUsage.cs | 4 +- .../Translation/ResourceManager.cs | 28 +++++------ .../Transforms/SharedAtomicSignedCas.cs | 2 +- .../Transforms/SharedStoreSmallIntCas.cs | 2 +- .../Translation/Transforms/ShufflePass.cs | 2 +- .../Translation/Transforms/TexturePass.cs | 33 ++++++------- .../Translation/Transforms/VertexToCompute.cs | 14 +++--- .../Translation/TranslatorContext.cs | 24 ++++------ .../VertexInfoBuffer.cs | 7 ++- 38 files changed, 198 insertions(+), 204 deletions(-) diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs index f623f2451..5abbf1fa8 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs +++ b/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 _labels = new(); + private readonly List _labels = []; public Instruction GetNextLabel(CodeGenContext context) { @@ -147,7 +147,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv public Instruction[] GetMainInterface() { - List mainInterface = new(); + List mainInterface = []; mainInterface.AddRange(Inputs.Values); mainInterface.AddRange(Outputs.Values); diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs index 0b2ad41fb..c0a597a10 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs +++ b/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 buffers, bool isBuffer) { - HashSet decoratedTypes = new(); + HashSet decoratedTypes = []; foreach (BufferDefinition buffer in buffers) { diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs index 9b00f7edb..39b27a3e1 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs +++ b/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[] - { + offsets = + [ AssembleOffsetVector(coordsCount), 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 operandsList = new(); + List operandsList = []; ImageOperandsMask operandsMask = ImageOperandsMask.MaskNone; if (hasLodBias) diff --git a/src/Ryujinx.Graphics.Shader/Decoders/Block.cs b/src/Ryujinx.Graphics.Shader/Decoders/Block.cs index 1a694898b..9264d15b9 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/Block.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/Block.cs @@ -45,11 +45,11 @@ namespace Ryujinx.Graphics.Shader.Decoders { Address = address; - Predecessors = new List(); - Successors = new List(); + Predecessors = []; + Successors = []; - OpCodes = new List(); - PushOpCodes = new List(); + OpCodes = []; + PushOpCodes = []; SyncTargets = new Dictionary(); } diff --git a/src/Ryujinx.Graphics.Shader/Decoders/DecodedFunction.cs b/src/Ryujinx.Graphics.Shader/Decoders/DecodedFunction.cs index 49cd3a30a..ce702b2ab 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/DecodedFunction.cs +++ b/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(); + _callers = []; Type = FunctionType.User; Id = -1; } diff --git a/src/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs b/src/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs index fdf3eacc3..be5d0a81b 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs +++ b/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; diff --git a/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs b/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs index d9f4dd5eb..72e934a39 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs @@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.Shader.Decoders while (functionsQueue.TryDequeue(out DecodedFunction currentFunction)) { - List blocks = new(); + List blocks = []; Queue workQueue = new(); Dictionary visited = new(); @@ -520,7 +520,7 @@ namespace Ryujinx.Graphics.Shader.Decoders if (lastOp.Name == InstName.Brx && block.Successors.Count == (hasNext ? 1 : 0)) { - HashSet visited = new(); + HashSet 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 visited = new(); + HashSet 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 workQueue = new(); - HashSet visited = new(); + HashSet visited = []; Stack<(ulong, MergeType)> branchStack = new(); void Push(PathBlockState pbs) diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs index 8638fb8f2..d3623ff6f 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs +++ b/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(ref low)), - ConstF((float)Unsafe.As(ref high)), - }; + ConstF((float)Unsafe.As(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(ref low)), - ConstF((float)Unsafe.As(ref high)), - }; + ConstF((float)Unsafe.As(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}\"."), }; } diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs index 383e82c69..946dcc02e 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs @@ -221,7 +221,7 @@ namespace Ryujinx.Graphics.Shader.Instructions Operand d = Register(dest, RegisterType.Gpr); - List sourcesList = new(); + List sourcesList = []; if (isBindless) { @@ -328,7 +328,7 @@ namespace Ryujinx.Graphics.Shader.Instructions return context.Copy(Register(srcA++, RegisterType.Gpr)); } - List sourcesList = new(); + List sourcesList = []; if (isBindless) { @@ -500,7 +500,7 @@ namespace Ryujinx.Graphics.Shader.Instructions return context.Copy(Register(srcB++, RegisterType.Gpr)); } - List sourcesList = new(); + List sourcesList = []; if (isBindless) { @@ -605,7 +605,7 @@ namespace Ryujinx.Graphics.Shader.Instructions return context.Copy(Register(srcB++, RegisterType.Gpr)); } - List sourcesList = new(); + List sourcesList = []; if (isBindless) { diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs index 52a004c0e..7499f12d8 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs +++ b/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 sourcesList = new(); + List sourcesList = []; if (isBindless) { @@ -339,7 +339,7 @@ namespace Ryujinx.Graphics.Shader.Instructions return; } - List sourcesList = new(); + List 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 sourcesList = new(); + List sourcesList = []; SamplerType type = ConvertSamplerType(dimensions); TextureFlags flags = TextureFlags.Gather; @@ -835,7 +835,7 @@ namespace Ryujinx.Graphics.Shader.Instructions TextureFlags flags = TextureFlags.None; - List sourcesList = new(); + List sourcesList = []; if (isBindless) { @@ -963,7 +963,7 @@ namespace Ryujinx.Graphics.Shader.Instructions TextureFlags flags = TextureFlags.Derivatives; - List sourcesList = new(); + List sourcesList = []; if (isBindless) { @@ -1076,7 +1076,7 @@ namespace Ryujinx.Graphics.Shader.Instructions return context.Copy(Register(srcA++, RegisterType.Gpr)); } - List sourcesList = new(); + List sourcesList = []; if (isBindless) { diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs index 637e120e1..d3eae3108 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs @@ -34,11 +34,11 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation public BasicBlock() { - Operations = new LinkedList(); + Operations = []; - Predecessors = new List(); + Predecessors = []; - DominanceFrontiers = new HashSet(); + DominanceFrontiers = []; } public BasicBlock(int index) : this() diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operand.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operand.cs index 6648457f0..19e65951a 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operand.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operand.cs @@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation private Operand() { - UseOps = new HashSet(); + UseOps = []; } public Operand(OperandType type) : this() diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operation.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operation.cs index 713e8a4fb..dc2f56e7e 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operation.cs +++ b/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(); + _dests = []; } } } @@ -82,7 +82,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation } else { - _dests = Array.Empty(); + _dests = []; } } @@ -94,11 +94,11 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation { dest.AsgOp = this; - _dests = new[] { dest }; + _dests = [dest]; } else { - _dests = Array.Empty(); + _dests = []; } } @@ -111,11 +111,11 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation { dest.AsgOp = this; - _dests = new[] { dest }; + _dests = [dest]; } else { - _dests = Array.Empty(); + _dests = []; } } @@ -258,7 +258,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation source.UseOps.Add(this); } - _sources = new Operand[] { source }; + _sources = [source]; } public void TurnDoubleIntoFloat() diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/PhiNode.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/PhiNode.cs index f4c4fef42..a32b2e9ee 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/PhiNode.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/PhiNode.cs @@ -35,9 +35,9 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation public PhiNode(Operand dest) { - _blocks = new HashSet(); + _blocks = []; - _sources = new List(); + _sources = []; dest.AsgOp = this; diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs index 826dbff88..97c0f005e 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs @@ -41,7 +41,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr Type = type; Condition = condition; - _nodes = new LinkedList(); + _nodes = []; } public void Add(IAstNode node) diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs index b64b96b8d..28aad589f 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs @@ -17,8 +17,8 @@ namespace Ryujinx.Graphics.Shader.StructuredIr private AstOperand() { - Defs = new HashSet(); - Uses = new HashSet(); + Defs = []; + Uses = []; VarType = AggregateType.S32; } diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs index 3ca1266f6..687e5942d 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs @@ -429,7 +429,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr { AstBlock block = bottom; - List path = new(); + List path = []; while (block != top) { diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs index aa5e13867..79fba17cd 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs @@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr InArguments = inArguments; OutArguments = outArguments; - Locals = new HashSet(); + Locals = []; } public AggregateType GetArgumentType(int index) diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs index a1aef7f97..1ae669aa9 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs +++ b/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 visited = new(); + HashSet visited = []; Queue pending = new(); diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs index c26086c72..a5887e80d 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs @@ -70,7 +70,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr AggregateType[] inArguments, AggregateType[] outArguments) { - _loopTails = new HashSet(); + _loopTails = []; _blockStack = new Stack<(AstBlock, int, int)>(); @@ -78,7 +78,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr _gotoTempAsgs = new Dictionary(); - _gotos = new List(); + _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); } diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs index 585497ed3..2f8675069 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs @@ -12,9 +12,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr public StructuredProgramInfo(bool precise) { - Functions = new List(); + Functions = []; - IoDefinitions = new HashSet(); + IoDefinitions = []; if (precise) { diff --git a/src/Ryujinx.Graphics.Shader/SupportBuffer.cs b/src/Ryujinx.Graphics.Shader/SupportBuffer.cs index d4d3cbf8f..fb624d624 100644 --- a/src/Ryujinx.Graphics.Shader/SupportBuffer.cs +++ b/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 FragmentAlphaTest; diff --git a/src/Ryujinx.Graphics.Shader/Translation/AttributeUsage.cs b/src/Ryujinx.Graphics.Shader/Translation/AttributeUsage.cs index 9dab9fdf9..5504ef4ed 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/AttributeUsage.cs +++ b/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) diff --git a/src/Ryujinx.Graphics.Shader/Translation/ControlFlowGraph.cs b/src/Ryujinx.Graphics.Shader/Translation/ControlFlowGraph.cs index 9b07c28f1..e14044256 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/ControlFlowGraph.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/ControlFlowGraph.cs @@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Shader.Translation { Blocks = blocks; - HashSet visited = new(); + HashSet visited = []; Stack blockStack = new(); @@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.Shader.Translation { Dictionary labels = new(); - List blocks = new(); + List blocks = []; BasicBlock currentBlock = null; diff --git a/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs b/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs index 25ecb8621..94448626f 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs @@ -54,7 +54,7 @@ namespace Ryujinx.Graphics.Shader.Translation public EmitterContext() { - _operations = new List(); + _operations = []; _labels = new Dictionary(); } @@ -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); diff --git a/src/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs b/src/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs index 5bdbb0025..3d19586db 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs +++ b/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; diff --git a/src/Ryujinx.Graphics.Shader/Translation/FunctionMatch.cs b/src/Ryujinx.Graphics.Shader/Translation/FunctionMatch.cs index ba9685433..b396de06b 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/FunctionMatch.cs +++ b/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(); + Uses = []; Type = TreeNodeType.Op; Order = order; } @@ -150,7 +150,7 @@ namespace Ryujinx.Graphics.Shader.Translation private static TreeNode[] BuildTree(Block[] blocks) { - List nodes = new(); + List nodes = []; Dictionary labels = new(); @@ -382,7 +382,7 @@ namespace Ryujinx.Graphics.Shader.Translation Type = type; Order = order; IsImm = isImm; - Uses = new List(); + Uses = []; } public PatternTreeNode 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 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 Bfi(int imm) diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/DoubleToFloat.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/DoubleToFloat.cs index aec95a9cc..208ca3935 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/DoubleToFloat.cs +++ b/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 newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, (Operand)null, callArgs)); diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs index 8628b3236..4805fb1ca 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs +++ b/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(); + _entries = []; _sharedEntries = new Dictionary>(); _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 targetCbs = new() { PackCbSlotAndOffset(result.SbCbSlot, result.SbCbOffset) }; + List 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 phis = new(); - HashSet visited = new(); - List targetCbs = new(); + HashSet visited = []; + List targetCbs = []; Operand globalAddress = operation.GetSource(0); diff --git a/src/Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs b/src/Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs index 2851381ae..c6bbb4968 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs @@ -128,8 +128,8 @@ namespace Ryujinx.Graphics.Shader.Translation public static FunctionRegisterUsage RunPass(ControlFlowGraph cfg) { - List inArguments = new(); - List outArguments = new(); + List inArguments = []; + List outArguments = []; // Compute local register inputs and outputs used inside blocks. RegisterMask[] localInputs = new RegisterMask[cfg.Blocks.Length]; diff --git a/src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs b/src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs index dee5174f2..e10182747 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs +++ b/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 usedResources, bool includeArrays) { - List descriptors = new(); + List 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)); } diff --git a/src/Ryujinx.Graphics.Shader/Translation/Transforms/SharedAtomicSignedCas.cs b/src/Ryujinx.Graphics.Shader/Translation/Transforms/SharedAtomicSignedCas.cs index 112b3b197..c556e8149 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Transforms/SharedAtomicSignedCas.cs +++ b/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 newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, result, callArgs)); diff --git a/src/Ryujinx.Graphics.Shader/Translation/Transforms/SharedStoreSmallIntCas.cs b/src/Ryujinx.Graphics.Shader/Translation/Transforms/SharedStoreSmallIntCas.cs index e58be0a8e..2852a61ad 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Transforms/SharedStoreSmallIntCas.cs +++ b/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 newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, (Operand)null, callArgs)); diff --git a/src/Ryujinx.Graphics.Shader/Translation/Transforms/ShufflePass.cs b/src/Ryujinx.Graphics.Shader/Translation/Transforms/ShufflePass.cs index 839d4f818..9cb361e6c 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Transforms/ShufflePass.cs +++ b/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 newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, result, callArgs)); diff --git a/src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs b/src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs index 6ba8cb44a..808692559 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs +++ b/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 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)); } diff --git a/src/Ryujinx.Graphics.Shader/Translation/Transforms/VertexToCompute.cs b/src/Ryujinx.Graphics.Shader/Translation/Transforms/VertexToCompute.cs index ddd2134d2..ebff0d59c 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Transforms/VertexToCompute.cs +++ b/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 GenerateVertexIdVertexRateLoad(ResourceManager resourceManager, LinkedListNode 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 GenerateVertexIdInstanceRateLoad(ResourceManager resourceManager, LinkedListNode 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 GenerateInstanceIdLoad(LinkedListNode 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)); } diff --git a/src/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs b/src/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs index 441d1f77a..ff8fb255a 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs +++ b/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, diff --git a/src/Ryujinx.Graphics.Shader/VertexInfoBuffer.cs b/src/Ryujinx.Graphics.Shader/VertexInfoBuffer.cs index 845135f86..000d372dc 100644 --- a/src/Ryujinx.Graphics.Shader/VertexInfoBuffer.cs +++ b/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 VertexCounts;