mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-28 06:46:24 +02:00
parent
417df486b1
commit
361d0c5632
622 changed files with 3080 additions and 2652 deletions
|
@ -629,9 +629,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
|||
}
|
||||
else
|
||||
{
|
||||
return stage == ShaderStage.TessellationControl ||
|
||||
stage == ShaderStage.TessellationEvaluation ||
|
||||
stage == ShaderStage.Geometry;
|
||||
return stage is ShaderStage.TessellationControl or
|
||||
ShaderStage.TessellationEvaluation or
|
||||
ShaderStage.Geometry;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
|||
{
|
||||
builder.Append(GenerateLoadOrStore(context, operation, isStore: false));
|
||||
|
||||
AggregateType dstType = operation.Inst == Instruction.AtomicMaxS32 || operation.Inst == Instruction.AtomicMinS32
|
||||
AggregateType dstType = operation.Inst is Instruction.AtomicMaxS32 or Instruction.AtomicMinS32
|
||||
? AggregateType.S32
|
||||
: AggregateType.U32;
|
||||
|
||||
|
|
|
@ -595,6 +595,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
|||
varName = $"gl_out[{expr}].{varName}";
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -4,7 +4,6 @@ using System.Diagnostics.CodeAnalysis;
|
|||
namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
{
|
||||
[Flags]
|
||||
[SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
|
||||
enum InstType
|
||||
{
|
||||
OpNullary = Op | 0,
|
||||
|
|
|
@ -79,9 +79,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
|||
}
|
||||
else
|
||||
{
|
||||
return stage == ShaderStage.TessellationControl ||
|
||||
stage == ShaderStage.TessellationEvaluation ||
|
||||
stage == ShaderStage.Geometry;
|
||||
return stage is ShaderStage.TessellationControl or
|
||||
ShaderStage.TessellationEvaluation or
|
||||
ShaderStage.Geometry;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
|||
|
||||
public static string FormatInt(int value)
|
||||
{
|
||||
if (value <= MaxDecimal && value >= -MaxDecimal)
|
||||
if (value is <= MaxDecimal and >= (-MaxDecimal))
|
||||
{
|
||||
return value.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
|||
|
||||
public static string FormatUint(uint value)
|
||||
{
|
||||
if (value <= MaxDecimal && value >= 0)
|
||||
if (value is <= MaxDecimal and >= 0)
|
||||
{
|
||||
return value.ToString(CultureInfo.InvariantCulture) + "u";
|
||||
}
|
||||
|
|
|
@ -97,8 +97,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
|||
}
|
||||
|
||||
IoVariable ioVariable = (IoVariable)varId.Value;
|
||||
bool isOutput = operation.StorageKind == StorageKind.Output || operation.StorageKind == StorageKind.OutputPerPatch;
|
||||
bool isPerPatch = operation.StorageKind == StorageKind.InputPerPatch || operation.StorageKind == StorageKind.OutputPerPatch;
|
||||
bool isOutput = operation.StorageKind is StorageKind.Output or StorageKind.OutputPerPatch;
|
||||
bool isPerPatch = operation.StorageKind is StorageKind.InputPerPatch or StorageKind.OutputPerPatch;
|
||||
int location = 0;
|
||||
int component = 0;
|
||||
|
||||
|
|
|
@ -1695,6 +1695,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
varType = context.Properties.SharedMemories[bindingId.Value].Type & AggregateType.ElementTypeMask;
|
||||
baseObj = context.SharedMemories[bindingId.Value];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case StorageKind.Input:
|
||||
|
|
|
@ -104,9 +104,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
}
|
||||
else
|
||||
{
|
||||
return stage == ShaderStage.TessellationControl ||
|
||||
stage == ShaderStage.TessellationEvaluation ||
|
||||
stage == ShaderStage.Geometry;
|
||||
return stage is ShaderStage.TessellationControl or
|
||||
ShaderStage.TessellationEvaluation or
|
||||
ShaderStage.Geometry;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,8 +89,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
context.AddCapability(Capability.GeometryShaderPassthroughNV);
|
||||
}
|
||||
}
|
||||
else if (parameters.Definitions.Stage == ShaderStage.TessellationControl ||
|
||||
parameters.Definitions.Stage == ShaderStage.TessellationEvaluation)
|
||||
else if (parameters.Definitions.Stage is ShaderStage.TessellationControl or
|
||||
ShaderStage.TessellationEvaluation)
|
||||
{
|
||||
context.AddCapability(Capability.Tessellation);
|
||||
}
|
||||
|
|
|
@ -392,7 +392,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
|
|||
|
||||
if (perPatch)
|
||||
{
|
||||
if (attr >= AttributeConsts.UserAttributePerPatchBase && attr < AttributeConsts.UserAttributePerPatchEnd)
|
||||
if (attr is >= AttributeConsts.UserAttributePerPatchBase and < AttributeConsts.UserAttributePerPatchEnd)
|
||||
{
|
||||
int userAttr = attr - AttributeConsts.UserAttributePerPatchBase;
|
||||
int index = userAttr / 16;
|
||||
|
@ -407,7 +407,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (attr >= AttributeConsts.UserAttributeBase && attr < AttributeConsts.UserAttributeEnd)
|
||||
else if (attr is >= AttributeConsts.UserAttributeBase and < AttributeConsts.UserAttributeEnd)
|
||||
{
|
||||
int userAttr = attr - AttributeConsts.UserAttributeBase;
|
||||
int index = userAttr / 16;
|
||||
|
@ -436,16 +436,18 @@ namespace Ryujinx.Graphics.Shader.Decoders
|
|||
switch (attr)
|
||||
{
|
||||
case AttributeConsts.Layer:
|
||||
if (definitions.Stage != ShaderStage.Compute && definitions.Stage != ShaderStage.Fragment)
|
||||
if (definitions.Stage is not ShaderStage.Compute and not ShaderStage.Fragment)
|
||||
{
|
||||
context.SetUsedFeature(FeatureFlags.RtLayer);
|
||||
}
|
||||
|
||||
break;
|
||||
case AttributeConsts.ViewportIndex:
|
||||
if (definitions.Stage != ShaderStage.Fragment)
|
||||
{
|
||||
context.SetUsedFeature(FeatureFlags.ViewportIndex);
|
||||
}
|
||||
|
||||
break;
|
||||
case AttributeConsts.ClipDistance0:
|
||||
case AttributeConsts.ClipDistance1:
|
||||
|
@ -459,12 +461,14 @@ namespace Ryujinx.Graphics.Shader.Decoders
|
|||
{
|
||||
context.SetClipDistanceWritten((attr - AttributeConsts.ClipDistance0) / 4);
|
||||
}
|
||||
|
||||
break;
|
||||
case AttributeConsts.ViewportMask:
|
||||
if (definitions.Stage != ShaderStage.Fragment)
|
||||
{
|
||||
context.SetUsedFeature(FeatureFlags.ViewportMask);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -478,12 +482,14 @@ namespace Ryujinx.Graphics.Shader.Decoders
|
|||
{
|
||||
context.SetUsedFeature(FeatureFlags.FragCoordXY);
|
||||
}
|
||||
|
||||
break;
|
||||
case AttributeConsts.InstanceId:
|
||||
if (definitions.Stage == ShaderStage.Vertex)
|
||||
{
|
||||
context.SetUsedFeature(FeatureFlags.InstanceId);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -879,7 +885,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
|
|||
|
||||
public static bool IsPopBranch(InstName name)
|
||||
{
|
||||
return name == InstName.Brk || name == InstName.Cont || name == InstName.Sync;
|
||||
return name is InstName.Brk or InstName.Cont or InstName.Sync;
|
||||
}
|
||||
|
||||
private static MergeType GetMergeTypeFromPush(InstName name)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
|
||||
using Ryujinx.Graphics.Shader.Translation;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
|
||||
|
||||
namespace Ryujinx.Graphics.Shader.Instructions
|
||||
|
@ -46,8 +47,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
}
|
||||
}
|
||||
|
||||
private static readonly IReadOnlyDictionary<int, AttributeEntry> _attributes;
|
||||
private static readonly IReadOnlyDictionary<int, AttributeEntry> _attributesPerPatch;
|
||||
private static readonly ReadOnlyDictionary<int, AttributeEntry> _attributes;
|
||||
private static readonly ReadOnlyDictionary<int, AttributeEntry> _attributesPerPatch;
|
||||
|
||||
static AttributeMap()
|
||||
{
|
||||
|
@ -55,7 +56,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
_attributesPerPatch = CreatePerPatchMap();
|
||||
}
|
||||
|
||||
private static IReadOnlyDictionary<int, AttributeEntry> CreateMap()
|
||||
private static ReadOnlyDictionary<int, AttributeEntry> CreateMap()
|
||||
{
|
||||
Dictionary<int, AttributeEntry> map = new();
|
||||
|
||||
|
@ -79,10 +80,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
Add(map, 0x3a0, AggregateType.Array | AggregateType.S32, IoVariable.ViewportMask, StagesMask.Fragment, StagesMask.VertexTessellationGeometry);
|
||||
Add(map, 0x3fc, AggregateType.Bool, IoVariable.FrontFacing, StagesMask.Fragment, StagesMask.None);
|
||||
|
||||
return map;
|
||||
return map.AsReadOnly();
|
||||
}
|
||||
|
||||
private static IReadOnlyDictionary<int, AttributeEntry> CreatePerPatchMap()
|
||||
private static ReadOnlyDictionary<int, AttributeEntry> CreatePerPatchMap()
|
||||
{
|
||||
Dictionary<int, AttributeEntry> map = new();
|
||||
|
||||
|
@ -90,7 +91,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
Add(map, 0x010, AggregateType.Vector2 | AggregateType.FP32, IoVariable.TessellationLevelInner, StagesMask.TessellationEvaluation, StagesMask.TessellationControl);
|
||||
Add(map, 0x018, AggregateType.Vector4 | AggregateType.FP32, IoVariable.UserDefined, StagesMask.TessellationEvaluation, StagesMask.TessellationControl, 31, 0x200);
|
||||
|
||||
return map;
|
||||
return map.AsReadOnly();
|
||||
}
|
||||
|
||||
private static void Add(
|
||||
|
@ -326,9 +327,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
return false;
|
||||
}
|
||||
|
||||
return stage == ShaderStage.TessellationControl ||
|
||||
stage == ShaderStage.TessellationEvaluation ||
|
||||
stage == ShaderStage.Geometry;
|
||||
return stage is ShaderStage.TessellationControl or
|
||||
ShaderStage.TessellationEvaluation or
|
||||
ShaderStage.Geometry;
|
||||
}
|
||||
|
||||
public static bool HasInvocationId(ShaderStage stage, bool isOutput)
|
||||
|
|
|
@ -164,7 +164,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
{
|
||||
isFixedFunc = TryFixedFuncToUserAttributeIpa(context, op.Imm10, out res);
|
||||
|
||||
if (op.Imm10 >= AttributeConsts.UserAttributeBase && op.Imm10 < AttributeConsts.UserAttributeEnd)
|
||||
if (op.Imm10 is >= AttributeConsts.UserAttributeBase and < AttributeConsts.UserAttributeEnd)
|
||||
{
|
||||
int index = (op.Imm10 - AttributeConsts.UserAttributeBase) >> 4;
|
||||
|
||||
|
@ -173,7 +173,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
res = context.FPMultiply(res, context.Load(StorageKind.Input, IoVariable.FragmentCoord, null, Const(3)));
|
||||
}
|
||||
}
|
||||
else if (op.Imm10 == AttributeConsts.PositionX || op.Imm10 == AttributeConsts.PositionY)
|
||||
else if (op.Imm10 is AttributeConsts.PositionX or AttributeConsts.PositionY)
|
||||
{
|
||||
// FragCoord X/Y must be divided by the render target scale, if resolution scaling is active,
|
||||
// because the shader code is not expecting scaled values.
|
||||
|
@ -296,19 +296,19 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
|
||||
private static bool HasPrimitiveVertex(int attr)
|
||||
{
|
||||
return attr != AttributeConsts.PrimitiveId &&
|
||||
attr != AttributeConsts.TessCoordX &&
|
||||
attr != AttributeConsts.TessCoordY;
|
||||
return attr is not AttributeConsts.PrimitiveId and
|
||||
not AttributeConsts.TessCoordX and
|
||||
not AttributeConsts.TessCoordY;
|
||||
}
|
||||
|
||||
private static bool CanLoadOutput(int attr)
|
||||
{
|
||||
return attr != AttributeConsts.TessCoordX && attr != AttributeConsts.TessCoordY;
|
||||
return attr is not AttributeConsts.TessCoordX and not AttributeConsts.TessCoordY;
|
||||
}
|
||||
|
||||
private static bool TryFixedFuncToUserAttributeIpa(EmitterContext context, int attr, out Operand selectedAttr)
|
||||
{
|
||||
if (attr >= AttributeConsts.FrontColorDiffuseR && attr < AttributeConsts.BackColorDiffuseR)
|
||||
if (attr is >= AttributeConsts.FrontColorDiffuseR and < AttributeConsts.BackColorDiffuseR)
|
||||
{
|
||||
// TODO: If two sided rendering is enabled, then this should return
|
||||
// FrontColor if the fragment is front facing, and back color otherwise.
|
||||
|
@ -321,12 +321,12 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
selectedAttr = GenerateIpaLoad(context, FixedFuncToUserAttribute(context.TranslatorContext, attr, isOutput: false));
|
||||
return true;
|
||||
}
|
||||
else if (attr >= AttributeConsts.BackColorDiffuseR && attr < AttributeConsts.ClipDistance0)
|
||||
else if (attr is >= AttributeConsts.BackColorDiffuseR and < AttributeConsts.ClipDistance0)
|
||||
{
|
||||
selectedAttr = ConstF(((attr >> 2) & 3) == 3 ? 1f : 0f);
|
||||
return true;
|
||||
}
|
||||
else if (attr >= AttributeConsts.TexCoordBase && attr < AttributeConsts.TexCoordEnd)
|
||||
else if (attr is >= AttributeConsts.TexCoordBase and < AttributeConsts.TexCoordEnd)
|
||||
{
|
||||
selectedAttr = GenerateIpaLoad(context, FixedFuncToUserAttribute(context.TranslatorContext, attr, isOutput: false));
|
||||
return true;
|
||||
|
@ -355,11 +355,11 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
{
|
||||
attr = FixedFuncToUserAttribute(translatorContext, attr, AttributeConsts.FogCoord, fixedStartAttr, isOutput);
|
||||
}
|
||||
else if (attr >= AttributeConsts.FrontColorDiffuseR && attr < AttributeConsts.ClipDistance0)
|
||||
else if (attr is >= AttributeConsts.FrontColorDiffuseR and < AttributeConsts.ClipDistance0)
|
||||
{
|
||||
attr = FixedFuncToUserAttribute(translatorContext, attr, AttributeConsts.FrontColorDiffuseR, fixedStartAttr + 1, isOutput);
|
||||
}
|
||||
else if (attr >= AttributeConsts.TexCoordBase && attr < AttributeConsts.TexCoordEnd)
|
||||
else if (attr is >= AttributeConsts.TexCoordBase and < AttributeConsts.TexCoordEnd)
|
||||
{
|
||||
attr = FixedFuncToUserAttribute(translatorContext, attr, AttributeConsts.TexCoordBase, fixedStartAttr + 5, isOutput);
|
||||
}
|
||||
|
|
|
@ -179,8 +179,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
|
||||
Instruction fpType = srcType.ToInstFPType();
|
||||
|
||||
bool isSignedInt = dstType == IDstFmt.S16 || dstType == IDstFmt.S32 || dstType == IDstFmt.S64;
|
||||
bool isSmallInt = dstType == IDstFmt.U16 || dstType == IDstFmt.S16;
|
||||
bool isSignedInt = dstType is IDstFmt.S16 or IDstFmt.S32 or IDstFmt.S64;
|
||||
bool isSmallInt = dstType is IDstFmt.U16 or IDstFmt.S16;
|
||||
|
||||
Operand srcB = context.FPAbsNeg(src, absolute, negate, fpType);
|
||||
|
||||
|
@ -242,15 +242,15 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
bool negate)
|
||||
{
|
||||
bool isSignedInt =
|
||||
srcType == ISrcFmt.S8 ||
|
||||
srcType == ISrcFmt.S16 ||
|
||||
srcType == ISrcFmt.S32 ||
|
||||
srcType == ISrcFmt.S64;
|
||||
srcType is ISrcFmt.S8 or
|
||||
ISrcFmt.S16 or
|
||||
ISrcFmt.S32 or
|
||||
ISrcFmt.S64;
|
||||
bool isSmallInt =
|
||||
srcType == ISrcFmt.U16 ||
|
||||
srcType == ISrcFmt.S16 ||
|
||||
srcType == ISrcFmt.U8 ||
|
||||
srcType == ISrcFmt.S8;
|
||||
srcType is ISrcFmt.U16 or
|
||||
ISrcFmt.S16 or
|
||||
ISrcFmt.U8 or
|
||||
ISrcFmt.S8;
|
||||
|
||||
// TODO: Handle S/U64.
|
||||
|
||||
|
@ -258,7 +258,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
|
||||
if (isSmallInt)
|
||||
{
|
||||
int size = srcType == ISrcFmt.U16 || srcType == ISrcFmt.S16 ? 16 : 8;
|
||||
int size = srcType is ISrcFmt.U16 or ISrcFmt.S16 ? 16 : 8;
|
||||
|
||||
srcB = isSignedInt
|
||||
? context.BitfieldExtractS32(srcB, Const((int)byteSelection * 8), Const(size))
|
||||
|
@ -302,22 +302,22 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
}
|
||||
|
||||
bool srcIsSignedInt =
|
||||
srcType == ISrcDstFmt.S8 ||
|
||||
srcType == ISrcDstFmt.S16 ||
|
||||
srcType == ISrcDstFmt.S32;
|
||||
srcType is ISrcDstFmt.S8 or
|
||||
ISrcDstFmt.S16 or
|
||||
ISrcDstFmt.S32;
|
||||
bool dstIsSignedInt =
|
||||
dstType == ISrcDstFmt.S8 ||
|
||||
dstType == ISrcDstFmt.S16 ||
|
||||
dstType == ISrcDstFmt.S32;
|
||||
dstType is ISrcDstFmt.S8 or
|
||||
ISrcDstFmt.S16 or
|
||||
ISrcDstFmt.S32;
|
||||
bool srcIsSmallInt =
|
||||
srcType == ISrcDstFmt.U16 ||
|
||||
srcType == ISrcDstFmt.S16 ||
|
||||
srcType == ISrcDstFmt.U8 ||
|
||||
srcType == ISrcDstFmt.S8;
|
||||
srcType is ISrcDstFmt.U16 or
|
||||
ISrcDstFmt.S16 or
|
||||
ISrcDstFmt.U8 or
|
||||
ISrcDstFmt.S8;
|
||||
|
||||
if (srcIsSmallInt)
|
||||
{
|
||||
int size = srcType == ISrcDstFmt.U16 || srcType == ISrcDstFmt.S16 ? 16 : 8;
|
||||
int size = srcType is ISrcDstFmt.U16 or ISrcDstFmt.S16 ? 16 : 8;
|
||||
|
||||
src = srcIsSignedInt
|
||||
? context.BitfieldExtractS32(src, Const((int)byteSelection * 8), Const(size))
|
||||
|
|
|
@ -534,7 +534,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
{
|
||||
res = Const(IrConsts.False);
|
||||
}
|
||||
else if (cond == FComp.Nan || cond == FComp.Num)
|
||||
else if (cond is FComp.Nan or FComp.Num)
|
||||
{
|
||||
res = context.BitwiseOr(context.IsNan(srcA, fpType), context.IsNan(srcB, fpType));
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
Operand slot = Const(op.CbufSlot);
|
||||
Operand srcA = GetSrcReg(context, op.SrcA);
|
||||
|
||||
if (op.AddressMode == AddressMode.Is || op.AddressMode == AddressMode.Isl)
|
||||
if (op.AddressMode is AddressMode.Is or AddressMode.Isl)
|
||||
{
|
||||
slot = context.IAdd(slot, context.BitfieldExtractU32(srcA, Const(16), Const(16)));
|
||||
srcA = context.BitwiseAnd(srcA, Const(0xffff));
|
||||
|
@ -213,7 +213,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
switch (op)
|
||||
{
|
||||
case AtomOp.Add:
|
||||
if (type == AtomSize.S32 || type == AtomSize.U32)
|
||||
if (type is AtomSize.S32 or AtomSize.U32)
|
||||
{
|
||||
res = context.AtomicAdd(storageKind, e0, e1, value);
|
||||
}
|
||||
|
@ -221,6 +221,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
{
|
||||
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}.");
|
||||
}
|
||||
|
||||
break;
|
||||
case AtomOp.Min:
|
||||
if (type == AtomSize.S32)
|
||||
|
@ -235,6 +236,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
{
|
||||
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}.");
|
||||
}
|
||||
|
||||
break;
|
||||
case AtomOp.Max:
|
||||
if (type == AtomSize.S32)
|
||||
|
@ -249,9 +251,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
{
|
||||
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}.");
|
||||
}
|
||||
|
||||
break;
|
||||
case AtomOp.And:
|
||||
if (type == AtomSize.S32 || type == AtomSize.U32)
|
||||
if (type is AtomSize.S32 or AtomSize.U32)
|
||||
{
|
||||
res = context.AtomicAnd(storageKind, e0, e1, value);
|
||||
}
|
||||
|
@ -259,9 +262,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
{
|
||||
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}.");
|
||||
}
|
||||
|
||||
break;
|
||||
case AtomOp.Or:
|
||||
if (type == AtomSize.S32 || type == AtomSize.U32)
|
||||
if (type is AtomSize.S32 or AtomSize.U32)
|
||||
{
|
||||
res = context.AtomicOr(storageKind, e0, e1, value);
|
||||
}
|
||||
|
@ -269,9 +273,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
{
|
||||
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}.");
|
||||
}
|
||||
|
||||
break;
|
||||
case AtomOp.Xor:
|
||||
if (type == AtomSize.S32 || type == AtomSize.U32)
|
||||
if (type is AtomSize.S32 or AtomSize.U32)
|
||||
{
|
||||
res = context.AtomicXor(storageKind, e0, e1, value);
|
||||
}
|
||||
|
@ -279,9 +284,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
{
|
||||
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}.");
|
||||
}
|
||||
|
||||
break;
|
||||
case AtomOp.Exch:
|
||||
if (type == AtomSize.S32 || type == AtomSize.U32)
|
||||
if (type is AtomSize.S32 or AtomSize.U32)
|
||||
{
|
||||
res = context.AtomicSwap(storageKind, e0, e1, value);
|
||||
}
|
||||
|
@ -289,6 +295,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
{
|
||||
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}.");
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
context.TranslatorContext.GpuAccessor.Log($"Invalid atomic operation: {op}.");
|
||||
|
|
|
@ -92,14 +92,14 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
break;
|
||||
|
||||
case SReg.InvocationInfo:
|
||||
if (context.TranslatorContext.Definitions.Stage != ShaderStage.Compute && context.TranslatorContext.Definitions.Stage != ShaderStage.Fragment)
|
||||
if (context.TranslatorContext.Definitions.Stage is not ShaderStage.Compute and not ShaderStage.Fragment)
|
||||
{
|
||||
// Note: Lowest 8-bits seems to contain some primitive index,
|
||||
// but it seems to be NVIDIA implementation specific as it's only used
|
||||
// to calculate ISBE offsets, so we can just keep it as zero.
|
||||
|
||||
if (context.TranslatorContext.Definitions.Stage == ShaderStage.TessellationControl ||
|
||||
context.TranslatorContext.Definitions.Stage == ShaderStage.TessellationEvaluation)
|
||||
if (context.TranslatorContext.Definitions.Stage is ShaderStage.TessellationControl or
|
||||
ShaderStage.TessellationEvaluation)
|
||||
{
|
||||
src = context.ShiftLeft(context.Load(StorageKind.Input, IoVariable.PatchVertices), Const(16));
|
||||
}
|
||||
|
@ -112,6 +112,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
{
|
||||
src = Const(0);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SReg.TId:
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
bool left,
|
||||
bool writeCC)
|
||||
{
|
||||
bool isLongShift = maxShift == MaxShift.U64 || maxShift == MaxShift.S64;
|
||||
bool isLongShift = maxShift is MaxShift.U64 or MaxShift.S64;
|
||||
bool signedShift = maxShift == MaxShift.S64;
|
||||
int maxShiftConst = isLongShift ? 64 : 32;
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
}
|
||||
|
||||
// TODO: FP and 64-bit formats.
|
||||
TextureFormat format = size == SuatomSize.Sd32 || size == SuatomSize.Sd64
|
||||
TextureFormat format = size is SuatomSize.Sd32 or SuatomSize.Sd64
|
||||
? (isBindless ? TextureFormat.Unknown : ShaderProperties.GetTextureFormatAtomic(context.TranslatorContext.GpuAccessor, imm))
|
||||
: GetTextureFormat(size);
|
||||
|
||||
|
@ -537,7 +537,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
}
|
||||
|
||||
// TODO: FP and 64-bit formats.
|
||||
TextureFormat format = size == SuatomSize.Sd32 || size == SuatomSize.Sd64
|
||||
TextureFormat format = size is SuatomSize.Sd32 or SuatomSize.Sd64
|
||||
? (isBindless ? TextureFormat.Unknown : ShaderProperties.GetTextureFormatAtomic(context.TranslatorContext.GpuAccessor, imm))
|
||||
: GetTextureFormat(size);
|
||||
|
||||
|
|
|
@ -284,7 +284,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
flags |= TextureFlags.Offset;
|
||||
}
|
||||
|
||||
if (lodMode == Lod.Lb || lodMode == Lod.Lba)
|
||||
if (lodMode is Lod.Lb or Lod.Lba)
|
||||
{
|
||||
sourcesList.Add(lodValue);
|
||||
|
||||
|
@ -504,6 +504,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
|
||||
sourcesList.Add(ConstF(0));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case TldsTarget.Texture1DLodLevel:
|
||||
|
@ -694,10 +695,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
}
|
||||
|
||||
bool isArray =
|
||||
dimensions == TexDim.Array1d ||
|
||||
dimensions == TexDim.Array2d ||
|
||||
dimensions == TexDim.Array3d ||
|
||||
dimensions == TexDim.ArrayCube;
|
||||
dimensions is TexDim.Array1d or
|
||||
TexDim.Array2d or
|
||||
TexDim.Array3d or
|
||||
TexDim.ArrayCube;
|
||||
|
||||
Operand arrayIndex = isArray ? Ra() : null;
|
||||
|
||||
|
@ -736,7 +737,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
|
||||
Operand[] packedOffs = new Operand[2];
|
||||
|
||||
bool hasAnyOffset = offset == TexOffset.Aoffi || offset == TexOffset.Ptp;
|
||||
bool hasAnyOffset = offset is TexOffset.Aoffi or TexOffset.Ptp;
|
||||
|
||||
packedOffs[0] = hasAnyOffset ? Rb() : null;
|
||||
packedOffs[1] = offset == TexOffset.Ptp ? Rb() : null;
|
||||
|
@ -849,10 +850,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
int coordsCount = type.GetDimensions();
|
||||
|
||||
bool isArray =
|
||||
dimensions == TexDim.Array1d ||
|
||||
dimensions == TexDim.Array2d ||
|
||||
dimensions == TexDim.Array3d ||
|
||||
dimensions == TexDim.ArrayCube;
|
||||
dimensions is TexDim.Array1d or
|
||||
TexDim.Array2d or
|
||||
TexDim.Array3d or
|
||||
TexDim.ArrayCube;
|
||||
|
||||
Operand arrayIndex = isArray ? Ra() : null;
|
||||
|
||||
|
@ -993,10 +994,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
Operand packedParams = Ra();
|
||||
|
||||
bool isArray =
|
||||
dimensions == TexDim.Array1d ||
|
||||
dimensions == TexDim.Array2d ||
|
||||
dimensions == TexDim.Array3d ||
|
||||
dimensions == TexDim.ArrayCube;
|
||||
dimensions is TexDim.Array1d or
|
||||
TexDim.Array2d or
|
||||
TexDim.Array3d or
|
||||
TexDim.ArrayCube;
|
||||
|
||||
if (isArray)
|
||||
{
|
||||
|
@ -1143,6 +1144,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
context.Copy(d, context.TextureQuerySize(type, flags, setAndBinding, compIndex, sources));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case TexQuery.TexHeaderTextureType:
|
||||
|
@ -1174,6 +1176,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
context.Copy(d, context.TextureQuerySamples(type, flags, setAndBinding, sources));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -179,19 +179,19 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
|
|||
public static bool IsTextureQuery(this Instruction inst)
|
||||
{
|
||||
inst &= Instruction.Mask;
|
||||
return inst == Instruction.Lod || inst == Instruction.TextureQuerySamples || inst == Instruction.TextureQuerySize;
|
||||
return inst is Instruction.Lod or Instruction.TextureQuerySamples or Instruction.TextureQuerySize;
|
||||
}
|
||||
|
||||
public static bool IsImage(this Instruction inst)
|
||||
{
|
||||
inst &= Instruction.Mask;
|
||||
return inst == Instruction.ImageAtomic || inst == Instruction.ImageLoad || inst == Instruction.ImageStore;
|
||||
return inst is Instruction.ImageAtomic or Instruction.ImageLoad or Instruction.ImageStore;
|
||||
}
|
||||
|
||||
public static bool IsImageStore(this Instruction inst)
|
||||
{
|
||||
inst &= Instruction.Mask;
|
||||
return inst == Instruction.ImageAtomic || inst == Instruction.ImageStore;
|
||||
return inst is Instruction.ImageAtomic or Instruction.ImageStore;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,22 +24,22 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
|
|||
{
|
||||
public static bool IsInputOrOutput(this StorageKind storageKind)
|
||||
{
|
||||
return storageKind == StorageKind.Input ||
|
||||
storageKind == StorageKind.InputPerPatch ||
|
||||
storageKind == StorageKind.Output ||
|
||||
storageKind == StorageKind.OutputPerPatch;
|
||||
return storageKind is StorageKind.Input or
|
||||
StorageKind.InputPerPatch or
|
||||
StorageKind.Output or
|
||||
StorageKind.OutputPerPatch;
|
||||
}
|
||||
|
||||
public static bool IsOutput(this StorageKind storageKind)
|
||||
{
|
||||
return storageKind == StorageKind.Output ||
|
||||
storageKind == StorageKind.OutputPerPatch;
|
||||
return storageKind is StorageKind.Output or
|
||||
StorageKind.OutputPerPatch;
|
||||
}
|
||||
|
||||
public static bool IsPerPatch(this StorageKind storageKind)
|
||||
{
|
||||
return storageKind == StorageKind.InputPerPatch ||
|
||||
storageKind == StorageKind.OutputPerPatch;
|
||||
return storageKind is StorageKind.InputPerPatch or
|
||||
StorageKind.OutputPerPatch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ using System.Diagnostics.CodeAnalysis;
|
|||
namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
|
||||
{
|
||||
[Flags]
|
||||
[SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
|
||||
enum TextureFlags
|
||||
{
|
||||
None = 0,
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Shader
|
|||
/// <returns>True if the shader stage supports render scale, false otherwise</returns>
|
||||
public static bool SupportsRenderScale(this ShaderStage stage)
|
||||
{
|
||||
return stage == ShaderStage.Vertex || stage == ShaderStage.Fragment || stage == ShaderStage.Compute;
|
||||
return stage is ShaderStage.Vertex or ShaderStage.Fragment or ShaderStage.Compute;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -31,10 +31,10 @@ namespace Ryujinx.Graphics.Shader
|
|||
/// <returns>True if the shader stage is vertex, tessellation or geometry, false otherwise</returns>
|
||||
public static bool IsVtg(this ShaderStage stage)
|
||||
{
|
||||
return stage == ShaderStage.Vertex ||
|
||||
stage == ShaderStage.TessellationControl ||
|
||||
stage == ShaderStage.TessellationEvaluation ||
|
||||
stage == ShaderStage.Geometry;
|
||||
return stage is ShaderStage.Vertex or
|
||||
ShaderStage.TessellationControl or
|
||||
ShaderStage.TessellationEvaluation or
|
||||
ShaderStage.Geometry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,8 +102,8 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
|||
return false;
|
||||
}
|
||||
|
||||
IAstNode block;
|
||||
IAstNode other;
|
||||
AstNode block;
|
||||
AstNode other;
|
||||
|
||||
int blockLvl, otherLvl;
|
||||
|
||||
|
@ -441,7 +441,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
|||
return path.ToArray();
|
||||
}
|
||||
|
||||
private static int Level(IAstNode node)
|
||||
private static int Level(AstNode node)
|
||||
{
|
||||
int level = 0;
|
||||
|
||||
|
|
|
@ -150,11 +150,11 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
|||
{
|
||||
// TODO: Return correct type depending on source index,
|
||||
// that can improve the decompiler output.
|
||||
if (inst == Instruction.ImageLoad ||
|
||||
inst == Instruction.ImageStore ||
|
||||
inst == Instruction.ImageAtomic ||
|
||||
inst == Instruction.Lod ||
|
||||
inst == Instruction.TextureSample)
|
||||
if (inst is Instruction.ImageLoad or
|
||||
Instruction.ImageStore or
|
||||
Instruction.ImageAtomic or
|
||||
Instruction.Lod or
|
||||
Instruction.TextureSample)
|
||||
{
|
||||
return AggregateType.FP32;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
|||
|
||||
private static bool FormatSupportsAtomic(TextureFormat format)
|
||||
{
|
||||
return format == TextureFormat.R32Sint || format == TextureFormat.R32Uint;
|
||||
return format is TextureFormat.R32Sint or TextureFormat.R32Uint;
|
||||
}
|
||||
|
||||
public static TextureFormat GetTextureFormatAtomic(IGpuAccessor gpuAccessor, int handle, int cbufSlot = -1)
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
|||
Instruction inst = operation.Inst;
|
||||
StorageKind storageKind = operation.StorageKind;
|
||||
|
||||
if (inst == Instruction.Load || inst == Instruction.Store)
|
||||
if (inst is Instruction.Load or Instruction.Store)
|
||||
{
|
||||
if (storageKind.IsInputOrOutput())
|
||||
{
|
||||
|
|
|
@ -110,8 +110,8 @@ namespace Ryujinx.Graphics.Shader
|
|||
samplerHandle = samplerWordOffset;
|
||||
}
|
||||
|
||||
if (handleType == TextureHandleType.SeparateSamplerId ||
|
||||
handleType == TextureHandleType.SeparateConstantSamplerHandle)
|
||||
if (handleType is TextureHandleType.SeparateSamplerId or
|
||||
TextureHandleType.SeparateConstantSamplerHandle)
|
||||
{
|
||||
samplerHandle <<= 20;
|
||||
}
|
||||
|
|
|
@ -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