misc: chore: Use collection expressions in Shader project

This commit is contained in:
Evan Husted 2025-01-26 15:50:50 -06:00
parent a5dbcb75d0
commit 95f9e548ca
38 changed files with 198 additions and 204 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -237,7 +237,8 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
dest.VarType = destElemType; 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) else if (operation.Dest != null)
@ -354,7 +355,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
private static AggregateType GetVarTypeFromUses(Operand dest) private static AggregateType GetVarTypeFromUses(Operand dest)
{ {
HashSet<Operand> visited = new(); HashSet<Operand> visited = [];
Queue<Operand> pending = new(); Queue<Operand> pending = new();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
{ {
int functionId = hfm.GetOrCreateFunctionId(HelperFunctionName.ConvertDoubleToFloat); 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; Operand floatValue = operation.Dest;
@ -51,7 +51,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
operation.Dest = null; 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)); LinkedListNode<INode> newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, (Operand)null, callArgs));

View File

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

View File

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

View File

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

View File

@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
int functionId = context.Hfm.GetOrCreateFunctionId(name, memoryId.Value); 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)); LinkedListNode<INode> newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, result, callArgs));

View File

@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
int functionId = context.Hfm.GetOrCreateFunctionId(name, memoryId.Value); 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)); LinkedListNode<INode> newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, (Operand)null, callArgs));

View File

@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
operation.Dest = null; 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)); LinkedListNode<INode> newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, result, callArgs));

View File

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

View File

@ -66,8 +66,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
setAndBinding.SetIndex, setAndBinding.SetIndex,
setAndBinding.Binding, setAndBinding.Binding,
1 << component, 1 << component,
new[] { temp }, [temp],
new[] { vertexElemOffset })); [vertexElemOffset]));
if (needsSextNorm) if (needsSextNorm)
{ {
@ -89,8 +89,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
setAndBinding.SetIndex, setAndBinding.SetIndex,
setAndBinding.Binding, setAndBinding.Binding,
1, 1,
new[] { temp }, [temp],
new[] { vertexElemOffset })); [vertexElemOffset]));
if (component > 0) 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) 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)); 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) 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)); return node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.LocalMemory, dest, sources));
} }
private static LinkedListNode<INode> GenerateInstanceIdLoad(LinkedListNode<INode> node, Operand dest) 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)); return node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.Input, dest, sources));
} }

View File

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

View File

@ -42,13 +42,12 @@ namespace Ryujinx.Graphics.Shader
internal static StructureType GetStructureType() 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, "vertex_counts"),
new StructureField(AggregateType.Vector4 | AggregateType.U32, "geometry_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_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; public Vector4<int> VertexCounts;