mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-25 21:27:14 +02:00
parent
417df486b1
commit
361d0c5632
622 changed files with 3080 additions and 2652 deletions
|
@ -4,7 +4,6 @@ using System.Diagnostics.CodeAnalysis;
|
|||
namespace Ryujinx.Graphics.Shader.Translation
|
||||
{
|
||||
[Flags]
|
||||
[SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
|
||||
enum AggregateType
|
||||
{
|
||||
Invalid,
|
||||
|
|
|
@ -110,9 +110,9 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
currentBlock.Operations.AddLast(operation);
|
||||
}
|
||||
|
||||
needsNewBlock = operation.Inst == Instruction.Branch ||
|
||||
operation.Inst == Instruction.BranchIfTrue ||
|
||||
operation.Inst == Instruction.BranchIfFalse;
|
||||
needsNewBlock = operation.Inst is Instruction.Branch or
|
||||
Instruction.BranchIfTrue or
|
||||
Instruction.BranchIfFalse;
|
||||
|
||||
if (needsNewBlock)
|
||||
{
|
||||
|
|
|
@ -470,6 +470,5 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,6 +167,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
operation.TurnIntoCopy(Cbuf(cbufSlot, cbufOffset));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Instruction.Maximum:
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
return functionId;
|
||||
}
|
||||
|
||||
public bool TryGetFunctionId(Operation baseOp, bool isMultiTarget, IReadOnlyList<uint> targetCbs, out int functionId)
|
||||
public bool TryGetFunctionId(Operation baseOp, bool isMultiTarget, List<uint> targetCbs, out int functionId)
|
||||
{
|
||||
foreach (Entry entry in _entries)
|
||||
{
|
||||
|
@ -281,19 +281,19 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
|
||||
private static bool IsGlobalMemory(StorageKind storageKind)
|
||||
{
|
||||
return storageKind == StorageKind.GlobalMemory ||
|
||||
storageKind == StorageKind.GlobalMemoryS8 ||
|
||||
storageKind == StorageKind.GlobalMemoryS16 ||
|
||||
storageKind == StorageKind.GlobalMemoryU8 ||
|
||||
storageKind == StorageKind.GlobalMemoryU16;
|
||||
return storageKind is StorageKind.GlobalMemory or
|
||||
StorageKind.GlobalMemoryS8 or
|
||||
StorageKind.GlobalMemoryS16 or
|
||||
StorageKind.GlobalMemoryU8 or
|
||||
StorageKind.GlobalMemoryU16;
|
||||
}
|
||||
|
||||
private static bool IsSmallInt(StorageKind storageKind)
|
||||
{
|
||||
return storageKind == StorageKind.GlobalMemoryS8 ||
|
||||
storageKind == StorageKind.GlobalMemoryS16 ||
|
||||
storageKind == StorageKind.GlobalMemoryU8 ||
|
||||
storageKind == StorageKind.GlobalMemoryU16;
|
||||
return storageKind is StorageKind.GlobalMemoryS8 or
|
||||
StorageKind.GlobalMemoryS16 or
|
||||
StorageKind.GlobalMemoryU8 or
|
||||
StorageKind.GlobalMemoryU16;
|
||||
}
|
||||
|
||||
private static LinkedListNode<INode> ReplaceGlobalMemoryWithStorage(
|
||||
|
@ -865,6 +865,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
return context.IMaximumS32(memValue, value);
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
case Instruction.AtomicMaxU32:
|
||||
resultValue = context.AtomicMaxU32(StorageKind.StorageBuffer, binding, Const(0), wordOffset, value);
|
||||
|
@ -881,6 +882,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
return context.IMinimumS32(memValue, value);
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
case Instruction.AtomicMinU32:
|
||||
resultValue = context.AtomicMinU32(StorageKind.StorageBuffer, binding, Const(0), wordOffset, value);
|
||||
|
@ -1100,7 +1102,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
{
|
||||
baseOffset = null;
|
||||
|
||||
if (operation.Inst == Instruction.Load || operation.Inst == Instruction.Store)
|
||||
if (operation.Inst is Instruction.Load or Instruction.Store)
|
||||
{
|
||||
if (operation.StorageKind == StorageKind.SharedMemory)
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
{
|
||||
TryEliminateBinaryOpCommutative(operation, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Instruction.BitwiseOr:
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
return x == y || x.Type == OperandType.Constant || x.Type == OperandType.ConstantBuffer;
|
||||
}
|
||||
|
||||
private static bool AreAllSourcesEqual(INode node, INode otherNode)
|
||||
private static bool AreAllSourcesEqual(Operation node, Operation otherNode)
|
||||
{
|
||||
if (node.SourcesCount != otherNode.SourcesCount)
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
|
||||
private static bool IsConditionalBranch(Instruction inst)
|
||||
{
|
||||
return inst == Instruction.BranchIfFalse || inst == Instruction.BranchIfTrue;
|
||||
return inst is Instruction.BranchIfFalse or Instruction.BranchIfTrue;
|
||||
}
|
||||
|
||||
private static bool IsSameCondition(Operand currentCondition, Operand queryCondition)
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
{
|
||||
for (LinkedListNode<INode> node = block.Operations.First; node != null; node = node.Next)
|
||||
{
|
||||
if (!(node.Value is Operation operation))
|
||||
if (node.Value is not Operation operation)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -56,14 +56,14 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
Operand src1 = operation.GetSource(0);
|
||||
Operand src2 = operation.GetSource(1);
|
||||
|
||||
if (!(src2.AsgOp is Operation addOp) || addOp.Inst != Instruction.Add)
|
||||
if (src2.AsgOp is not Operation addOp || addOp.Inst != Instruction.Add)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Operand lowTimesLowResult = GetCopySource(addOp.GetSource(0));
|
||||
|
||||
if (!(lowTimesLowResult.AsgOp is Operation lowTimesLowOp))
|
||||
if (lowTimesLowResult.AsgOp is not Operation lowTimesLowOp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
|
||||
Operand lowTimesHighResult = GetCopySource(GetShifted16Source(addOp.GetSource(1), Instruction.ShiftLeft));
|
||||
|
||||
if (!(lowTimesHighResult.AsgOp is Operation lowTimesHighOp))
|
||||
if (lowTimesHighResult.AsgOp is not Operation lowTimesHighOp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!(src1.AsgOp is Operation highTimesHighOp))
|
||||
if (src1.AsgOp is not Operation highTimesHighOp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
|
||||
Operand lowTimesLowResult = GetCopySource(src2);
|
||||
|
||||
if (!(lowTimesLowResult.AsgOp is Operation lowTimesLowOp))
|
||||
if (lowTimesLowResult.AsgOp is not Operation lowTimesLowOp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
|
||||
Operand highTimesLowResult = src1;
|
||||
|
||||
if (!(highTimesLowResult.AsgOp is Operation highTimesLowOp))
|
||||
if (highTimesLowResult.AsgOp is not Operation highTimesLowOp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
|
||||
if (operation.Inst == Instruction.Add)
|
||||
{
|
||||
if (!(operation.GetSource(0).AsgOp is Operation mulOp))
|
||||
if (operation.GetSource(0).AsgOp is not Operation mulOp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
|
||||
mulResult = GetCopySource(mulResult);
|
||||
|
||||
if (!(mulResult.AsgOp is Operation mulOp) || mulOp.Inst != Instruction.Multiply)
|
||||
if (mulResult.AsgOp is not Operation mulOp || mulOp.Inst != Instruction.Multiply)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
|
||||
Operand mulResult = operation.GetSource(0);
|
||||
|
||||
if (!(mulResult.AsgOp is Operation mulOp) || mulOp.Inst != Instruction.Multiply)
|
||||
if (mulResult.AsgOp is not Operation mulOp || mulOp.Inst != Instruction.Multiply)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
|
||||
Operand mulResult = operation.GetSource(0);
|
||||
|
||||
if (!(mulResult.AsgOp is Operation mulOp) || mulOp.Inst != Instruction.Multiply)
|
||||
if (mulResult.AsgOp is not Operation mulOp || mulOp.Inst != Instruction.Multiply)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
|
||||
private static Operand GetMasked16Source(Operand value)
|
||||
{
|
||||
if (!(value.AsgOp is Operation maskOp))
|
||||
if (value.AsgOp is not Operation maskOp)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
|
||||
private static Operand GetShifted16Source(Operand value, Instruction shiftInst)
|
||||
{
|
||||
if (!(value.AsgOp is Operation shiftOp))
|
||||
if (value.AsgOp is not Operation shiftOp)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -33,10 +33,12 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
{
|
||||
return X;
|
||||
}
|
||||
|
||||
if (Y != PixelImap.Unused)
|
||||
{
|
||||
return Y;
|
||||
}
|
||||
|
||||
if (Z != PixelImap.Unused)
|
||||
{
|
||||
return Z;
|
||||
|
|
|
@ -91,6 +91,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
context.GpuAccessor.Log($"Invalid output \"{(IoVariable)operation.GetSource(0).Value}\".");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case Instruction.Store:
|
||||
if (operation.StorageKind == StorageKind.Output)
|
||||
|
@ -110,6 +111,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
context.GpuAccessor.Log($"Invalid output \"{(IoVariable)operation.GetSource(0).Value}\".");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
newNode = CopyMasked(context.ResourceManager, newNode, location, component, dest, temp);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case IoVariable.GlobalId:
|
||||
case IoVariable.SubgroupEqMask:
|
||||
|
|
|
@ -385,7 +385,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
{
|
||||
StructureType tfeDataStruct = new(new StructureField[]
|
||||
{
|
||||
new StructureField(AggregateType.Array | AggregateType.U32, "data", 0)
|
||||
new(AggregateType.Array | AggregateType.U32, "data", 0)
|
||||
});
|
||||
|
||||
for (int i = 0; i < ResourceReservations.TfeBuffersCount; i++)
|
||||
|
@ -404,7 +404,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
StructureType vertexOutputStruct = new(new StructureField[]
|
||||
{
|
||||
new StructureField(AggregateType.Array | AggregateType.FP32, "data", 0)
|
||||
new(AggregateType.Array | AggregateType.FP32, "data", 0)
|
||||
});
|
||||
|
||||
int vertexOutputSbBinding = resourceManager.Reservations.VertexOutputStorageBufferBinding;
|
||||
|
@ -441,7 +441,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
StructureType geometryIbOutputStruct = new(new StructureField[]
|
||||
{
|
||||
new StructureField(AggregateType.Array | AggregateType.U32, "data", 0)
|
||||
new(AggregateType.Array | AggregateType.U32, "data", 0)
|
||||
});
|
||||
|
||||
int geometryIbOutputSbBinding = resourceManager.Reservations.GeometryIndexOutputStorageBufferBinding;
|
||||
|
@ -501,7 +501,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
StructureType vertexInputStruct = new(new StructureField[]
|
||||
{
|
||||
new StructureField(AggregateType.Array | AggregateType.FP32, "data", 0)
|
||||
new(AggregateType.Array | AggregateType.FP32, "data", 0)
|
||||
});
|
||||
|
||||
int vertexDataSbBinding = reservations.VertexOutputStorageBufferBinding;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue