Prefer using collection expressions with implicit object creation when the type is clear

This commit is contained in:
Marco Carvalho
2024-12-27 13:23:31 -03:00
parent 850df38f1e
commit 57d1486da9
510 changed files with 6022 additions and 6212 deletions

View File

@@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
public OperandManager()
{
_locals = new Dictionary<AstOperand, string>();
_locals = [];
}
public string DeclareLocal(AstOperand operand)

View File

@@ -75,8 +75,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
context.AppendLine();
DeclareOutputAttributes(context, info.IoDefinitions.Where(x => x.StorageKind == StorageKind.Output));
context.AppendLine();
DeclareBufferStructures(context, context.Properties.ConstantBuffers.Values.OrderBy(x => x.Binding).ToArray(), true, fsi);
DeclareBufferStructures(context, context.Properties.StorageBuffers.Values.OrderBy(x => x.Binding).ToArray(), false, fsi);
DeclareBufferStructures(context, [.. context.Properties.ConstantBuffers.Values.OrderBy(x => x.Binding)], true, fsi);
DeclareBufferStructures(context, [.. context.Properties.StorageBuffers.Values.OrderBy(x => x.Binding)], false, fsi);
// We need to declare each set as a new struct
var textureDefinitions = context.Properties.Textures.Values

View File

@@ -152,26 +152,26 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
// TODO: add these only if they are used
if (stage == ShaderStage.Vertex)
{
args = args.Append("uint vertex_id [[vertex_id]]").ToArray();
args = args.Append("uint instance_id [[instance_id]]").ToArray();
args = args.Append("uint base_instance [[base_instance]]").ToArray();
args = args.Append("uint base_vertex [[base_vertex]]").ToArray();
args = [.. args, "uint vertex_id [[vertex_id]]"];
args = [.. args, "uint instance_id [[instance_id]]"];
args = [.. args, "uint base_instance [[base_instance]]"];
args = [.. args, "uint base_vertex [[base_vertex]]"];
}
else if (stage == ShaderStage.Compute)
{
args = args.Append("uint3 threadgroup_position_in_grid [[threadgroup_position_in_grid]]").ToArray();
args = args.Append("uint3 thread_position_in_grid [[thread_position_in_grid]]").ToArray();
args = args.Append("uint3 thread_position_in_threadgroup [[thread_position_in_threadgroup]]").ToArray();
args = args.Append("uint thread_index_in_simdgroup [[thread_index_in_simdgroup]]").ToArray();
args = [.. args, "uint3 threadgroup_position_in_grid [[threadgroup_position_in_grid]]"];
args = [.. args, "uint3 thread_position_in_grid [[thread_position_in_grid]]"];
args = [.. args, "uint3 thread_position_in_threadgroup [[thread_position_in_threadgroup]]"];
args = [.. args, "uint thread_index_in_simdgroup [[thread_index_in_simdgroup]]"];
}
args = args.Append($"constant ConstantBuffers &constant_buffers [[buffer({Defaults.ConstantBuffersIndex})]]").ToArray();
args = args.Append($"device StorageBuffers &storage_buffers [[buffer({Defaults.StorageBuffersIndex})]]").ToArray();
args = [.. args, $"constant ConstantBuffers &constant_buffers [[buffer({Defaults.ConstantBuffersIndex})]]"];
args = [.. args, $"device StorageBuffers &storage_buffers [[buffer({Defaults.StorageBuffersIndex})]]"];
foreach (var set in sets)
{
var bindingIndex = set + Defaults.BaseSetIndex;
args = args.Append($"constant {Declarations.GetNameForSet(set)} &{Declarations.GetNameForSet(set, true)} [[buffer({bindingIndex})]]").ToArray();
args = [.. args, $"constant {Declarations.GetNameForSet(set)} &{Declarations.GetNameForSet(set, true)} [[buffer({bindingIndex})]]"];
}
}

View File

@@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
public OperandManager()
{
_locals = new Dictionary<AstOperand, string>();
_locals = [];
}
public string DeclareLocal(AstOperand operand)

View File

@@ -27,30 +27,30 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
public ILogger Logger { get; }
public TargetApi TargetApi { get; }
public Dictionary<int, Instruction> ConstantBuffers { get; } = new();
public Dictionary<int, Instruction> StorageBuffers { get; } = new();
public Dictionary<int, Instruction> ConstantBuffers { get; } = [];
public Dictionary<int, Instruction> StorageBuffers { get; } = [];
public Dictionary<int, Instruction> LocalMemories { get; } = new();
public Dictionary<int, Instruction> SharedMemories { get; } = new();
public Dictionary<int, Instruction> LocalMemories { get; } = [];
public Dictionary<int, Instruction> SharedMemories { get; } = [];
public Dictionary<SetBindingPair, SamplerType> SamplersTypes { get; } = new();
public Dictionary<SetBindingPair, SamplerDeclaration> Samplers { get; } = new();
public Dictionary<SetBindingPair, ImageDeclaration> Images { get; } = new();
public Dictionary<SetBindingPair, SamplerType> SamplersTypes { get; } = [];
public Dictionary<SetBindingPair, SamplerDeclaration> Samplers { get; } = [];
public Dictionary<SetBindingPair, ImageDeclaration> Images { get; } = [];
public Dictionary<IoDefinition, Instruction> Inputs { get; } = new();
public Dictionary<IoDefinition, Instruction> Outputs { get; } = new();
public Dictionary<IoDefinition, Instruction> InputsPerPatch { get; } = new();
public Dictionary<IoDefinition, Instruction> OutputsPerPatch { get; } = new();
public Dictionary<IoDefinition, Instruction> Inputs { get; } = [];
public Dictionary<IoDefinition, Instruction> Outputs { get; } = [];
public Dictionary<IoDefinition, Instruction> InputsPerPatch { get; } = [];
public Dictionary<IoDefinition, Instruction> OutputsPerPatch { get; } = [];
public StructuredFunction CurrentFunction { get; set; }
private readonly Dictionary<AstOperand, Instruction> _locals = new();
private readonly Dictionary<int, Instruction> _funcArgs = new();
private readonly Dictionary<int, (StructuredFunction, Instruction)> _functions = new();
private readonly Dictionary<AstOperand, Instruction> _locals = [];
private readonly Dictionary<int, Instruction> _funcArgs = [];
private readonly Dictionary<int, (StructuredFunction, Instruction)> _functions = [];
private class BlockState
{
private int _entryCount;
private readonly List<Instruction> _labels = new();
private readonly List<Instruction> _labels = [];
public Instruction GetNextLabel(CodeGenContext context)
{
@@ -73,7 +73,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
}
}
private readonly Dictionary<AstBlock, BlockState> _labels = new();
private readonly Dictionary<AstBlock, BlockState> _labels = [];
public Dictionary<AstBlock, (Instruction, Instruction)> LoopTargets { get; set; }
@@ -147,14 +147,15 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
public Instruction[] GetMainInterface()
{
var mainInterface = new List<Instruction>();
List<Instruction> mainInterface =
[
.. Inputs.Values,
.. Outputs.Values,
.. InputsPerPatch.Values,
.. OutputsPerPatch.Values,
];
mainInterface.AddRange(Inputs.Values);
mainInterface.AddRange(Outputs.Values);
mainInterface.AddRange(InputsPerPatch.Values);
mainInterface.AddRange(OutputsPerPatch.Values);
return mainInterface.ToArray();
return [.. mainInterface];
}
public void DeclareLocal(AstOperand local, Instruction spvLocal)

View File

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

View File

@@ -1242,11 +1242,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
if (hasDerivatives)
{
derivatives = new[]
{
derivatives =
[
AssembleDerivativesVector(coordsCount), // dPdx
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),
};
];
}
SpvInstruction lodBias = null;
@@ -1327,7 +1327,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
compIdx = Src(AggregateType.S32);
}
var operandsList = new List<SpvInstruction>();
List<SpvInstruction> operandsList = [];
var operandsMask = ImageOperandsMask.MaskNone;
if (hasLodBias)

View File

@@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
public PushOpInfo(InstOp op)
{
Op = op;
Consumers = new Dictionary<Block, Operand>();
Consumers = [];
}
}
@@ -45,12 +45,12 @@ namespace Ryujinx.Graphics.Shader.Decoders
{
Address = address;
Predecessors = new List<Block>();
Successors = new List<Block>();
Predecessors = [];
Successors = [];
OpCodes = new List<InstOp>();
PushOpCodes = new List<PushOpInfo>();
SyncTargets = new Dictionary<ulong, SyncTarget>();
OpCodes = [];
PushOpCodes = [];
SyncTargets = [];
}
public void Split(Block rightBlock)

View File

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

View File

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

View File

@@ -49,7 +49,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
{
Context context = new(gpuAccessor);
Queue<DecodedFunction> functionsQueue = new();
Dictionary<ulong, DecodedFunction> functionsVisited = new();
Dictionary<ulong, DecodedFunction> functionsVisited = [];
DecodedFunction EnqueueFunction(ulong address)
{
@@ -66,9 +66,9 @@ namespace Ryujinx.Graphics.Shader.Decoders
while (functionsQueue.TryDequeue(out DecodedFunction currentFunction))
{
List<Block> blocks = new();
List<Block> blocks = [];
Queue<Block> workQueue = new();
Dictionary<ulong, Block> visited = new();
Dictionary<ulong, Block> visited = [];
Block GetBlock(ulong blkAddress)
{
@@ -194,7 +194,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
}
while (hasNewTarget);
currentFunction.SetBlocks(blocks.ToArray());
currentFunction.SetBlocks([.. blocks]);
}
return new DecodedProgram(
@@ -251,7 +251,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
{
ulong address = block.Address;
int bufferOffset = 0;
ReadOnlySpan<ulong> buffer = ReadOnlySpan<ulong>.Empty;
ReadOnlySpan<ulong> buffer = [];
InstOp op = default;
@@ -520,7 +520,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
if (lastOp.Name == InstName.Brx && block.Successors.Count == (hasNext ? 1 : 0))
{
HashSet<ulong> visited = new();
HashSet<ulong> visited = [];
InstBrx opBrx = new(lastOp.RawOpCode);
ulong baseOffset = lastOp.GetAbsoluteAddress();
@@ -566,7 +566,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
// On a successful match, "BaseOffset" is the offset in bytes where the jump offsets are
// located on the constant buffer, and "UpperBound" is the total number of offsets for the BRX, minus 1.
HashSet<Block> visited = new();
HashSet<Block> visited = [];
var ldcLocation = FindFirstRegWrite(visited, new BlockLocation(block, block.OpCodes.Count - 1), brxReg);
if (ldcLocation.Block == null || ldcLocation.Block.OpCodes[ldcLocation.Index].Name != InstName.Ldc)
@@ -752,7 +752,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
Block target = blocks[pushOp.GetAbsoluteAddress()];
Stack<PathBlockState> workQueue = new();
HashSet<Block> visited = new();
HashSet<Block> visited = [];
Stack<(ulong, MergeType)> branchStack = new();
void Push(PathBlockState pbs)

View File

@@ -472,7 +472,7 @@ namespace Ryujinx.Graphics.Shader
/// <returns>Varying locations for the specified buffer</returns>
ReadOnlySpan<byte> QueryTransformFeedbackVaryingLocations(int bufferIndex)
{
return ReadOnlySpan<byte>.Empty;
return [];
}
/// <summary>

View File

@@ -464,10 +464,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
int rd,
bool boolFloat)
{
Operand[] res = new Operand[2];
res[0] = GetFPComparison(context, cmpOp, srcA[0], srcB[0]);
res[1] = GetFPComparison(context, cmpOp, srcA[1], srcB[1]);
Operand[] res = [GetFPComparison(context, cmpOp, srcA[0], srcB[0]), GetFPComparison(context, cmpOp, srcA[1], srcB[1])];
Operand pred = GetPredicate(context, srcPred, srcPredInv);

View File

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

View File

@@ -221,7 +221,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand d = Register(dest, RegisterType.Gpr);
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -269,7 +269,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
sourcesList.Add(Rb());
Operand[] sources = sourcesList.ToArray();
Operand[] sources = [.. sourcesList];
TextureFlags flags = compareAndSwap ? TextureFlags.CAS : GetAtomicOpFlags(atomicOp);
@@ -328,7 +328,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcA++, RegisterType.Gpr));
}
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -355,7 +355,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
sourcesList.Add(Ra());
}
Operand[] sources = sourcesList.ToArray();
Operand[] sources = [.. sourcesList];
int handle = imm;
@@ -500,7 +500,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcB++, RegisterType.Gpr));
}
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -543,7 +543,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
sourcesList.Add(Rb());
Operand[] sources = sourcesList.ToArray();
Operand[] sources = [.. sourcesList];
TextureFlags flags = GetAtomicOpFlags((SuatomOp)atomicOp);
@@ -605,7 +605,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcB++, RegisterType.Gpr));
}
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -668,7 +668,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
format = GetTextureFormat(size);
}
Operand[] sources = sourcesList.ToArray();
Operand[] sources = [.. sourcesList];
int handle = imm;

View File

@@ -10,11 +10,11 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
static partial class InstEmit
{
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 },
};
private static readonly int[][] _maskLut =
[
[0b0001, 0b0010, 0b0100, 0b1000, 0b0011, 0b1001, 0b1010, 0b1100],
[0b0111, 0b1011, 0b1101, 0b1110, 0b1111, 0b0000, 0b0000, 0b0000],
];
public const bool Sample1DAs2D = true;
@@ -202,7 +202,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand arrayIndex = isArray ? Ra() : null;
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -298,7 +298,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
type |= SamplerType.Multisample;
}
Operand[] sources = sourcesList.ToArray();
Operand[] sources = [.. sourcesList];
Operand[] dests = new Operand[BitOperations.PopCount((uint)componentMask)];
int outputIndex = 0;
@@ -339,7 +339,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return;
}
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
Operand Ra()
{
@@ -603,10 +603,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
throw new ArgumentException($"Invalid TEXS type \"{texsType}\".");
}
Operand[] sources = sourcesList.ToArray();
Operand[] sources = [.. sourcesList];
Operand[] rd0 = new Operand[2] { ConstF(0), ConstF(0) };
Operand[] rd1 = new Operand[2] { ConstF(0), ConstF(0) };
Operand[] rd0 = [ConstF(0), ConstF(0)];
Operand[] rd1 = [ConstF(0), ConstF(0)];
int handle = imm;
int componentMask = _maskLut[dest2 == RegisterConsts.RegisterZeroIndex ? 0 : 1][writeMask];
@@ -701,7 +701,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand arrayIndex = isArray ? Ra() : null;
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
SamplerType type = ConvertSamplerType(dimensions);
TextureFlags flags = TextureFlags.Gather;
@@ -775,7 +775,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
sourcesList.Add(Const((int)component));
}
Operand[] sources = sourcesList.ToArray();
Operand[] sources = [.. sourcesList];
Operand[] dests = new Operand[BitOperations.PopCount((uint)componentMask)];
int outputIndex = 0;
@@ -835,7 +835,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
TextureFlags flags = TextureFlags.None;
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -873,7 +873,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
sourcesList.Add(arrayIndex);
}
Operand[] sources = sourcesList.ToArray();
Operand[] sources = [.. sourcesList];
Operand GetDest()
{
@@ -963,7 +963,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
TextureFlags flags = TextureFlags.Derivatives;
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -1029,7 +1029,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
flags |= TextureFlags.Offset;
}
Operand[] sources = sourcesList.ToArray();
Operand[] sources = [.. sourcesList];
Operand[] dests = new Operand[BitOperations.PopCount((uint)componentMask)];
int outputIndex = 0;
@@ -1076,7 +1076,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcA++, RegisterType.Gpr));
}
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -1085,7 +1085,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
sourcesList.Add(Ra());
Operand[] sources = sourcesList.ToArray();
Operand[] sources = [.. sourcesList];
Operand GetDest()
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -60,7 +60,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
private static void PropagateExpression(AstOperand propVar, IAstNode source)
{
IAstNode[] uses = propVar.Uses.ToArray();
IAstNode[] uses = [.. propVar.Uses];
foreach (IAstNode useNode in uses)
{

View File

@@ -429,7 +429,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
AstBlock block = bottom;
List<AstBlock> path = new();
List<AstBlock> path = [];
while (block != top)
{
@@ -438,7 +438,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
block = block.Parent;
}
return path.ToArray();
return [.. path];
}
private static int Level(IAstNode node)

View File

@@ -20,12 +20,12 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
public ShaderProperties()
{
_constantBuffers = new Dictionary<int, BufferDefinition>();
_storageBuffers = new Dictionary<int, BufferDefinition>();
_textures = new Dictionary<SetBindingPair, TextureDefinition>();
_images = new Dictionary<SetBindingPair, TextureDefinition>();
_localMemories = new Dictionary<int, MemoryDefinition>();
_sharedMemories = new Dictionary<int, MemoryDefinition>();
_constantBuffers = [];
_storageBuffers = [];
_textures = [];
_images = [];
_localMemories = [];
_sharedMemories = [];
}
public void AddOrUpdateConstantBuffer(BufferDefinition definition)

View File

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

View File

@@ -354,7 +354,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
private static AggregateType GetVarTypeFromUses(Operand dest)
{
HashSet<Operand> visited = new();
HashSet<Operand> visited = [];
Queue<Operand> pending = new();

View File

@@ -70,15 +70,15 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
AggregateType[] inArguments,
AggregateType[] outArguments)
{
_loopTails = new HashSet<BasicBlock>();
_loopTails = [];
_blockStack = new Stack<(AstBlock, int, int)>();
_localsMap = new Dictionary<Operand, AstOperand>();
_localsMap = [];
_gotoTempAsgs = new Dictionary<int, AstAssignment>();
_gotoTempAsgs = [];
_gotos = new List<GotoStatement>();
_gotos = [];
_currBlock = new AstBlock(AstBlockType.Main);
@@ -289,7 +289,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
public GotoStatement[] GetGotos()
{
return _gotos.ToArray();
return [.. _gotos];
}
public AstOperand NewTemp(AggregateType type)
@@ -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),
};
];
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)
{
Functions = new List<StructuredFunction>();
Functions = [];
IoDefinitions = new HashSet<IoDefinition>();
IoDefinitions = [];
if (precise)
{

View File

@@ -72,8 +72,8 @@ 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"),
@@ -82,7 +82,7 @@ namespace Ryujinx.Graphics.Shader
new StructureField(AggregateType.Array | AggregateType.FP32, "render_scale", RenderScaleMaxCount),
new StructureField(AggregateType.Vector4 | AggregateType.S32, "tfe_offset"),
new StructureField(AggregateType.S32, "tfe_vertex_count"),
});
]);
}
public Vector4<int> FragmentAlphaTest;

View File

@@ -25,8 +25,8 @@ namespace Ryujinx.Graphics.Shader.Translation
{
_gpuAccessor = gpuAccessor;
UsedInputAttributesPerPatch = new();
UsedOutputAttributesPerPatch = new();
UsedInputAttributesPerPatch = [];
UsedOutputAttributesPerPatch = [];
}
public void SetInputUserAttribute(int index, int component)
@@ -65,7 +65,7 @@ namespace Ryujinx.Graphics.Shader.Translation
// Regular and per-patch input/output locations can't overlap,
// so we must assign on our location using unused regular input/output locations.
Dictionary<int, int> locationsMap = new();
Dictionary<int, int> locationsMap = [];
int freeMask = ~UsedOutputAttributes;

View File

@@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Shader.Translation
{
Blocks = blocks;
HashSet<BasicBlock> visited = new();
HashSet<BasicBlock> visited = [];
Stack<BasicBlock> blockStack = new();
@@ -45,14 +45,14 @@ namespace Ryujinx.Graphics.Shader.Translation
}
}
PostOrderBlocks = postOrderBlocks.ToArray();
PostOrderBlocks = [.. postOrderBlocks];
}
public static ControlFlowGraph Create(Operation[] operations)
{
Dictionary<Operand, BasicBlock> labels = new();
Dictionary<Operand, BasicBlock> labels = [];
List<BasicBlock> blocks = new();
List<BasicBlock> blocks = [];
BasicBlock currentBlock = null;
@@ -154,7 +154,7 @@ namespace Ryujinx.Graphics.Shader.Translation
}
} while (hasUnreachable);
return new ControlFlowGraph(blocks.ToArray());
return new ControlFlowGraph([.. blocks]);
}
private static bool EndsWithUnconditionalInst(INode node)

View File

@@ -53,8 +53,8 @@ namespace Ryujinx.Graphics.Shader.Translation
public EmitterContext()
{
_operations = new List<Operation>();
_labels = new Dictionary<ulong, BlockLabel>();
_operations = [];
_labels = [];
}
public EmitterContext(
@@ -126,8 +126,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));
@@ -147,8 +147,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);
}
@@ -186,7 +186,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);
@@ -621,7 +621,7 @@ namespace Ryujinx.Graphics.Shader.Translation
public Operation[] GetOperations()
{
return _operations.ToArray();
return [.. _operations];
}
}
}

View File

@@ -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;

View File

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

View File

@@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Shader.Translation
public HelperFunctionManager(List<Function> functionList, ShaderStage stage)
{
_functionList = functionList;
_functionIds = new Dictionary<int, int>();
_functionIds = [];
_stage = stage;
}

View File

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

View File

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

View File

@@ -134,7 +134,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
Operand dest = copyOp.Dest;
Operand src = copyOp.GetSource(0);
INode[] uses = dest.UseOps.ToArray();
INode[] uses = [.. dest.UseOps];
foreach (INode useNode in uses)
{
@@ -162,7 +162,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
Operand firstSrc = phi.GetSource(0);
Operand dest = phi.Dest;
INode[] uses = dest.UseOps.ToArray();
INode[] uses = [.. dest.UseOps];
foreach (INode useNode in uses)
{
@@ -188,7 +188,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
Operand src0 = packOp.GetSource(0);
Operand src1 = packOp.GetSource(1);
INode[] uses = dest.UseOps.ToArray();
INode[] uses = [.. dest.UseOps];
foreach (INode useNode in uses)
{
@@ -237,7 +237,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
// - The mask should be 0b10100101 for DDY, or 0b10011001 for DDX.
// - The first source operand must be the shuffle output.
// - The second source operand must be the shuffle first source operand.
INode[] uses = operation.Dest.UseOps.ToArray();
INode[] uses = [.. operation.Dest.UseOps];
foreach (INode use in uses)
{

View File

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

View File

@@ -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;
@@ -75,18 +75,18 @@ namespace Ryujinx.Graphics.Shader.Translation
_cbSlotToBindingMap.AsSpan().Fill(new(-1, -1));
_sbSlotToBindingMap.AsSpan().Fill(new(-1, -1));
_sbSlots = new();
_sbSlotsReverse = new();
_sbSlots = [];
_sbSlotsReverse = [];
_usedConstantBufferBindings = new();
_usedConstantBufferBindings = [];
_usedTextures = new();
_usedImages = new();
_usedTextures = [];
_usedImages = [];
_vacConstantBuffers = new();
_vacStorageBuffers = new();
_vacTextures = new();
_vacImages = new();
_vacConstantBuffers = [];
_vacStorageBuffers = [];
_vacTextures = [];
_vacImages = [];
Properties.AddOrUpdateConstantBuffer(new(BufferLayout.Std140, 0, SupportBuffer.Binding, "support_buffer", SupportBuffer.GetStructureType()));
@@ -524,7 +524,7 @@ namespace Ryujinx.Graphics.Shader.Translation
private static TextureDescriptor[] GetDescriptors(IReadOnlyDictionary<TextureInfo, TextureMeta> usedResources, bool includeArrays)
{
List<TextureDescriptor> descriptors = new();
List<TextureDescriptor> descriptors = [];
bool hasAnyArray = false;
@@ -570,7 +570,7 @@ namespace Ryujinx.Graphics.Shader.Translation
}
}
return descriptors.ToArray();
return [.. descriptors];
}
public ShaderProgramInfo GetVertexAsComputeInfo(bool isVertex = false)
@@ -690,20 +690,20 @@ namespace Ryujinx.Graphics.Shader.Translation
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),
});
]);
Properties.AddOrUpdateConstantBuffer(new(BufferLayout.Std140, setIndex, binding, name, type));
}
private void AddNewStorageBuffer(int setIndex, int binding, string name)
{
StructureType type = new(new[]
{
StructureType type = new(
[
new StructureField(AggregateType.Array | AggregateType.U32, "data", 0),
});
]);
Properties.AddOrUpdateStorageBuffer(new(BufferLayout.Std430, setIndex, binding, name, type));
}

View File

@@ -80,7 +80,7 @@ namespace Ryujinx.Graphics.Shader.Translation
{
if (vertexAsCompute)
{
_offsets = new();
_offsets = [];
if (vacInput.HasValue)
{

View File

@@ -104,7 +104,7 @@ namespace Ryujinx.Graphics.Shader.Translation
Stage = stage;
TransformFeedbackEnabled = transformFeedbackOutputs != null;
_transformFeedbackOutputs = transformFeedbackOutputs;
_transformFeedbackDefinitions = new();
_transformFeedbackDefinitions = [];
PopulateTransformFeedbackDefinitions(transformFeedbackVecMap, transformFeedbackOutputs);
}
@@ -166,7 +166,7 @@ namespace Ryujinx.Graphics.Shader.Translation
SupportsScaledVertexFormats = supportsScaledVertexFormats;
TransformFeedbackEnabled = transformFeedbackOutputs != null;
_transformFeedbackOutputs = transformFeedbackOutputs;
_transformFeedbackDefinitions = new();
_transformFeedbackDefinitions = [];
PopulateTransformFeedbackDefinitions(transformFeedbackVecMap, transformFeedbackOutputs);
}

View File

@@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Shader.Translation
public DefMap()
{
_map = new Dictionary<Register, Operand>();
_map = [];
_phiMasks = new long[(RegisterConsts.TotalCount + 63) / 64];
}

View File

@@ -49,7 +49,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Load,
StorageKind.StorageBuffer,
operation.Dest,
new[] { Const(context.ResourceManager.Reservations.VertexOutputStorageBufferBinding), Const(0), vertexElemOffset }));
[Const(context.ResourceManager.Reservations.VertexOutputStorageBufferBinding), Const(0), vertexElemOffset]));
}
else
{
@@ -84,7 +84,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Load,
StorageKind.LocalMemory,
operation.Dest,
new[] { Const(context.ResourceManager.LocalVertexDataMemoryId), Const(outputOffset) }));
[Const(context.ResourceManager.LocalVertexDataMemoryId), Const(outputOffset)]));
}
else
{
@@ -103,7 +103,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Store,
StorageKind.LocalMemory,
(Operand)null,
new[] { Const(context.ResourceManager.LocalVertexDataMemoryId), Const(outputOffset), value }));
[Const(context.ResourceManager.LocalVertexDataMemoryId), Const(outputOffset), value]));
}
else
{
@@ -134,7 +134,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
definitions.MaxOutputVertices * definitions.ThreadsPerInputPrimitive,
definitions.ThreadsPerInputPrimitive);
Operand outputBaseVertex = Local();
node.List.AddBefore(node, new Operation(Instruction.Add, outputBaseVertex, new[] { baseVertexOffset, outputPrimVertex }));
node.List.AddBefore(node, new Operation(Instruction.Add, outputBaseVertex, [baseVertexOffset, outputPrimVertex]));
Operand outputPrimIndex = IncrementLocalMemory(node, resourceManager.LocalGeometryOutputIndexCountMemoryId);
Operand baseIndexOffset = GenerateBaseOffset(
@@ -143,16 +143,16 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
definitions.GetGeometryOutputIndexBufferStride(),
definitions.ThreadsPerInputPrimitive);
Operand outputBaseIndex = Local();
node.List.AddBefore(node, new Operation(Instruction.Add, outputBaseIndex, new[] { baseIndexOffset, outputPrimIndex }));
node.List.AddBefore(node, new Operation(Instruction.Add, outputBaseIndex, [baseIndexOffset, outputPrimIndex]));
node.List.AddBefore(node, new Operation(
Instruction.Store,
StorageKind.StorageBuffer,
null,
new[] { Const(ibOutputBinding), Const(0), outputBaseIndex, outputBaseVertex }));
[Const(ibOutputBinding), Const(0), outputBaseIndex, outputBaseVertex]));
Operand baseOffset = Local();
node.List.AddBefore(node, new Operation(Instruction.Multiply, baseOffset, new[] { outputBaseVertex, Const(stride) }));
node.List.AddBefore(node, new Operation(Instruction.Multiply, baseOffset, [outputBaseVertex, Const(stride)]));
LinkedListNode<INode> newNode = node;
@@ -163,7 +163,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
if (offset > 0)
{
vertexOffset = Local();
node.List.AddBefore(node, new Operation(Instruction.Add, vertexOffset, new[] { baseOffset, Const(offset) }));
node.List.AddBefore(node, new Operation(Instruction.Add, vertexOffset, [baseOffset, Const(offset)]));
}
else
{
@@ -175,13 +175,13 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Load,
StorageKind.LocalMemory,
value,
new[] { Const(resourceManager.LocalVertexDataMemoryId), Const(offset) }));
[Const(resourceManager.LocalVertexDataMemoryId), Const(offset)]));
newNode = node.List.AddBefore(node, new Operation(
Instruction.Store,
StorageKind.StorageBuffer,
null,
new[] { Const(vbOutputBinding), Const(0), vertexOffset, value }));
[Const(vbOutputBinding), Const(0), vertexOffset, value]));
}
return newNode;
@@ -198,13 +198,13 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
definitions.GetGeometryOutputIndexBufferStride(),
definitions.ThreadsPerInputPrimitive);
Operand outputBaseIndex = Local();
node.List.AddBefore(node, new Operation(Instruction.Add, outputBaseIndex, new[] { baseIndexOffset, outputPrimIndex }));
node.List.AddBefore(node, new Operation(Instruction.Add, outputBaseIndex, [baseIndexOffset, outputPrimIndex]));
return node.List.AddBefore(node, new Operation(
Instruction.Store,
StorageKind.StorageBuffer,
null,
new[] { Const(ibOutputBinding), Const(0), outputBaseIndex, Const(-1) }));
[Const(ibOutputBinding), Const(0), outputBaseIndex, Const(-1)]));
}
private static Operand GenerateBaseOffset(ResourceManager resourceManager, LinkedListNode<INode> node, int stride, int threadsPerInputPrimitive)
@@ -213,16 +213,16 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
GeneratePrimitiveId(resourceManager, node, primitiveId);
Operand baseOffset = Local();
node.List.AddBefore(node, new Operation(Instruction.Multiply, baseOffset, new[] { primitiveId, Const(stride) }));
node.List.AddBefore(node, new Operation(Instruction.Multiply, baseOffset, [primitiveId, Const(stride)]));
Operand invocationId = Local();
GenerateInvocationId(node, invocationId);
Operand invocationOffset = Local();
node.List.AddBefore(node, new Operation(Instruction.Multiply, invocationOffset, new[] { invocationId, Const(stride / threadsPerInputPrimitive) }));
node.List.AddBefore(node, new Operation(Instruction.Multiply, invocationOffset, [invocationId, Const(stride / threadsPerInputPrimitive)]));
Operand combinedOffset = Local();
node.List.AddBefore(node, new Operation(Instruction.Add, combinedOffset, new[] { baseOffset, invocationOffset }));
node.List.AddBefore(node, new Operation(Instruction.Add, combinedOffset, [baseOffset, invocationOffset]));
return combinedOffset;
}
@@ -234,12 +234,12 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Load,
StorageKind.LocalMemory,
oldValue,
new[] { Const(memoryId) }));
[Const(memoryId)]));
Operand newValue = Local();
node.List.AddBefore(node, new Operation(Instruction.Add, newValue, new[] { oldValue, Const(1) }));
node.List.AddBefore(node, new Operation(Instruction.Add, newValue, [oldValue, Const(1)]));
node.List.AddBefore(node, new Operation(Instruction.Store, StorageKind.LocalMemory, null, new[] { Const(memoryId), newValue }));
node.List.AddBefore(node, new Operation(Instruction.Store, StorageKind.LocalMemory, null, [Const(memoryId), newValue]));
return oldValue;
}
@@ -257,33 +257,33 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Load,
StorageKind.ConstantBuffer,
vertexCount,
new[] { Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexCounts), Const(0) }));
[Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexCounts), Const(0)]));
Operand primInputVertex = Local();
node.List.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.LocalMemory,
primInputVertex,
new[] { Const(resourceManager.LocalTopologyRemapMemoryId), primVertex }));
[Const(resourceManager.LocalTopologyRemapMemoryId), primVertex]));
Operand instanceIndex = Local();
node.List.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.Input,
instanceIndex,
new[] { Const((int)IoVariable.GlobalId), Const(1) }));
[Const((int)IoVariable.GlobalId), Const(1)]));
Operand baseVertex = Local();
node.List.AddBefore(node, new Operation(Instruction.Multiply, baseVertex, new[] { instanceIndex, vertexCount }));
node.List.AddBefore(node, new Operation(Instruction.Multiply, baseVertex, [instanceIndex, vertexCount]));
Operand vertexIndex = Local();
node.List.AddBefore(node, new Operation(Instruction.Add, vertexIndex, new[] { baseVertex, primInputVertex }));
node.List.AddBefore(node, new Operation(Instruction.Add, vertexIndex, [baseVertex, primInputVertex]));
Operand vertexBaseOffset = Local();
node.List.AddBefore(node, new Operation(
Instruction.Multiply,
vertexBaseOffset,
new[] { vertexIndex, Const(resourceManager.Reservations.InputSizePerInvocation) }));
[vertexIndex, Const(resourceManager.Reservations.InputSizePerInvocation)]));
Operand vertexElemOffset;
@@ -291,7 +291,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
vertexElemOffset = Local();
node.List.AddBefore(node, new Operation(Instruction.Add, vertexElemOffset, new[] { vertexBaseOffset, Const(elementOffset) }));
node.List.AddBefore(node, new Operation(Instruction.Add, vertexElemOffset, [vertexBaseOffset, Const(elementOffset)]));
}
else
{
@@ -310,26 +310,26 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Load,
StorageKind.ConstantBuffer,
vertexCount,
new[] { Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexCounts), Const(0) }));
[Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexCounts), Const(0)]));
Operand vertexIndex = Local();
node.List.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.Input,
vertexIndex,
new[] { Const((int)IoVariable.GlobalId), Const(0) }));
[Const((int)IoVariable.GlobalId), Const(0)]));
Operand instanceIndex = Local();
node.List.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.Input,
instanceIndex,
new[] { Const((int)IoVariable.GlobalId), Const(1) }));
[Const((int)IoVariable.GlobalId), Const(1)]));
Operand baseVertex = Local();
node.List.AddBefore(node, new Operation(Instruction.Multiply, baseVertex, new[] { instanceIndex, vertexCount }));
node.List.AddBefore(node, new Operation(Instruction.Multiply, baseVertex, [instanceIndex, vertexCount]));
return node.List.AddBefore(node, new Operation(Instruction.Add, dest, new[] { baseVertex, vertexIndex }));
return node.List.AddBefore(node, new Operation(Instruction.Add, dest, [baseVertex, vertexIndex]));
}
private static LinkedListNode<INode> GenerateInvocationId(LinkedListNode<INode> node, Operand dest)
@@ -338,7 +338,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Load,
StorageKind.Input,
dest,
new[] { Const((int)IoVariable.GlobalId), Const(2) }));
[Const((int)IoVariable.GlobalId), Const(2)]));
}
private static bool TryGetOffset(ResourceManager resourceManager, Operation operation, StorageKind storageKind, out int outputOffset)

View File

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

View File

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

View File

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

View File

@@ -71,11 +71,11 @@ 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 +127,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 +175,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
Operand coordSize = Local();
Operand[] texSizeSources = new Operand[] { Const(0) };
Operand[] texSizeSources = [Const(0)];
LinkedListNode<INode> textureSizeNode = node.List.AddBefore(node, new TextureOperation(
Instruction.TextureQuerySize,
@@ -185,7 +185,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
texOp.Set,
texOp.Binding,
index,
new[] { coordSize },
[coordSize],
texSizeSources));
resourceManager.SetUsageFlagsForTextureQuery(texOp.Binding, texOp.Type);
@@ -240,11 +240,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 +255,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
texOp.Set,
texOp.Binding,
index,
new[] { coordSize },
[coordSize],
texSizeSources));
node.List.AddBefore(node, new Operation(
@@ -476,7 +476,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 +565,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 +580,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
texOp.Set,
texOp.Binding,
index,
new[] { texSizes[index] },
[texSizes[index]],
texSizeSources));
}
@@ -611,7 +611,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
texOp.Set,
texOp.Binding,
0,
new[] { lod },
[lod],
lodSources));
}
else
@@ -627,11 +627,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 +642,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
texOp.Set,
texOp.Binding,
index,
new[] { texSizes[index] },
[texSizes[index]],
texSizeSources));
}
@@ -686,7 +686,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
Operand dest = texOp.GetDest(i);
INode[] uses = dest.UseOps.ToArray();
INode[] uses = [.. dest.UseOps];
Operation convOp = new(Instruction.ConvertS32ToFP32, Local(), dest);
Operation normOp = new(Instruction.FP32 | Instruction.Multiply, Local(), convOp.Dest, ConstF(1f / maxPositive));

View File

@@ -78,8 +78,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Operand isCurrentIndex = Local();
Operand selection = Local();
Operation compareOp = new(Instruction.CompareEqual, isCurrentIndex, new Operand[] { elemIndex, Const(i) });
Operation selectOp = new(Instruction.ConditionalSelect, selection, new Operand[] { isCurrentIndex, value, result });
Operation compareOp = new(Instruction.CompareEqual, isCurrentIndex, [elemIndex, Const(i)]);
Operation selectOp = new(Instruction.ConditionalSelect, selection, [isCurrentIndex, value, result]);
node.List.AddBefore(node, compareOp);
node.List.AddBefore(node, selectOp);

View File

@@ -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)
{
@@ -120,7 +120,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Load,
StorageKind.LocalMemory,
operation.Dest,
new[] { Const(context.ResourceManager.LocalVertexDataMemoryId), Const(outputOffset) }));
[Const(context.ResourceManager.LocalVertexDataMemoryId), Const(outputOffset)]));
}
else
{
@@ -137,7 +137,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Store,
StorageKind.LocalMemory,
(Operand)null,
new[] { Const(context.ResourceManager.LocalVertexDataMemoryId), Const(outputOffset), value }));
[Const(context.ResourceManager.LocalVertexDataMemoryId), Const(outputOffset), value]));
}
else
{
@@ -168,33 +168,33 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Load,
StorageKind.ConstantBuffer,
attributeOffset,
new[] { Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexOffsets), Const(location), Const(0) }));
[Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexOffsets), Const(location), Const(0)]));
Operand isInstanceRate = Local();
node.List.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.ConstantBuffer,
isInstanceRate,
new[] { Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexOffsets), Const(location), Const(1) }));
[Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexOffsets), Const(location), Const(1)]));
Operand vertexId = Local();
node.List.AddBefore(node, new Operation(
Instruction.ConditionalSelect,
vertexId,
new[] { isInstanceRate, vertexIdIr, vertexIdVr }));
[isInstanceRate, vertexIdIr, vertexIdVr]));
Operand vertexStride = Local();
node.List.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.ConstantBuffer,
vertexStride,
new[] { Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexStrides), Const(location), Const(0) }));
[Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexStrides), Const(location), Const(0)]));
Operand vertexBaseOffset = Local();
node.List.AddBefore(node, new Operation(Instruction.Multiply, vertexBaseOffset, new[] { vertexId, vertexStride }));
node.List.AddBefore(node, new Operation(Instruction.Multiply, vertexBaseOffset, [vertexId, vertexStride]));
Operand vertexOffset = Local();
node.List.AddBefore(node, new Operation(Instruction.Add, vertexOffset, new[] { attributeOffset, vertexBaseOffset }));
node.List.AddBefore(node, new Operation(Instruction.Add, vertexOffset, [attributeOffset, vertexBaseOffset]));
Operand vertexElemOffset;
@@ -202,7 +202,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
vertexElemOffset = Local();
node.List.AddBefore(node, new Operation(Instruction.Add, vertexElemOffset, new[] { vertexOffset, Const(component) }));
node.List.AddBefore(node, new Operation(Instruction.Add, vertexElemOffset, [vertexOffset, Const(component)]));
}
else
{
@@ -218,22 +218,22 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
node = node.List.AddAfter(node, new Operation(
Instruction.ShiftLeft,
leftShifted,
new[] { src, Const(32 - bits) }));
[src, Const(32 - bits)]));
Operand rightShifted = normalize ? Local() : dest;
node = node.List.AddAfter(node, new Operation(
Instruction.ShiftRightS32,
rightShifted,
new[] { leftShifted, Const(32 - bits) }));
[leftShifted, Const(32 - bits)]));
if (normalize)
{
Operand asFloat = Local();
node = node.List.AddAfter(node, new Operation(Instruction.ConvertS32ToFP32, asFloat, new[] { rightShifted }));
node = node.List.AddAfter(node, new Operation(Instruction.ConvertS32ToFP32, asFloat, [rightShifted]));
node = node.List.AddAfter(node, new Operation(
Instruction.FP32 | Instruction.Multiply,
dest,
new[] { asFloat, ConstF(1f / (1 << (bits - 1))) }));
[asFloat, ConstF(1f / (1 << (bits - 1)))]));
}
return node;
@@ -253,12 +253,12 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Load,
StorageKind.ConstantBuffer,
componentExists,
new[] { Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexStrides), Const(location), Const(component) }));
[Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexStrides), Const(location), Const(component)]));
return node.List.AddAfter(node, new Operation(
Instruction.ConditionalSelect,
dest,
new[] { componentExists, src, ConstF(component == 3 ? 1f : 0f) }));
[componentExists, src, ConstF(component == 3 ? 1f : 0f)]));
}
private static LinkedListNode<INode> GenerateBaseVertexLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
@@ -269,7 +269,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Load,
StorageKind.ConstantBuffer,
dest,
new[] { Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexCounts), Const(2) }));
[Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexCounts), Const(2)]));
}
private static LinkedListNode<INode> GenerateBaseInstanceLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
@@ -280,7 +280,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Load,
StorageKind.ConstantBuffer,
dest,
new[] { Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexCounts), Const(3) }));
[Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexCounts), Const(3)]));
}
private static LinkedListNode<INode> GenerateVertexIndexLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
@@ -291,7 +291,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
GenerateBaseVertexLoad(resourceManager, node, baseVertex);
GenerateVertexIdVertexRateLoad(resourceManager, node, vertexId);
return node.List.AddBefore(node, new Operation(Instruction.Add, dest, new[] { baseVertex, vertexId }));
return node.List.AddBefore(node, new Operation(Instruction.Add, dest, [baseVertex, vertexId]));
}
private static LinkedListNode<INode> GenerateInstanceIndexLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
@@ -305,28 +305,28 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Instruction.Load,
StorageKind.Input,
instanceId,
new[] { Const((int)IoVariable.GlobalId), Const(1) }));
[Const((int)IoVariable.GlobalId), Const(1)]));
return node.List.AddBefore(node, new Operation(Instruction.Add, dest, new[] { baseInstance, instanceId }));
return node.List.AddBefore(node, new Operation(Instruction.Add, dest, [baseInstance, instanceId]));
}
private static LinkedListNode<INode> GenerateVertexIdVertexRateLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
{
Operand[] sources = new Operand[] { Const(resourceManager.LocalVertexIndexVertexRateMemoryId) };
Operand[] sources = [Const(resourceManager.LocalVertexIndexVertexRateMemoryId)];
return node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.LocalMemory, dest, sources));
}
private static LinkedListNode<INode> GenerateVertexIdInstanceRateLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
{
Operand[] sources = new Operand[] { Const(resourceManager.LocalVertexIndexInstanceRateMemoryId) };
Operand[] sources = [Const(resourceManager.LocalVertexIndexInstanceRateMemoryId)];
return node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.LocalMemory, dest, sources));
}
private static LinkedListNode<INode> GenerateInstanceIdLoad(LinkedListNode<INode> node, Operand dest)
{
Operand[] sources = new Operand[] { Const((int)IoVariable.GlobalId), Const(1) };
Operand[] sources = [Const((int)IoVariable.GlobalId), Const(1)];
return node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.Input, dest, sources));
}

View File

@@ -143,7 +143,7 @@ namespace Ryujinx.Graphics.Shader.Translation
ops.Add(operation);
}
output[0] = new FunctionCode(ops.ToArray());
output[0] = new FunctionCode([.. ops]);
for (int i = 1; i < a.Length; i++)
{
@@ -386,10 +386,10 @@ namespace Ryujinx.Graphics.Shader.Translation
if (IsTransformFeedbackEmulated)
{
StructureType tfeDataStruct = new(new StructureField[]
{
new StructureField(AggregateType.Array | AggregateType.U32, "data", 0)
});
StructureType tfeDataStruct = new(
[
new(AggregateType.Array | AggregateType.U32, "data", 0)
]);
for (int i = 0; i < ResourceReservations.TfeBuffersCount; i++)
{
@@ -405,10 +405,10 @@ namespace Ryujinx.Graphics.Shader.Translation
BufferDefinition vertexInfoBuffer = new(BufferLayout.Std140, 0, vertexInfoCbBinding, "vb_info", VertexInfoBuffer.GetStructureType());
resourceManager.AddVertexAsComputeConstantBuffer(vertexInfoBuffer);
StructureType vertexOutputStruct = new(new StructureField[]
{
new StructureField(AggregateType.Array | AggregateType.FP32, "data", 0)
});
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 +442,10 @@ namespace Ryujinx.Graphics.Shader.Translation
BufferDefinition geometryVbOutputBuffer = new(BufferLayout.Std430, 1, geometryVbOutputSbBinding, "geometry_vb_output", vertexOutputStruct);
resourceManager.AddVertexAsComputeStorageBuffer(geometryVbOutputBuffer);
StructureType geometryIbOutputStruct = new(new StructureField[]
{
new StructureField(AggregateType.Array | AggregateType.U32, "data", 0)
});
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 +507,10 @@ namespace Ryujinx.Graphics.Shader.Translation
resourceManager.AddVertexAsComputeConstantBuffer(vertexInfoBuffer);
}
StructureType vertexInputStruct = new(new StructureField[]
{
new StructureField(AggregateType.Array | AggregateType.FP32, "data", 0)
});
StructureType vertexInputStruct = new(
[
new(AggregateType.Array | AggregateType.FP32, "data", 0)
]);
int vertexDataSbBinding = reservations.VertexOutputStorageBufferBinding;
BufferDefinition vertexOutputBuffer = new(BufferLayout.Std430, 1, vertexDataSbBinding, "vb_input", vertexInputStruct);

View File

@@ -42,13 +42,13 @@ 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),
});
]);
}
public Vector4<int> VertexCounts;