misc: chore: Fix numerous NullReferenceExceptions, InvalidOperationExceptions

This commit is contained in:
KeatonTheBot committed 2025-06-18 02:25:06 -05:00
1 parent a90db3464d
commit d2a532f971
90 files changed
+667 -533

No files matched your search

@@ -36,7 +36,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Operand GenerateLoad(IoVariable ioVariable)
{
Operand value = Local();
node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.Input, value, Const((int)ioVariable)));
node.List?.AddBefore(node, new Operation(Instruction.Load, StorageKind.Input, value, Const((int)ioVariable)));
return value;
}
@@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Operand vertexElemOffset = GenerateVertexOffset(context.ResourceManager, node, inputOffset, primVertex);
newNode = node.List.AddBefore(node, new Operation(
newNode = node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.StorageBuffer,
operation.Dest,
@@ -80,7 +80,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
if (TryGetOffset(context.ResourceManager, operation, StorageKind.Output, out int outputOffset))
{
newNode = node.List.AddBefore(node, new Operation(
newNode = node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.LocalMemory,
operation.Dest,
@@ -99,7 +99,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
Operand value = operation.GetSource(operation.SourcesCount - 1);
newNode = node.List.AddBefore(node, new Operation(
newNode = node.List?.AddBefore(node, new Operation(
Instruction.Store,
StorageKind.LocalMemory,
(Operand)null,
@@ -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, new[] { 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, new[] { baseIndexOffset, outputPrimIndex }));
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.Store,
StorageKind.StorageBuffer,
null,
new[] { 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, new[] { 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, new[] { baseOffset, Const(offset) }));
}
else
{
@@ -171,13 +171,13 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
}
Operand value = Local();
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.LocalMemory,
value,
new[] { Const(resourceManager.LocalVertexDataMemoryId), Const(offset) }));
newNode = node.List.AddBefore(node, new Operation(
newNode = node.List?.AddBefore(node, new Operation(
Instruction.Store,
StorageKind.StorageBuffer,
null,
@@ -198,9 +198,9 @@ 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, new[] { baseIndexOffset, outputPrimIndex }));
return node.List.AddBefore(node, new Operation(
return node.List?.AddBefore(node, new Operation(
Instruction.Store,
StorageKind.StorageBuffer,
null,
@@ -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, new[] { 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, new[] { 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, new[] { baseOffset, invocationOffset }));
return combinedOffset;
}
@@ -230,16 +230,16 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
private static Operand IncrementLocalMemory(LinkedListNode<INode> node, int memoryId)
{
Operand oldValue = Local();
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.LocalMemory,
oldValue,
new[] { 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, new[] { 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, new[] { Const(memoryId), newValue }));
return oldValue;
}
@@ -253,34 +253,34 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferBinding;
Operand vertexCount = Local();
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.ConstantBuffer,
vertexCount,
new[] { Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexCounts), Const(0) }));
Operand primInputVertex = Local();
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.LocalMemory,
primInputVertex,
new[] { Const(resourceManager.LocalTopologyRemapMemoryId), primVertex }));
Operand instanceIndex = Local();
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.Input,
instanceIndex,
new[] { 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, new[] { 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, new[] { baseVertex, primInputVertex }));
Operand vertexBaseOffset = Local();
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.Multiply,
vertexBaseOffset,
new[] { vertexIndex, Const(resourceManager.Reservations.InputSizePerInvocation) }));
@@ -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, new[] { vertexBaseOffset, Const(elementOffset) }));
}
else
{
@@ -306,35 +306,35 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferBinding;
Operand vertexCount = Local();
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.ConstantBuffer,
vertexCount,
new[] { Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexCounts), Const(0) }));
Operand vertexIndex = Local();
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.Input,
vertexIndex,
new[] { Const((int)IoVariable.GlobalId), Const(0) }));
Operand instanceIndex = Local();
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.Input,
instanceIndex,
new[] { 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, new[] { 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, new[] { baseVertex, vertexIndex }));
}
private static LinkedListNode<INode> GenerateInvocationId(LinkedListNode<INode> node, Operand dest)
{
return node.List.AddBefore(node, new Operation(
return node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.Input,
dest,
@@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Operand[] callArgs = [Const(functionId), byteOffset, value];
LinkedListNode<INode> newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, result, callArgs));
LinkedListNode<INode> newNode = node.List?.AddBefore(node, new Operation(Instruction.Call, 0, result, callArgs));
Utils.DeleteNode(node, operation);
@@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Operand[] callArgs = [Const(functionId), byteOffset, value];
LinkedListNode<INode> newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, (Operand)null, callArgs));
LinkedListNode<INode> newNode = node.List?.AddBefore(node, new Operation(Instruction.Call, 0, (Operand)null, callArgs));
Utils.DeleteNode(node, operation);
@@ -42,7 +42,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Operand[] callArgs = [Const(functionId), value, index, mask, valid];
LinkedListNode<INode> newNode = node.List.AddBefore(node, new Operation(Instruction.Call, 0, result, callArgs));
LinkedListNode<INode> newNode = node.List?.AddBefore(node, new Operation(Instruction.Call, 0, result, callArgs));
Utils.DeleteNode(node, operation);
@@ -79,7 +79,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
callArgs = [Const(functionId), texOp.GetSource(coordsIndex + index), Const(samplerIndex)];
}
node.List.AddBefore(node, new Operation(Instruction.Call, 0, scaledCoord, callArgs));
node.List?.AddBefore(node, new Operation(Instruction.Call, 0, scaledCoord, callArgs));
texOp.SetSource(coordsIndex + index, scaledCoord);
}
@@ -130,7 +130,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Operand[] callArgs = [Const(functionId), dest, Const(samplerIndex)];
node.List.AddAfter(node, new Operation(Instruction.Call, 0, unscaledSize, callArgs));
node.List?.AddAfter(node, new Operation(Instruction.Call, 0, unscaledSize, callArgs));
}
}
@@ -178,7 +178,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Operand[] texSizeSources = [Const(0)];
LinkedListNode<INode> textureSizeNode = node.List.AddBefore(node, new TextureOperation(
LinkedListNode<INode> textureSizeNode = node.List?.AddBefore(node, new TextureOperation(
Instruction.TextureQuerySize,
texOp.Type,
texOp.Format,
@@ -195,7 +195,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Operand coordNormalized = Local();
node.List.AddBefore(node, new Operation(Instruction.FP32 | Instruction.Divide, coordNormalized, source, GenerateI2f(node, coordSize)));
node.List?.AddBefore(node, new Operation(Instruction.FP32 | Instruction.Divide, coordNormalized, source, GenerateI2f(node, coordSize)));
texOp.SetSource(index, coordNormalized);
@@ -248,7 +248,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
texSizeSources = [Const(0)];
}
node.List.AddBefore(node, new TextureOperation(
node.List?.AddBefore(node, new TextureOperation(
Instruction.TextureQuerySize,
texOp.Type,
texOp.Format,
@@ -259,18 +259,18 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
[coordSize],
texSizeSources));
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.FP32 | Instruction.Multiply,
scaledSize,
GenerateI2f(node, coordSize),
ConstF((float)(1 << (gatherBiasPrecision + 1)))));
node.List.AddBefore(node, new Operation(Instruction.FP32 | Instruction.Divide, bias, ConstF(1f), scaledSize));
node.List?.AddBefore(node, new Operation(Instruction.FP32 | Instruction.Divide, bias, ConstF(1f), scaledSize));
Operand source = texOp.GetSource(coordsIndex + index);
Operand coordBiased = Local();
node.List.AddBefore(node, new Operation(Instruction.FP32 | Instruction.Add, coordBiased, source, bias));
node.List?.AddBefore(node, new Operation(Instruction.FP32 | Instruction.Add, coordBiased, source, bias));
texOp.SetSource(coordsIndex + index, coordBiased);
}
@@ -573,7 +573,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
texSizeSources = [Const(0)];
}
node.List.AddBefore(node, new TextureOperation(
node.List?.AddBefore(node, new TextureOperation(
Instruction.TextureQuerySize,
texOp.Type,
texOp.Format,
@@ -604,7 +604,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
lod = Local();
node.List.AddBefore(node, new TextureOperation(
node.List?.AddBefore(node, new TextureOperation(
Instruction.Lod,
texOp.Type,
texOp.Format,
@@ -635,7 +635,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
texSizeSources = [GenerateF2i(node, lod)];
}
node.List.AddBefore(node, new TextureOperation(
node.List?.AddBefore(node, new TextureOperation(
Instruction.TextureQuerySize,
texOp.Type,
texOp.Format,
@@ -692,8 +692,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Operation convOp = new(Instruction.ConvertS32ToFP32, Local(), dest);
Operation normOp = new(Instruction.FP32 | Instruction.Multiply, Local(), convOp.Dest, ConstF(1f / maxPositive));
node = node.List.AddAfter(node, convOp);
node = node.List.AddAfter(node, normOp);
node = node?.List?.AddAfter(node, convOp);
node = node?.List?.AddAfter(node, normOp);
foreach (INode useOp in uses)
{
@@ -720,7 +720,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
Operand res = Local();
node.List.AddBefore(node, new Operation(Instruction.ConvertS32ToFP32, res, value));
node.List?.AddBefore(node, new Operation(Instruction.ConvertS32ToFP32, res, value));
return res;
}
@@ -729,7 +729,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
Operand res = Local();
node.List.AddBefore(node, new Operation(Instruction.ConvertFP32ToS32, res, value));
node.List?.AddBefore(node, new Operation(Instruction.ConvertFP32ToS32, res, value));
return res;
}
@@ -67,7 +67,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Operation loadOp = new(Instruction.Load, StorageKind.ConstantBuffer, value, inputs);
node.List.AddBefore(node, loadOp);
node.List?.AddBefore(node, loadOp);
if (i == 0)
{
@@ -81,8 +81,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Operation compareOp = new(Instruction.CompareEqual, isCurrentIndex, new Operand[] { elemIndex, Const(i) });
Operation selectOp = new(Instruction.ConditionalSelect, selection, new Operand[] { isCurrentIndex, value, result });
node.List.AddBefore(node, compareOp);
node.List.AddBefore(node, selectOp);
node.List?.AddBefore(node, compareOp);
node.List?.AddBefore(node, selectOp);
result = selection;
}
@@ -58,7 +58,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Operand temp = needsSextNorm ? Local() : dest;
Operand vertexElemOffset = GenerateVertexOffset(context.ResourceManager, node, location, 0);
newNode = node.List.AddBefore(node, new TextureOperation(
newNode = node.List?.AddBefore(node, new TextureOperation(
Instruction.TextureSample,
SamplerType.TextureBuffer,
TextureFormat.Unknown,
@@ -81,7 +81,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
Operand temp = component > 0 ? Local() : dest;
Operand vertexElemOffset = GenerateVertexOffset(context.ResourceManager, node, location, component);
newNode = node.List.AddBefore(node, new TextureOperation(
newNode = node.List?.AddBefore(node, new TextureOperation(
Instruction.TextureSample,
SamplerType.TextureBuffer,
TextureFormat.Unknown,
@@ -116,7 +116,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
if (TryGetOutputOffset(context.ResourceManager, operation, out int outputOffset))
{
newNode = node.List.AddBefore(node, new Operation(
newNode = node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.LocalMemory,
operation.Dest,
@@ -133,7 +133,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
Operand value = operation.GetSource(operation.SourcesCount - 1);
newNode = node.List.AddBefore(node, new Operation(
newNode = node.List?.AddBefore(node, new Operation(
Instruction.Store,
StorageKind.LocalMemory,
(Operand)null,
@@ -164,37 +164,37 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
GenerateVertexIdInstanceRateLoad(resourceManager, node, vertexIdIr);
Operand attributeOffset = Local();
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.ConstantBuffer,
attributeOffset,
new[] { Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexOffsets), Const(location), Const(0) }));
Operand isInstanceRate = Local();
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.ConstantBuffer,
isInstanceRate,
new[] { Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexOffsets), Const(location), Const(1) }));
Operand vertexId = Local();
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.ConditionalSelect,
vertexId,
new[] { isInstanceRate, vertexIdIr, vertexIdVr }));
Operand vertexStride = Local();
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.ConstantBuffer,
vertexStride,
new[] { 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, new[] { 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, new[] { 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, new[] { vertexOffset, Const(component) }));
}
else
{
@@ -215,13 +215,13 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
private static LinkedListNode<INode> CopySignExtendedNormalized(LinkedListNode<INode> node, int bits, bool normalize, Operand dest, Operand src)
{
Operand leftShifted = Local();
node = node.List.AddAfter(node, new Operation(
node = node.List?.AddAfter(node, new Operation(
Instruction.ShiftLeft,
leftShifted,
new[] { src, Const(32 - bits) }));
Operand rightShifted = normalize ? Local() : dest;
node = node.List.AddAfter(node, new Operation(
node = node?.List?.AddAfter(node, new Operation(
Instruction.ShiftRightS32,
rightShifted,
new[] { leftShifted, Const(32 - bits) }));
@@ -229,8 +229,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
if (normalize)
{
Operand asFloat = Local();
node = node.List.AddAfter(node, new Operation(Instruction.ConvertS32ToFP32, asFloat, new[] { rightShifted }));
node = node.List.AddAfter(node, new Operation(
node = node?.List?.AddAfter(node, new Operation(Instruction.ConvertS32ToFP32, asFloat, new[] { rightShifted }));
node = node?.List?.AddAfter(node, new Operation(
Instruction.FP32 | Instruction.Multiply,
dest,
new[] { asFloat, ConstF(1f / (1 << (bits - 1))) }));
@@ -249,13 +249,13 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
Operand componentExists = Local();
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferBinding;
node = node.List.AddAfter(node, new Operation(
node = node.List?.AddAfter(node, new Operation(
Instruction.Load,
StorageKind.ConstantBuffer,
componentExists,
new[] { Const(vertexInfoCbBinding), Const((int)VertexInfoBufferField.VertexStrides), Const(location), Const(component) }));
return node.List.AddAfter(node, new Operation(
return node?.List?.AddAfter(node, new Operation(
Instruction.ConditionalSelect,
dest,
new[] { componentExists, src, ConstF(component == 3 ? 1f : 0f) }));
@@ -265,7 +265,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferBinding;
return node.List.AddBefore(node, new Operation(
return node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.ConstantBuffer,
dest,
@@ -276,7 +276,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
{
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferBinding;
return node.List.AddBefore(node, new Operation(
return node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.ConstantBuffer,
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, new[] { baseVertex, vertexId }));
}
private static LinkedListNode<INode> GenerateInstanceIndexLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
@@ -301,34 +301,34 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
GenerateBaseInstanceLoad(resourceManager, node, baseInstance);
node.List.AddBefore(node, new Operation(
node.List?.AddBefore(node, new Operation(
Instruction.Load,
StorageKind.Input,
instanceId,
new[] { 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, new[] { baseInstance, instanceId }));
}
private static LinkedListNode<INode> GenerateVertexIdVertexRateLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
{
Operand[] sources = [Const(resourceManager.LocalVertexIndexVertexRateMemoryId)];
return node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.LocalMemory, dest, sources));
return node.List?.AddBefore(node, new Operation(Instruction.Load, StorageKind.LocalMemory, dest, sources));
}
private static LinkedListNode<INode> GenerateVertexIdInstanceRateLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
{
Operand[] sources = [Const(resourceManager.LocalVertexIndexInstanceRateMemoryId)];
return node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.LocalMemory, dest, sources));
return node.List?.AddBefore(node, new Operation(Instruction.Load, StorageKind.LocalMemory, dest, sources));
}
private static LinkedListNode<INode> GenerateInstanceIdLoad(LinkedListNode<INode> node, Operand dest)
{
Operand[] sources = [Const((int)IoVariable.GlobalId), Const(1)];
return node.List.AddBefore(node, new Operation(Instruction.Load, StorageKind.Input, dest, sources));
return node.List?.AddBefore(node, new Operation(Instruction.Load, StorageKind.Input, dest, sources));
}
private static bool TryGetOutputOffset(ResourceManager resourceManager, Operation operation, out int outputOffset)