misc: chore: Use collection expressions

This commit is contained in:
KeatonTheBot
2025-03-06 20:46:29 -06:00
parent 4d5757417e
commit e2973a875a
236 changed files with 9843 additions and 7561 deletions
@@ -1242,11 +1242,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
if (hasDerivatives)
{
derivatives = new[]
{
derivatives =
[
AssembleDerivativesVector(coordsCount), // dPdx
AssembleDerivativesVector(coordsCount), // dPdy
};
AssembleDerivativesVector(coordsCount) // dPdy
];
}
SpvInstruction sample = null;
@@ -1286,17 +1286,17 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
if (hasOffset)
{
offsets = new[] { AssembleOffsetVector(coordsCount) };
offsets = [AssembleOffsetVector(coordsCount)];
}
else if (hasOffsets)
{
offsets = new[]
{
offsets =
[
AssembleOffsetVector(coordsCount),
AssembleOffsetVector(coordsCount),
AssembleOffsetVector(coordsCount),
AssembleOffsetVector(coordsCount),
};
AssembleOffsetVector(coordsCount)
];
}
SpvInstruction lodBias = null;
@@ -107,11 +107,11 @@ namespace Ryujinx.Graphics.Shader.Instructions
ushort low = (ushort)(immH0 << 6);
ushort high = (ushort)(immH1 << 6);
return new Operand[]
{
return
[
ConstF((float)Unsafe.As<ushort, Half>(ref low)),
ConstF((float)Unsafe.As<ushort, Half>(ref high)),
};
ConstF((float)Unsafe.As<ushort, Half>(ref high))
];
}
public static Operand[] GetHalfSrc(EmitterContext context, int imm32)
@@ -119,11 +119,11 @@ namespace Ryujinx.Graphics.Shader.Instructions
ushort low = (ushort)imm32;
ushort high = (ushort)(imm32 >> 16);
return new Operand[]
{
return
[
ConstF((float)Unsafe.As<ushort, Half>(ref low)),
ConstF((float)Unsafe.As<ushort, Half>(ref high)),
};
ConstF((float)Unsafe.As<ushort, Half>(ref high))
];
}
public static Operand[] FPAbsNeg(EmitterContext context, Operand[] operands, bool abs, bool neg)
@@ -140,22 +140,22 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
return swizzle switch
{
HalfSwizzle.F16 => new Operand[]
{
context.UnpackHalf2x16Low (src),
context.UnpackHalf2x16High(src),
},
HalfSwizzle.F32 => new Operand[] { src, src },
HalfSwizzle.H0H0 => new Operand[]
{
context.UnpackHalf2x16Low(src),
context.UnpackHalf2x16Low(src),
},
HalfSwizzle.H1H1 => new Operand[]
{
context.UnpackHalf2x16High(src),
context.UnpackHalf2x16High(src),
},
HalfSwizzle.F16 =>
[
context.UnpackHalf2x16Low (src),
context.UnpackHalf2x16High(src)
],
HalfSwizzle.F32 => [src, src],
HalfSwizzle.H0H0 =>
[
context.UnpackHalf2x16Low(src),
context.UnpackHalf2x16Low(src)
],
HalfSwizzle.H1H1 =>
[
context.UnpackHalf2x16High(src),
context.UnpackHalf2x16High(src)
],
_ => throw new ArgumentException($"Invalid swizzle \"{swizzle}\"."),
};
}
@@ -12,8 +12,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
private static readonly int[][] _maskLut = new int[][]
{
new int[] { 0b0001, 0b0010, 0b0100, 0b1000, 0b0011, 0b1001, 0b1010, 0b1100 },
new int[] { 0b0111, 0b1011, 0b1101, 0b1110, 0b1111, 0b0000, 0b0000, 0b0000 },
[0b0001, 0b0010, 0b0100, 0b1000, 0b0011, 0b1001, 0b1010, 0b1100], [0b0111, 0b1011, 0b1101, 0b1110, 0b1111, 0b0000, 0b0000, 0b0000
],
};
public const bool Sample1DAs2D = true;
@@ -202,7 +202,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand arrayIndex = isArray ? Ra() : null;
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -339,7 +339,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return;
}
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
Operand Ra()
{
@@ -605,8 +605,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand[] sources = sourcesList.ToArray();
Operand[] rd0 = new Operand[2] { ConstF(0), ConstF(0) };
Operand[] rd1 = new Operand[2] { ConstF(0), ConstF(0) };
Operand[] rd0 = [ConstF(0), ConstF(0)];
Operand[] rd1 = [ConstF(0), ConstF(0)];
int handle = imm;
int componentMask = _maskLut[dest2 == RegisterConsts.RegisterZeroIndex ? 0 : 1][writeMask];
@@ -701,7 +701,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand arrayIndex = isArray ? Ra() : null;
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
SamplerType type = ConvertSamplerType(dimensions);
TextureFlags flags = TextureFlags.Gather;
@@ -835,7 +835,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
TextureFlags flags = TextureFlags.None;
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -963,7 +963,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
TextureFlags flags = TextureFlags.Derivatives;
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -1076,7 +1076,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcA++, RegisterType.Gpr));
}
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -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()
@@ -69,7 +69,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
AggregateType[] inArguments,
AggregateType[] outArguments)
{
_loopTails = new HashSet<BasicBlock>();
_loopTails = [];
_blockStack = new Stack<(AstBlock, int, int)>();
@@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
_gotoTempAsgs = new Dictionary<int, AstAssignment>();
_gotos = new List<GotoStatement>();
_gotos = [];
_currBlock = new AstBlock(AstBlockType.Main);
@@ -313,13 +313,13 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
ResourceManager.SetUsedConstantBufferBinding(binding);
IAstNode[] sources = new IAstNode[]
{
IAstNode[] sources =
[
new AstOperand(OperandType.Constant, binding),
new AstOperand(OperandType.Constant, 0),
new AstOperand(OperandType.Constant, vecIndex),
new AstOperand(OperandType.Constant, elemIndex),
};
new AstOperand(OperandType.Constant, elemIndex)
];
return new AstOperation(Instruction.Load, StorageKind.ConstantBuffer, false, sources, sources.Length);
}
+3 -4
View File
@@ -72,8 +72,7 @@ namespace Ryujinx.Graphics.Shader
internal static StructureType GetStructureType()
{
return new StructureType(new[]
{
return new StructureType([
new StructureField(AggregateType.U32, "alpha_test"),
new StructureField(AggregateType.Array | AggregateType.U32, "is_bgra", FragmentIsBgraCount),
new StructureField(AggregateType.Vector4 | AggregateType.FP32, "viewport_inverse"),
@@ -81,8 +80,8 @@ namespace Ryujinx.Graphics.Shader
new StructureField(AggregateType.S32, "frag_scale_count"),
new StructureField(AggregateType.Array | AggregateType.FP32, "render_scale", RenderScaleMaxCount),
new StructureField(AggregateType.Vector4 | AggregateType.S32, "tfe_offset"),
new StructureField(AggregateType.S32, "tfe_vertex_count"),
});
new StructureField(AggregateType.S32, "tfe_vertex_count")
]);
}
public Vector4<int> FragmentAlphaTest;
@@ -53,7 +53,7 @@ namespace Ryujinx.Graphics.Shader.Translation
public EmitterContext()
{
_operations = new List<Operation>();
_operations = [];
_labels = new Dictionary<ulong, BlockLabel>();
}
@@ -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);
@@ -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;
@@ -132,7 +132,7 @@ namespace Ryujinx.Graphics.Shader.Translation
public TreeNode(InstOp op, byte order)
{
Op = op;
Uses = new List<TreeNodeUse>();
Uses = [];
Type = TreeNodeType.Op;
Order = order;
}
@@ -150,7 +150,7 @@ namespace Ryujinx.Graphics.Shader.Translation
private static TreeNode[] BuildTree(Block[] blocks)
{
List<TreeNode> nodes = new();
List<TreeNode> nodes = [];
Dictionary<ulong, TreeNode> labels = new();
@@ -382,7 +382,7 @@ namespace Ryujinx.Graphics.Shader.Translation
Type = type;
Order = order;
IsImm = isImm;
Uses = new List<PatternTreeNodeUse>();
Uses = [];
}
public PatternTreeNode<T> Use(PatternTreeNodeUse use)
@@ -527,8 +527,8 @@ namespace Ryujinx.Graphics.Shader.Translation
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)
@@ -548,8 +548,8 @@ namespace Ryujinx.Graphics.Shader.Translation
.Use(PT)
.Use(orderingTicketValue).Out),
Iadd(x: true, 0, 405).Use(PT).Use(RZ),
Ret().Use(PT),
};
Ret().Use(PT)
];
}
public static IPatternTreeNode[] GetFsiGetAddressV2()
@@ -557,8 +557,8 @@ namespace Ryujinx.Graphics.Shader.Translation
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),
@@ -576,8 +576,8 @@ namespace Ryujinx.Graphics.Shader.Translation
.Use(PT)
.Use(orderingTicketValue).Out).Out),
Iadd(x: true, 0, 405).Use(PT).Use(RZ),
Ret().Use(PT),
};
Ret().Use(PT)
];
}
public static IPatternTreeNode[] GetFsiIsLastWarpThread()
@@ -585,8 +585,8 @@ namespace Ryujinx.Graphics.Shader.Translation
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)
@@ -603,8 +603,8 @@ namespace Ryujinx.Graphics.Shader.Translation
.Use(threadKillValue).OutAt(1))
.Use(RZ).Out).OutAt(1)).Out)
.Use(laneIdValue),
Ret().Use(PT),
};
Ret().Use(PT)
];
}
public static IPatternTreeNode[] GetFsiBeginPattern()
@@ -624,8 +624,8 @@ namespace Ryujinx.Graphics.Shader.Translation
PatternTreeNode<byte> label;
return new IPatternTreeNode[]
{
return
[
Cal(),
Ret().Use(CallArg(0).Inv),
Ret()
@@ -638,8 +638,8 @@ namespace Ryujinx.Graphics.Shader.Translation
.Use(PT)
.Use(addressLowValue).Out).Inv)
.Use(label.Out),
Ret().Use(PT),
};
Ret().Use(PT)
];
}
public static IPatternTreeNode[] GetFsiEndPattern()
@@ -652,8 +652,8 @@ namespace Ryujinx.Graphics.Shader.Translation
var addressLowValue = CallArg(1);
var incrementValue = CallArg(2);
return new IPatternTreeNode[]
{
return
[
Cal(),
Ret().Use(CallArg(0).Inv),
Membar(Decoders.Membar.Vc).Use(PT),
@@ -684,8 +684,8 @@ namespace Ryujinx.Graphics.Shader.Translation
.Use(incrementValue)
.Use(popcResult)
.Use(RZ).Out).Out),
Ret().Use(PT),
};
Ret().Use(PT)
];
}
private static PatternTreeNode<InstBfiI> Bfi(int imm)
@@ -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));
@@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
public GtsContext(HelperFunctionManager hfm)
{
_entries = new List<Entry>();
_entries = [];
_sharedEntries = new Dictionary<LsKey, Dictionary<uint, SearchResult>>();
_hfm = hfm;
}
@@ -420,22 +420,22 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
if (operation.Inst == Instruction.AtomicCompareAndSwap)
{
sources = new[]
{
sources =
[
Const(binding),
Const(0),
wordOffset,
operation.GetSource(operation.SourcesCount - 2),
operation.GetSource(operation.SourcesCount - 1),
};
operation.GetSource(operation.SourcesCount - 1)
];
}
else if (isStore)
{
sources = new[] { Const(binding), Const(0), wordOffset, operation.GetSource(operation.SourcesCount - 1) };
sources = [Const(binding), Const(0), wordOffset, operation.GetSource(operation.SourcesCount - 1)];
}
else
{
sources = new[] { Const(binding), Const(0), wordOffset };
sources = [Const(binding), Const(0), wordOffset];
}
Operation shiftOp = new(Instruction.ShiftRightU32, wordOffset, offset, Const(2));
@@ -507,7 +507,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
SearchResult result,
out int functionId)
{
List<uint> targetCbs = new() { PackCbSlotAndOffset(result.SbCbSlot, result.SbCbOffset) };
List<uint> targetCbs = [PackCbSlotAndOffset(result.SbCbSlot, result.SbCbOffset)];
if (gtsContext.TryGetFunctionId(operation, isMultiTarget: false, targetCbs, out functionId))
{
@@ -592,8 +592,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
out int functionId)
{
Queue<PhiNode> phis = new();
HashSet<PhiNode> visited = new();
List<uint> targetCbs = new();
HashSet<PhiNode> visited = [];
List<uint> targetCbs = [];
Operand globalAddress = operation.GetSource(0);
@@ -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;
@@ -73,7 +73,7 @@ namespace Ryujinx.Graphics.Shader.Translation
_sbSlots = new();
_sbSlotsReverse = new();
_usedConstantBufferBindings = new();
_usedConstantBufferBindings = [];
_usedTextures = new();
_usedImages = new();
@@ -514,7 +514,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;
@@ -611,20 +611,18 @@ namespace Ryujinx.Graphics.Shader.Translation
private void AddNewConstantBuffer(int setIndex, int binding, string name)
{
StructureType type = new(new[]
{
new StructureField(AggregateType.Array | AggregateType.Vector4 | AggregateType.FP32, "data", Constants.ConstantBufferSize / 16),
});
StructureType type = new([
new StructureField(AggregateType.Array | AggregateType.Vector4 | AggregateType.FP32, "data", Constants.ConstantBufferSize / 16)
]);
Properties.AddOrUpdateConstantBuffer(new(BufferLayout.Std140, setIndex, binding, name, type));
}
private void AddNewStorageBuffer(int setIndex, int binding, string name)
{
StructureType type = new(new[]
{
new StructureField(AggregateType.Array | AggregateType.U32, "data", 0),
});
StructureType type = new([
new StructureField(AggregateType.Array | AggregateType.U32, "data", 0)
]);
Properties.AddOrUpdateStorageBuffer(new(BufferLayout.Std430, setIndex, binding, name, type));
}
@@ -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));
@@ -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));
@@ -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));
@@ -71,11 +71,12 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
if (stage == ShaderStage.Fragment)
{
callArgs = new Operand[] { Const(functionId), texOp.GetSource(coordsIndex + index), Const(samplerIndex), Const(index) };
callArgs = [Const(functionId), texOp.GetSource(coordsIndex + index), Const(samplerIndex), Const(index)
];
}
else
{
callArgs = new Operand[] { Const(functionId), texOp.GetSource(coordsIndex + index), Const(samplerIndex) };
callArgs = [Const(functionId), texOp.GetSource(coordsIndex + index), Const(samplerIndex)];
}
node.List.AddBefore(node, new Operation(Instruction.Call, 0, scaledCoord, callArgs));
@@ -127,7 +128,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
}
}
Operand[] callArgs = new Operand[] { Const(functionId), dest, Const(samplerIndex) };
Operand[] callArgs = [Const(functionId), dest, Const(samplerIndex)];
node.List.AddAfter(node, new Operation(Instruction.Call, 0, unscaledSize, callArgs));
}
@@ -175,7 +176,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
Operand coordSize = Local();
Operand[] texSizeSources = new Operand[] { Const(0) };
Operand[] texSizeSources = [Const(0)];
LinkedListNode<INode> textureSizeNode = node.List.AddBefore(node, new TextureOperation(
Instruction.TextureQuerySize,
@@ -185,7 +186,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
texOp.Set,
texOp.Binding,
index,
new[] { coordSize },
[coordSize],
texSizeSources));
resourceManager.SetUsageFlagsForTextureQuery(texOp.Binding, texOp.Type);
@@ -240,11 +241,11 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
if (isBindless || isIndexed)
{
texSizeSources = new Operand[] { texOp.GetSource(0), Const(0) };
texSizeSources = [texOp.GetSource(0), Const(0)];
}
else
{
texSizeSources = new Operand[] { Const(0) };
texSizeSources = [Const(0)];
}
node.List.AddBefore(node, new TextureOperation(
@@ -255,7 +256,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
texOp.Set,
texOp.Binding,
index,
new[] { coordSize },
[coordSize],
texSizeSources));
node.List.AddBefore(node, new Operation(
@@ -476,7 +477,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
texOp.Set,
texOp.Binding,
1 << 3, // W component: i=0, j=0
new[] { dests[destIndex++] },
[dests[destIndex++]],
newSources);
node = node.List.AddBefore(node, newTexOp);
@@ -565,11 +566,11 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
if (bindlessHandle != null)
{
texSizeSources = new Operand[] { bindlessHandle, Const(0) };
texSizeSources = [bindlessHandle, Const(0)];
}
else
{
texSizeSources = new Operand[] { Const(0) };
texSizeSources = [Const(0)];
}
node.List.AddBefore(node, new TextureOperation(
@@ -580,7 +581,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
texOp.Set,
texOp.Binding,
index,
new[] { texSizes[index] },
[texSizes[index]],
texSizeSources));
}
@@ -611,7 +612,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
texOp.Set,
texOp.Binding,
0,
new[] { lod },
[lod],
lodSources));
}
else
@@ -627,11 +628,11 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
if (bindlessHandle != null)
{
texSizeSources = new Operand[] { bindlessHandle, GenerateF2i(node, lod) };
texSizeSources = [bindlessHandle, GenerateF2i(node, lod)];
}
else
{
texSizeSources = new Operand[] { GenerateF2i(node, lod) };
texSizeSources = [GenerateF2i(node, lod)];
}
node.List.AddBefore(node, new TextureOperation(
@@ -642,7 +643,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
texOp.Set,
texOp.Binding,
index,
new[] { texSizes[index] },
[texSizes[index]],
texSizeSources));
}
@@ -66,8 +66,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
setAndBinding.SetIndex,
setAndBinding.Binding,
1 << component,
new[] { temp },
new[] { vertexElemOffset }));
[temp],
[vertexElemOffset]));
if (needsSextNorm)
{
@@ -89,8 +89,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
setAndBinding.SetIndex,
setAndBinding.Binding,
1,
new[] { temp },
new[] { vertexElemOffset }));
[temp],
[vertexElemOffset]));
if (component > 0)
{
@@ -312,21 +312,21 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
private static LinkedListNode<INode> GenerateVertexIdVertexRateLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
{
Operand[] sources = new Operand[] { Const(resourceManager.LocalVertexIndexVertexRateMemoryId) };
Operand[] sources = [Const(resourceManager.LocalVertexIndexVertexRateMemoryId)];
return node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.LocalMemory, dest, sources));
}
private static LinkedListNode<INode> GenerateVertexIdInstanceRateLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
{
Operand[] sources = new Operand[] { Const(resourceManager.LocalVertexIndexInstanceRateMemoryId) };
Operand[] sources = [Const(resourceManager.LocalVertexIndexInstanceRateMemoryId)];
return node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.LocalMemory, dest, sources));
}
private static LinkedListNode<INode> GenerateInstanceIdLoad(LinkedListNode<INode> node, Operand dest)
{
Operand[] sources = new Operand[] { Const((int)IoVariable.GlobalId), Const(1) };
Operand[] sources = [Const((int)IoVariable.GlobalId), Const(1)];
return node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.Input, dest, sources));
}
@@ -383,10 +383,9 @@ namespace Ryujinx.Graphics.Shader.Translation
if (IsTransformFeedbackEmulated)
{
StructureType tfeDataStruct = new(new StructureField[]
{
StructureType tfeDataStruct = new([
new StructureField(AggregateType.Array | AggregateType.U32, "data", 0)
});
]);
for (int i = 0; i < ResourceReservations.TfeBuffersCount; i++)
{
@@ -402,10 +401,9 @@ namespace Ryujinx.Graphics.Shader.Translation
BufferDefinition vertexInfoBuffer = new(BufferLayout.Std140, 0, vertexInfoCbBinding, "vb_info", VertexInfoBuffer.GetStructureType());
resourceManager.Properties.AddOrUpdateConstantBuffer(vertexInfoBuffer);
StructureType vertexOutputStruct = new(new StructureField[]
{
StructureType vertexOutputStruct = new([
new StructureField(AggregateType.Array | AggregateType.FP32, "data", 0)
});
]);
int vertexOutputSbBinding = resourceManager.Reservations.VertexOutputStorageBufferBinding;
BufferDefinition vertexOutputBuffer = new(BufferLayout.Std430, 1, vertexOutputSbBinding, "vertex_output", vertexOutputStruct);
@@ -439,10 +437,9 @@ namespace Ryujinx.Graphics.Shader.Translation
BufferDefinition geometryVbOutputBuffer = new(BufferLayout.Std430, 1, geometryVbOutputSbBinding, "geometry_vb_output", vertexOutputStruct);
resourceManager.Properties.AddOrUpdateStorageBuffer(geometryVbOutputBuffer);
StructureType geometryIbOutputStruct = new(new StructureField[]
{
StructureType geometryIbOutputStruct = new([
new StructureField(AggregateType.Array | AggregateType.U32, "data", 0)
});
]);
int geometryIbOutputSbBinding = resourceManager.Reservations.GeometryIndexOutputStorageBufferBinding;
BufferDefinition geometryIbOutputBuffer = new(BufferLayout.Std430, 1, geometryIbOutputSbBinding, "geometry_ib_output", geometryIbOutputStruct);
@@ -499,10 +496,9 @@ namespace Ryujinx.Graphics.Shader.Translation
resourceManager.Properties.AddOrUpdateConstantBuffer(vertexInfoBuffer);
}
StructureType vertexInputStruct = new(new StructureField[]
{
StructureType vertexInputStruct = new([
new StructureField(AggregateType.Array | AggregateType.FP32, "data", 0)
});
]);
int vertexDataSbBinding = reservations.VertexOutputStorageBufferBinding;
BufferDefinition vertexOutputBuffer = new(BufferLayout.Std430, 1, vertexDataSbBinding, "vb_input", vertexInputStruct);
@@ -565,7 +561,7 @@ namespace Ryujinx.Graphics.Shader.Translation
};
return Generate(
new[] { function },
[function],
attributeUsage,
definitions,
definitions,
@@ -661,7 +657,7 @@ namespace Ryujinx.Graphics.Shader.Translation
maxOutputVertices);
return Generate(
new[] { function },
[function],
attributeUsage,
definitions,
definitions,
@@ -42,13 +42,12 @@ namespace Ryujinx.Graphics.Shader
internal static StructureType GetStructureType()
{
return new StructureType(new[]
{
return new StructureType([
new StructureField(AggregateType.Vector4 | AggregateType.U32, "vertex_counts"),
new StructureField(AggregateType.Vector4 | AggregateType.U32, "geometry_counts"),
new StructureField(AggregateType.Array | AggregateType.Vector4 | AggregateType.U32, "vertex_strides", ResourceReservations.MaxVertexBufferTextures),
new StructureField(AggregateType.Array | AggregateType.Vector4 | AggregateType.U32, "vertex_offsets", ResourceReservations.MaxVertexBufferTextures),
});
new StructureField(AggregateType.Array | AggregateType.Vector4 | AggregateType.U32, "vertex_offsets", ResourceReservations.MaxVertexBufferTextures)
]);
}
public Vector4<int> VertexCounts;