[Ryujinx.Graphics.Shader] Address dotnet-format issues (#5373)

* dotnet format style --severity info

Some changes were manually reverted.

* Restore a few unused methods and variables

* Silence dotnet format IDE0060 warnings

* Silence dotnet format IDE0052 warnings

* Silence dotnet format IDE0059 warnings

* Address or silence dotnet format CA1069 warnings

* Address or silence dotnet format CA2211 warnings

* Address review comments

* Fix formatting for switch expressions

* Address most dotnet format whitespace warnings

* Apply dotnet format whitespace formatting

A few of them have been manually reverted and the corresponding warning was silenced

* Format if-blocks correctly

* Run dotnet format whitespace after rebase

* Run dotnet format style after rebase

* Run dotnet format whitespace after rebase

* Run dotnet format style after rebase

* Run dotnet format after rebase and remove unused usings

- analyzers
- style
- whitespace

* Disable 'prefer switch expression' rule

* Add comments to disabled warnings

* Fix naming rule violation, Convert shader properties to auto-property and convert values to const

* Simplify properties and array initialization, Use const when possible, Remove trailing commas

* Run dotnet format after rebase

* Address IDE0251 warnings

* Address a few disabled IDE0060 warnings

* Silence IDE0060 in .editorconfig

* Run dotnet format after rebase

* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"

This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.

* dotnet format whitespace after rebase

* First dotnet format pass

* Fix naming rule violations

* Add trailing commas

* Remove unused members and most unnecessary value assignments

* Remove more unnecessary assignments

* Remove NRE suppressor
This commit is contained in:
TSRBerry 2023-06-28 08:59:13 +02:00 committed by GitHub
parent e055217292
commit 9becbd7d72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
162 changed files with 1611 additions and 1627 deletions

View file

@ -1,7 +1,6 @@
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
using System.Collections.Generic;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
namespace Ryujinx.Graphics.Shader.Instructions
@ -21,10 +20,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
Tessellation = TessellationControl | TessellationEvaluation,
VertexTessellationGeometry = Vertex | Tessellation | Geometry,
TessellationGeometryFragment = Tessellation | Geometry | Fragment,
AllGraphics = Vertex | Tessellation | Geometry | Fragment
AllGraphics = Vertex | Tessellation | Geometry | Fragment,
}
private struct AttributeEntry
private readonly struct AttributeEntry
{
public int BaseOffset { get; }
public AggregateType Type { get; }
@ -344,8 +343,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
AggregateType.Vector2 => 2,
AggregateType.Vector3 => 3,
AggregateType.Vector4 => 4,
_ => 1
_ => 1,
};
}
}
}
}

View file

@ -7,352 +7,352 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
public static void AtomCas(EmitterContext context)
{
InstAtomCas op = context.GetOp<InstAtomCas>();
context.GetOp<InstAtomCas>();
context.Config.GpuAccessor.Log("Shader instruction AtomCas is not implemented.");
}
public static void AtomsCas(EmitterContext context)
{
InstAtomsCas op = context.GetOp<InstAtomsCas>();
context.GetOp<InstAtomsCas>();
context.Config.GpuAccessor.Log("Shader instruction AtomsCas is not implemented.");
}
public static void B2r(EmitterContext context)
{
InstB2r op = context.GetOp<InstB2r>();
context.GetOp<InstB2r>();
context.Config.GpuAccessor.Log("Shader instruction B2r is not implemented.");
}
public static void Bpt(EmitterContext context)
{
InstBpt op = context.GetOp<InstBpt>();
context.GetOp<InstBpt>();
context.Config.GpuAccessor.Log("Shader instruction Bpt is not implemented.");
}
public static void Cctl(EmitterContext context)
{
InstCctl op = context.GetOp<InstCctl>();
context.GetOp<InstCctl>();
context.Config.GpuAccessor.Log("Shader instruction Cctl is not implemented.");
}
public static void Cctll(EmitterContext context)
{
InstCctll op = context.GetOp<InstCctll>();
context.GetOp<InstCctll>();
context.Config.GpuAccessor.Log("Shader instruction Cctll is not implemented.");
}
public static void Cctlt(EmitterContext context)
{
InstCctlt op = context.GetOp<InstCctlt>();
context.GetOp<InstCctlt>();
context.Config.GpuAccessor.Log("Shader instruction Cctlt is not implemented.");
}
public static void Cs2r(EmitterContext context)
{
InstCs2r op = context.GetOp<InstCs2r>();
context.GetOp<InstCs2r>();
context.Config.GpuAccessor.Log("Shader instruction Cs2r is not implemented.");
}
public static void FchkR(EmitterContext context)
{
InstFchkR op = context.GetOp<InstFchkR>();
context.GetOp<InstFchkR>();
context.Config.GpuAccessor.Log("Shader instruction FchkR is not implemented.");
}
public static void FchkI(EmitterContext context)
{
InstFchkI op = context.GetOp<InstFchkI>();
context.GetOp<InstFchkI>();
context.Config.GpuAccessor.Log("Shader instruction FchkI is not implemented.");
}
public static void FchkC(EmitterContext context)
{
InstFchkC op = context.GetOp<InstFchkC>();
context.GetOp<InstFchkC>();
context.Config.GpuAccessor.Log("Shader instruction FchkC is not implemented.");
}
public static void Getcrsptr(EmitterContext context)
{
InstGetcrsptr op = context.GetOp<InstGetcrsptr>();
context.GetOp<InstGetcrsptr>();
context.Config.GpuAccessor.Log("Shader instruction Getcrsptr is not implemented.");
}
public static void Getlmembase(EmitterContext context)
{
InstGetlmembase op = context.GetOp<InstGetlmembase>();
context.GetOp<InstGetlmembase>();
context.Config.GpuAccessor.Log("Shader instruction Getlmembase is not implemented.");
}
public static void Ide(EmitterContext context)
{
InstIde op = context.GetOp<InstIde>();
context.GetOp<InstIde>();
context.Config.GpuAccessor.Log("Shader instruction Ide is not implemented.");
}
public static void IdpR(EmitterContext context)
{
InstIdpR op = context.GetOp<InstIdpR>();
context.GetOp<InstIdpR>();
context.Config.GpuAccessor.Log("Shader instruction IdpR is not implemented.");
}
public static void IdpC(EmitterContext context)
{
InstIdpC op = context.GetOp<InstIdpC>();
context.GetOp<InstIdpC>();
context.Config.GpuAccessor.Log("Shader instruction IdpC is not implemented.");
}
public static void ImadspR(EmitterContext context)
{
InstImadspR op = context.GetOp<InstImadspR>();
context.GetOp<InstImadspR>();
context.Config.GpuAccessor.Log("Shader instruction ImadspR is not implemented.");
}
public static void ImadspI(EmitterContext context)
{
InstImadspI op = context.GetOp<InstImadspI>();
context.GetOp<InstImadspI>();
context.Config.GpuAccessor.Log("Shader instruction ImadspI is not implemented.");
}
public static void ImadspC(EmitterContext context)
{
InstImadspC op = context.GetOp<InstImadspC>();
context.GetOp<InstImadspC>();
context.Config.GpuAccessor.Log("Shader instruction ImadspC is not implemented.");
}
public static void ImadspRc(EmitterContext context)
{
InstImadspRc op = context.GetOp<InstImadspRc>();
context.GetOp<InstImadspRc>();
context.Config.GpuAccessor.Log("Shader instruction ImadspRc is not implemented.");
}
public static void Jcal(EmitterContext context)
{
InstJcal op = context.GetOp<InstJcal>();
context.GetOp<InstJcal>();
context.Config.GpuAccessor.Log("Shader instruction Jcal is not implemented.");
}
public static void Jmp(EmitterContext context)
{
InstJmp op = context.GetOp<InstJmp>();
context.GetOp<InstJmp>();
context.Config.GpuAccessor.Log("Shader instruction Jmp is not implemented.");
}
public static void Jmx(EmitterContext context)
{
InstJmx op = context.GetOp<InstJmx>();
context.GetOp<InstJmx>();
context.Config.GpuAccessor.Log("Shader instruction Jmx is not implemented.");
}
public static void Ld(EmitterContext context)
{
InstLd op = context.GetOp<InstLd>();
context.GetOp<InstLd>();
context.Config.GpuAccessor.Log("Shader instruction Ld is not implemented.");
}
public static void Lepc(EmitterContext context)
{
InstLepc op = context.GetOp<InstLepc>();
context.GetOp<InstLepc>();
context.Config.GpuAccessor.Log("Shader instruction Lepc is not implemented.");
}
public static void Longjmp(EmitterContext context)
{
InstLongjmp op = context.GetOp<InstLongjmp>();
context.GetOp<InstLongjmp>();
context.Config.GpuAccessor.Log("Shader instruction Longjmp is not implemented.");
}
public static void Pexit(EmitterContext context)
{
InstPexit op = context.GetOp<InstPexit>();
context.GetOp<InstPexit>();
context.Config.GpuAccessor.Log("Shader instruction Pexit is not implemented.");
}
public static void Pixld(EmitterContext context)
{
InstPixld op = context.GetOp<InstPixld>();
context.GetOp<InstPixld>();
context.Config.GpuAccessor.Log("Shader instruction Pixld is not implemented.");
}
public static void Plongjmp(EmitterContext context)
{
InstPlongjmp op = context.GetOp<InstPlongjmp>();
context.GetOp<InstPlongjmp>();
context.Config.GpuAccessor.Log("Shader instruction Plongjmp is not implemented.");
}
public static void Pret(EmitterContext context)
{
InstPret op = context.GetOp<InstPret>();
context.GetOp<InstPret>();
context.Config.GpuAccessor.Log("Shader instruction Pret is not implemented.");
}
public static void PrmtR(EmitterContext context)
{
InstPrmtR op = context.GetOp<InstPrmtR>();
context.GetOp<InstPrmtR>();
context.Config.GpuAccessor.Log("Shader instruction PrmtR is not implemented.");
}
public static void PrmtI(EmitterContext context)
{
InstPrmtI op = context.GetOp<InstPrmtI>();
context.GetOp<InstPrmtI>();
context.Config.GpuAccessor.Log("Shader instruction PrmtI is not implemented.");
}
public static void PrmtC(EmitterContext context)
{
InstPrmtC op = context.GetOp<InstPrmtC>();
context.GetOp<InstPrmtC>();
context.Config.GpuAccessor.Log("Shader instruction PrmtC is not implemented.");
}
public static void PrmtRc(EmitterContext context)
{
InstPrmtRc op = context.GetOp<InstPrmtRc>();
context.GetOp<InstPrmtRc>();
context.Config.GpuAccessor.Log("Shader instruction PrmtRc is not implemented.");
}
public static void R2b(EmitterContext context)
{
InstR2b op = context.GetOp<InstR2b>();
context.GetOp<InstR2b>();
context.Config.GpuAccessor.Log("Shader instruction R2b is not implemented.");
}
public static void Ram(EmitterContext context)
{
InstRam op = context.GetOp<InstRam>();
context.GetOp<InstRam>();
context.Config.GpuAccessor.Log("Shader instruction Ram is not implemented.");
}
public static void Rtt(EmitterContext context)
{
InstRtt op = context.GetOp<InstRtt>();
context.GetOp<InstRtt>();
context.Config.GpuAccessor.Log("Shader instruction Rtt is not implemented.");
}
public static void Sam(EmitterContext context)
{
InstSam op = context.GetOp<InstSam>();
context.GetOp<InstSam>();
context.Config.GpuAccessor.Log("Shader instruction Sam is not implemented.");
}
public static void Setcrsptr(EmitterContext context)
{
InstSetcrsptr op = context.GetOp<InstSetcrsptr>();
context.GetOp<InstSetcrsptr>();
context.Config.GpuAccessor.Log("Shader instruction Setcrsptr is not implemented.");
}
public static void Setlmembase(EmitterContext context)
{
InstSetlmembase op = context.GetOp<InstSetlmembase>();
context.GetOp<InstSetlmembase>();
context.Config.GpuAccessor.Log("Shader instruction Setlmembase is not implemented.");
}
public static void St(EmitterContext context)
{
InstSt op = context.GetOp<InstSt>();
context.GetOp<InstSt>();
context.Config.GpuAccessor.Log("Shader instruction St is not implemented.");
}
public static void Stp(EmitterContext context)
{
InstStp op = context.GetOp<InstStp>();
context.GetOp<InstStp>();
context.Config.GpuAccessor.Log("Shader instruction Stp is not implemented.");
}
public static void Txa(EmitterContext context)
{
InstTxa op = context.GetOp<InstTxa>();
context.GetOp<InstTxa>();
context.Config.GpuAccessor.Log("Shader instruction Txa is not implemented.");
}
public static void Vabsdiff(EmitterContext context)
{
InstVabsdiff op = context.GetOp<InstVabsdiff>();
context.GetOp<InstVabsdiff>();
context.Config.GpuAccessor.Log("Shader instruction Vabsdiff is not implemented.");
}
public static void Vabsdiff4(EmitterContext context)
{
InstVabsdiff4 op = context.GetOp<InstVabsdiff4>();
context.GetOp<InstVabsdiff4>();
context.Config.GpuAccessor.Log("Shader instruction Vabsdiff4 is not implemented.");
}
public static void Vadd(EmitterContext context)
{
InstVadd op = context.GetOp<InstVadd>();
context.GetOp<InstVadd>();
context.Config.GpuAccessor.Log("Shader instruction Vadd is not implemented.");
}
public static void Votevtg(EmitterContext context)
{
InstVotevtg op = context.GetOp<InstVotevtg>();
context.GetOp<InstVotevtg>();
context.Config.GpuAccessor.Log("Shader instruction Votevtg is not implemented.");
}
public static void Vset(EmitterContext context)
{
InstVset op = context.GetOp<InstVset>();
context.GetOp<InstVset>();
context.Config.GpuAccessor.Log("Shader instruction Vset is not implemented.");
}
public static void Vshl(EmitterContext context)
{
InstVshl op = context.GetOp<InstVshl>();
context.GetOp<InstVshl>();
context.Config.GpuAccessor.Log("Shader instruction Vshl is not implemented.");
}
public static void Vshr(EmitterContext context)
{
InstVshr op = context.GetOp<InstVshr>();
context.GetOp<InstVshr>();
context.Config.GpuAccessor.Log("Shader instruction Vshr is not implemented.");
}
}
}
}

View file

@ -2,7 +2,6 @@ using Ryujinx.Graphics.Shader.Decoders;
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
using System;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
@ -18,7 +17,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
IDstFmt.S16 => short.MinValue,
IDstFmt.U32 => uint.MinValue,
IDstFmt.S32 => int.MinValue,
_ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type.")
_ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type."),
};
}
@ -30,7 +29,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
IDstFmt.S16 => short.MaxValue,
IDstFmt.U32 => uint.MaxValue,
IDstFmt.S32 => int.MaxValue,
_ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type.")
_ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type."),
};
}
@ -44,7 +43,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
ISrcDstFmt.S16 => short.MinValue,
ISrcDstFmt.U32 => uint.MinValue,
ISrcDstFmt.S32 => int.MinValue,
_ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type.")
_ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type."),
};
}
@ -58,7 +57,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
ISrcDstFmt.S16 => short.MaxValue,
ISrcDstFmt.U32 => uint.MaxValue,
ISrcDstFmt.S32 => int.MaxValue,
_ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type.")
_ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type."),
};
}
@ -69,7 +68,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
BoolOp.And => context.BitwiseAnd(input, pred),
BoolOp.Or => context.BitwiseOr(input, pred),
BoolOp.Xor => context.BitwiseExclusiveOr(input, pred),
_ => input
_ => input,
};
}
@ -89,7 +88,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
VectorSelect.S8B3 => SignExtendTo32(context, context.ShiftRightU32(src, Const(24)), 8),
VectorSelect.S16H0 => SignExtendTo32(context, context.ShiftRightU32(src, Const(0)), 16),
VectorSelect.S16H1 => SignExtendTo32(context, context.ShiftRightU32(src, Const(16)), 16),
_ => src
_ => src,
};
}
@ -134,7 +133,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
}
context.Copy(GetZF(), context.FPCompareEqual(dest, zero, fpType));
context.Copy(GetNF(), context.FPCompareLess (dest, zero, fpType));
context.Copy(GetNF(), context.FPCompareLess(dest, zero, fpType));
}
}
@ -157,4 +156,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
return result;
}
}
}
}

View file

@ -33,7 +33,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
for (int index = 0; index < (int)op.AlSize + 1; index++)
{
Register rd = new Register(op.Dest + index, RegisterType.Gpr);
Register rd = new(op.Dest + index, RegisterType.Gpr);
if (rd.IsRZ)
{
@ -91,7 +91,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
break;
}
Register rd = new Register(op.SrcB + index, RegisterType.Gpr);
Register rd = new(op.SrcB + index, RegisterType.Gpr);
if (op.Phys)
{
@ -380,4 +380,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
return false;
}
}
}
}

View file

@ -22,7 +22,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
public static void Depbar(EmitterContext context)
{
#pragma warning disable IDE0059 // Remove unnecessary value assignment
InstDepbar op = context.GetOp<InstDepbar>();
#pragma warning restore IDE0059
// No operation.
}
@ -41,4 +43,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
}
}
}
}
}

View file

@ -191,4 +191,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
context.Copy(GetDest(rd), res);
}
}
}
}

View file

@ -1,7 +1,6 @@
using Ryujinx.Graphics.Shader.Decoders;
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitAluHelper;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
@ -80,8 +79,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
Ccc.Oft => GetVF(),
Ccc.Rle => context.BitwiseOr(GetNF(), GetZF()),
Ccc.Rgt => context.BitwiseNot(context.BitwiseOr(GetNF(), GetZF())),
_ => Const(defaultCond)
_ => Const(defaultCond),
};
}
}
}
}

View file

@ -2,7 +2,6 @@ using Ryujinx.Graphics.Shader.Decoders;
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
using System;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitAluHelper;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
@ -140,7 +139,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
IntegerRound.Floor => context.FPFloor(srcB, srcType.ToInstFPType()),
IntegerRound.Ceil => context.FPCeiling(srcB, srcType.ToInstFPType()),
IntegerRound.Trunc => context.FPTruncate(srcB, srcType.ToInstFPType()),
_ => srcB
_ => srcB,
};
}
@ -191,7 +190,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
RoundMode2.Floor => context.FPFloor(srcB, fpType),
RoundMode2.Ceil => context.FPCeiling(srcB, fpType),
RoundMode2.Trunc => context.FPTruncate(srcB, fpType),
_ => srcB
_ => srcB,
};
if (!isSignedInt)
@ -422,4 +421,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
return type == DstFmt.F64 ? Instruction.FP64 : Instruction.FP32;
}
}
}
}

View file

@ -1,7 +1,6 @@
using Ryujinx.Graphics.Shader.Decoders;
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitAluHelper;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
@ -458,7 +457,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
MultiplyScale.M2 => ConstF(2f),
MultiplyScale.M4 => ConstF(4f),
MultiplyScale.M8 => ConstF(8f),
_ => ConstF(1f) // Invalid, behave as if it had no scale.
_ => ConstF(1f), // Invalid, behave as if it had no scale.
};
if (scaleConst.AsFloat() == 1f)
@ -529,4 +528,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
context.Copy(GetDest(rd), GetHalfPacked(context, swizzle, res, rd));
}
}
}
}

View file

@ -2,7 +2,6 @@ using Ryujinx.Graphics.Shader.Decoders;
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
using System;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitAluHelper;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
@ -484,8 +483,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
}
else
{
Operand low = context.BitwiseAnd(res[0], Const(0xffff));
Operand high = context.ShiftLeft (res[1], Const(16));
Operand low = context.BitwiseAnd(res[0], Const(0xffff));
Operand high = context.ShiftLeft(res[1], Const(16));
Operand packed = context.BitwiseOr(low, high);
@ -546,20 +545,16 @@ namespace Ryujinx.Graphics.Shader.Instructions
}
else
{
Instruction inst;
switch (cond & ~FComp.Nan)
var inst = (cond & ~FComp.Nan) switch
{
case FComp.Lt: inst = Instruction.CompareLess; break;
case FComp.Eq: inst = Instruction.CompareEqual; break;
case FComp.Le: inst = Instruction.CompareLessOrEqual; break;
case FComp.Gt: inst = Instruction.CompareGreater; break;
case FComp.Ne: inst = Instruction.CompareNotEqual; break;
case FComp.Ge: inst = Instruction.CompareGreaterOrEqual; break;
default: throw new ArgumentException($"Unexpected condition \"{cond}\".");
}
FComp.Lt => Instruction.CompareLess,
FComp.Eq => Instruction.CompareEqual,
FComp.Le => Instruction.CompareLessOrEqual,
FComp.Gt => Instruction.CompareGreater,
FComp.Ne => Instruction.CompareNotEqual,
FComp.Ge => Instruction.CompareGreaterOrEqual,
_ => throw new ArgumentException($"Unexpected condition \"{cond}\"."),
};
res = context.Add(inst | fpType, Local(), srcA, srcB);
if ((cond & FComp.Nan) != 0)
@ -572,4 +567,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
return res;
}
}
}
}

View file

@ -103,4 +103,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
SetFPZnFlags(context, res, writeCC, fpType);
}
}
}
}

View file

@ -3,8 +3,6 @@ using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
using System.Collections.Generic;
using System.Linq;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
namespace Ryujinx.Graphics.Shader.Instructions
@ -13,14 +11,14 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
public static void Bra(EmitterContext context)
{
InstBra op = context.GetOp<InstBra>();
context.GetOp<InstBra>();
EmitBranch(context, context.CurrBlock.Successors[^1].Address);
}
public static void Brk(EmitterContext context)
{
InstBrk op = context.GetOp<InstBrk>();
context.GetOp<InstBrk>();
EmitBrkContSync(context);
}
@ -123,7 +121,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
public static void Cal(EmitterContext context)
{
InstCal op = context.GetOp<InstCal>();
context.GetOp<InstCal>();
DecodedFunction function = context.Program.GetFunctionByAddress(context.CurrOp.GetAbsoluteAddress());
@ -147,7 +145,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
public static void Cont(EmitterContext context)
{
InstCont op = context.GetOp<InstCont>();
context.GetOp<InstCont>();
EmitBrkContSync(context);
}
@ -185,28 +183,28 @@ namespace Ryujinx.Graphics.Shader.Instructions
public static void Kil(EmitterContext context)
{
InstKil op = context.GetOp<InstKil>();
context.GetOp<InstKil>();
context.Discard();
}
public static void Pbk(EmitterContext context)
{
InstPbk op = context.GetOp<InstPbk>();
context.GetOp<InstPbk>();
EmitPbkPcntSsy(context);
}
public static void Pcnt(EmitterContext context)
{
InstPcnt op = context.GetOp<InstPcnt>();
context.GetOp<InstPcnt>();
EmitPbkPcntSsy(context);
}
public static void Ret(EmitterContext context)
{
InstRet op = context.GetOp<InstRet>();
context.GetOp<InstRet>();
if (context.IsNonMain)
{
@ -220,14 +218,14 @@ namespace Ryujinx.Graphics.Shader.Instructions
public static void Ssy(EmitterContext context)
{
InstSsy op = context.GetOp<InstSsy>();
context.GetOp<InstSsy>();
EmitPbkPcntSsy(context);
}
public static void Sync(EmitterContext context)
{
InstSync op = context.GetOp<InstSync>();
context.GetOp<InstSync>();
EmitBrkContSync(context);
}
@ -275,7 +273,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
private static void EmitBranch(EmitterContext context, ulong address)
{
InstOp op = context.CurrOp;
InstConditional opCond = new InstConditional(op.RawOpCode);
InstConditional opCond = new(op.RawOpCode);
// If we're branching to the next instruction, then the branch
// is useless and we can ignore it.
@ -321,4 +319,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
}
}
}
}
}

View file

@ -3,7 +3,6 @@ using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
using System;
using System.Runtime.CompilerServices;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
namespace Ryujinx.Graphics.Shader.Instructions
@ -111,7 +110,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return new Operand[]
{
ConstF((float)Unsafe.As<ushort, Half>(ref low)),
ConstF((float)Unsafe.As<ushort, Half>(ref high))
ConstF((float)Unsafe.As<ushort, Half>(ref high)),
};
}
@ -123,7 +122,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return new Operand[]
{
ConstF((float)Unsafe.As<ushort, Half>(ref low)),
ConstF((float)Unsafe.As<ushort, Half>(ref high))
ConstF((float)Unsafe.As<ushort, Half>(ref high)),
};
}
@ -139,56 +138,51 @@ namespace Ryujinx.Graphics.Shader.Instructions
public static Operand[] GetHalfUnpacked(EmitterContext context, Operand src, HalfSwizzle swizzle)
{
switch (swizzle)
return swizzle switch
{
case HalfSwizzle.F16:
return new Operand[]
{
HalfSwizzle.F16 => new Operand[]
{
context.UnpackHalf2x16Low (src),
context.UnpackHalf2x16High(src)
};
case HalfSwizzle.F32: return new Operand[] { src, src };
case HalfSwizzle.H0H0:
return new Operand[]
context.UnpackHalf2x16High(src),
},
HalfSwizzle.F32 => new Operand[] { src, src },
HalfSwizzle.H0H0 => new Operand[]
{
context.UnpackHalf2x16Low(src),
context.UnpackHalf2x16Low(src)
};
case HalfSwizzle.H1H1:
return new Operand[]
context.UnpackHalf2x16Low(src),
},
HalfSwizzle.H1H1 => new Operand[]
{
context.UnpackHalf2x16High(src),
context.UnpackHalf2x16High(src)
};
}
throw new ArgumentException($"Invalid swizzle \"{swizzle}\".");
context.UnpackHalf2x16High(src),
},
_ => throw new ArgumentException($"Invalid swizzle \"{swizzle}\"."),
};
}
public static Operand GetHalfPacked(EmitterContext context, OFmt swizzle, Operand[] results, int rd)
{
switch (swizzle)
{
case OFmt.F16: return context.PackHalf2x16(results[0], results[1]);
case OFmt.F16:
return context.PackHalf2x16(results[0], results[1]);
case OFmt.F32: return results[0];
case OFmt.F32:
return results[0];
case OFmt.MrgH0:
{
Operand h1 = GetHalfDest(context, rd, isHigh: true);
{
Operand h1 = GetHalfDest(context, rd, isHigh: true);
return context.PackHalf2x16(results[0], h1);
}
return context.PackHalf2x16(results[0], h1);
}
case OFmt.MrgH1:
{
Operand h0 = GetHalfDest(context, rd, isHigh: false);
{
Operand h0 = GetHalfDest(context, rd, isHigh: false);
return context.PackHalf2x16(h0, results[1]);
}
return context.PackHalf2x16(h0, results[1]);
}
}
throw new ArgumentException($"Invalid swizzle \"{swizzle}\".");
@ -263,4 +257,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.BitwiseAnd(src, Const(mask));
}
}
}
}

View file

@ -510,7 +510,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
aLow = context.BitwiseNot(aLow);
aHigh = context.BitwiseNot(aHigh);
#pragma warning disable IDE0059 // Remove unnecessary value assignment
aLow = AddWithCarry(context, aLow, Const(1), out Operand aLowCOut);
#pragma warning restore IDE0059
aHigh = context.IAdd(aHigh, aLowCOut);
}
@ -696,4 +698,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
SetZnFlags(context, res, setCC: true, extended: extended);
}
}
}
}

View file

@ -2,7 +2,6 @@ using Ryujinx.Graphics.Shader.Decoders;
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
using System;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitAluHelper;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
@ -220,7 +219,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
else
{
res = context.ISubtract(srcA, srcB);
#pragma warning disable IDE0059 // Remove unnecessary value assignment
res = context.IAdd(res, context.BitwiseNot(GetCF()));
#pragma warning restore IDE0059
switch (cond)
{
@ -287,17 +288,25 @@ namespace Ryujinx.Graphics.Shader.Instructions
IComp.Gt => Instruction.CompareGreaterU32,
IComp.Ne => Instruction.CompareNotEqual,
IComp.Ge => Instruction.CompareGreaterOrEqualU32,
_ => throw new InvalidOperationException($"Unexpected condition \"{cond}\".")
_ => throw new InvalidOperationException($"Unexpected condition \"{cond}\"."),
};
if (isSigned)
{
switch (cond)
{
case IComp.Lt: inst = Instruction.CompareLess; break;
case IComp.Le: inst = Instruction.CompareLessOrEqual; break;
case IComp.Gt: inst = Instruction.CompareGreater; break;
case IComp.Ge: inst = Instruction.CompareGreaterOrEqual; break;
case IComp.Lt:
inst = Instruction.CompareLess;
break;
case IComp.Le:
inst = Instruction.CompareLessOrEqual;
break;
case IComp.Gt:
inst = Instruction.CompareGreater;
break;
case IComp.Ge:
inst = Instruction.CompareGreaterOrEqual;
break;
}
}
@ -307,4 +316,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
return res;
}
}
}
}

View file

@ -1,7 +1,6 @@
using Ryujinx.Graphics.Shader.Decoders;
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitAluHelper;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
@ -103,10 +102,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand res = logicOp switch
{
LogicOp.And => res = context.BitwiseAnd(srcA, srcB),
LogicOp.Or => res = context.BitwiseOr(srcA, srcB),
LogicOp.Xor => res = context.BitwiseExclusiveOr(srcA, srcB),
_ => srcB
LogicOp.And => context.BitwiseAnd(srcA, srcB),
LogicOp.Or => context.BitwiseOr(srcA, srcB),
LogicOp.Xor => context.BitwiseExclusiveOr(srcA, srcB),
_ => srcB,
};
EmitLopPredWrite(context, res, predOp, destPred);
@ -164,4 +163,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
}
}
}
}
}

View file

@ -68,4 +68,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
// TODO: X flags.
}
}
}
}

View file

@ -2,7 +2,6 @@ using Ryujinx.Graphics.Shader.Decoders;
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
using System.Numerics;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
@ -48,7 +47,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
AtomsSize.S32 => AtomSize.S32,
AtomsSize.U64 => AtomSize.U64,
AtomsSize.S64 => AtomSize.S64,
_ => AtomSize.U32
_ => AtomSize.U32,
};
Operand id = Const(context.Config.ResourceManager.SharedMemoryId);
@ -85,7 +84,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
for (int index = 0; index < count; index++)
{
Register dest = new Register(op.Dest + index, RegisterType.Gpr);
Register dest = new(op.Dest + index, RegisterType.Gpr);
if (dest.IsRZ)
{
@ -309,14 +308,14 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
LsSize2.B64 => 2,
LsSize2.B128 => 4,
_ => 1
_ => 1,
};
Operand baseOffset = context.Copy(srcA);
for (int index = 0; index < count; index++)
{
Register dest = new Register(rd + index, RegisterType.Gpr);
Register dest = new(rd + index, RegisterType.Gpr);
if (dest.IsRZ)
{
@ -354,7 +353,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
for (int index = 0; index < count; index++)
{
Register dest = new Register(rd + index, RegisterType.Gpr);
Register dest = new(rd + index, RegisterType.Gpr);
if (dest.IsRZ)
{
@ -390,7 +389,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
LsSize2.B64 => 2,
LsSize2.B128 => 4,
_ => 1
_ => 1,
};
Operand baseOffset = context.Copy(srcA);
@ -476,22 +475,18 @@ namespace Ryujinx.Graphics.Shader.Instructions
LsSize.S8 => StorageKind.GlobalMemoryS8,
LsSize.U16 => StorageKind.GlobalMemoryU16,
LsSize.S16 => StorageKind.GlobalMemoryS16,
_ => StorageKind.GlobalMemory
_ => StorageKind.GlobalMemory,
};
}
private static int GetVectorCount(LsSize size)
{
switch (size)
return size switch
{
case LsSize.B64:
return 2;
case LsSize.B128:
case LsSize.UB128:
return 4;
}
return 1;
LsSize.B64 => 2,
LsSize.B128 or LsSize.UB128 => 4,
_ => 1,
};
}
private static (Operand, Operand) Get40BitsAddress(
@ -544,10 +539,18 @@ namespace Ryujinx.Graphics.Shader.Instructions
switch (size)
{
case LsSize.U8: value = ZeroExtendTo32(context, value, 8); break;
case LsSize.U16: value = ZeroExtendTo32(context, value, 16); break;
case LsSize.S8: value = SignExtendTo32(context, value, 8); break;
case LsSize.S16: value = SignExtendTo32(context, value, 16); break;
case LsSize.U8:
value = ZeroExtendTo32(context, value, 8);
break;
case LsSize.U16:
value = ZeroExtendTo32(context, value, 16);
break;
case LsSize.S8:
value = SignExtendTo32(context, value, 8);
break;
case LsSize.S16:
value = SignExtendTo32(context, value, 16);
break;
}
return value;
@ -578,4 +581,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
return value;
}
}
}
}

View file

@ -212,7 +212,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
int count = ccpr ? RegisterConsts.FlagsCount : RegisterConsts.PredsCount;
RegisterType type = ccpr ? RegisterType.Flag : RegisterType.Predicate;
int shift = (int)byteSel * 8;
for (int bit = 0; bit < count; bit++)
{
Operand flag = Register(bit, type);
@ -228,4 +228,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
context.Copy(GetDest(rd), res);
}
}
}
}

View file

@ -94,4 +94,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
context.Copy(GetDest(rd), srcB);
}
}
}
}

View file

@ -7,9 +7,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
public static void Nop(EmitterContext context)
{
InstNop op = context.GetOp<InstNop>();
context.GetOp<InstNop>();
// No operation.
}
}
}
}

View file

@ -113,4 +113,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
context.Copy(dest, res);
}
}
}
}

View file

@ -246,4 +246,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
context.Copy(GetDest(rd), res);
}
}
}
}

View file

@ -4,7 +4,6 @@ using Ryujinx.Graphics.Shader.Translation;
using System;
using System.Collections.Generic;
using System.Numerics;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
@ -221,7 +220,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand destOperand = dest != RegisterConsts.RegisterZeroIndex ? Register(dest, RegisterType.Gpr) : null;
List<Operand> sourcesList = new List<Operand>();
List<Operand> sourcesList = new();
if (isBindless)
{
@ -325,7 +324,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcA++, RegisterType.Gpr));
}
List<Operand> sourcesList = new List<Operand>();
List<Operand> sourcesList = new();
if (isBindless)
{
@ -445,10 +444,18 @@ namespace Ryujinx.Graphics.Shader.Instructions
switch (size)
{
case SuSize.U8: context.Copy(dests[0], ZeroExtendTo32(context, dests[0], 8)); break;
case SuSize.U16: context.Copy(dests[0], ZeroExtendTo32(context, dests[0], 16)); break;
case SuSize.S8: context.Copy(dests[0], SignExtendTo32(context, dests[0], 8)); break;
case SuSize.S16: context.Copy(dests[0], SignExtendTo32(context, dests[0], 16)); break;
case SuSize.U8:
context.Copy(dests[0], ZeroExtendTo32(context, dests[0], 8));
break;
case SuSize.U16:
context.Copy(dests[0], ZeroExtendTo32(context, dests[0], 16));
break;
case SuSize.S8:
context.Copy(dests[0], SignExtendTo32(context, dests[0], 8));
break;
case SuSize.S16:
context.Copy(dests[0], SignExtendTo32(context, dests[0], 16));
break;
}
}
}
@ -493,7 +500,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcB++, RegisterType.Gpr));
}
List<Operand> sourcesList = new List<Operand>();
List<Operand> sourcesList = new();
if (isBindless)
{
@ -600,7 +607,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcB++, RegisterType.Gpr));
}
List<Operand> sourcesList = new List<Operand>();
List<Operand> sourcesList = new();
if (isBindless)
{
@ -699,7 +706,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
SuatomSize.S64 => 3,
SuatomSize.Sd32 => 2,
SuatomSize.Sd64 => 3,
_ => 2
_ => 2,
};
}
@ -715,7 +722,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
SuatomSize.S64 => TextureFormat.R32G32Uint,
SuatomSize.Sd32 => TextureFormat.R32Uint,
SuatomSize.Sd64 => TextureFormat.R32G32Uint,
_ => TextureFormat.R32Uint
_ => TextureFormat.R32Uint,
};
}
@ -732,7 +739,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
SuatomOp.Or => TextureFlags.BitwiseOr,
SuatomOp.Xor => TextureFlags.BitwiseXor,
SuatomOp.Exch => TextureFlags.Swap,
_ => TextureFlags.Add
_ => TextureFlags.Add,
};
}
@ -743,7 +750,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
SuSize.B64 => 2,
SuSize.B128 => 4,
SuSize.UB128 => 4,
_ => 1
_ => 1,
};
}
@ -759,7 +766,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
SuSize.B64 => 3,
SuSize.B128 => 4,
SuSize.UB128 => 4,
_ => 2
_ => 2,
};
}
@ -775,7 +782,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
SuSize.B64 => TextureFormat.R32G32Uint,
SuSize.B128 => TextureFormat.R32G32B32A32Uint,
SuSize.UB128 => TextureFormat.R32G32B32A32Uint,
_ => TextureFormat.R32Uint
_ => TextureFormat.R32Uint,
};
}
@ -789,8 +796,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
SuDim._2d => SamplerType.Texture2D,
SuDim._2dArray => SamplerType.Texture2D | SamplerType.Array,
SuDim._3d => SamplerType.Texture3D,
_ => SamplerType.None
_ => SamplerType.None,
};
}
}
}
}

View file

@ -4,7 +4,6 @@ using Ryujinx.Graphics.Shader.Translation;
using System;
using System.Collections.Generic;
using System.Numerics;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
namespace Ryujinx.Graphics.Shader.Instructions
@ -14,7 +13,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
private static readonly int[,] _maskLut = new int[,]
{
{ 0b0001, 0b0010, 0b0100, 0b1000, 0b0011, 0b1001, 0b1010, 0b1100 },
{ 0b0111, 0b1011, 0b1101, 0b1110, 0b1111, 0b0000, 0b0000, 0b0000 }
{ 0b0111, 0b1011, 0b1101, 0b1110, 0b1111, 0b0000, 0b0000, 0b0000 },
};
public const bool Sample1DAs2D = true;
@ -23,7 +22,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
Texs,
Tlds,
Tld4s
Tld4s,
}
public static void Tex(EmitterContext context)
@ -207,7 +206,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand arrayIndex = isArray ? Ra() : null;
List<Operand> sourcesList = new List<Operand>();
List<Operand> sourcesList = new();
if (isBindless)
{
@ -353,7 +352,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return;
}
List<Operand> sourcesList = new List<Operand>();
List<Operand> sourcesList = new();
Operand Ra()
{
@ -722,7 +721,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand arrayIndex = isArray ? Ra() : null;
List<Operand> sourcesList = new List<Operand>();
List<Operand> sourcesList = new();
SamplerType type = ConvertSamplerType(dimensions);
TextureFlags flags = TextureFlags.Gather;
@ -864,7 +863,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
TextureFlags flags = TextureFlags.None;
List<Operand> sourcesList = new List<Operand>();
List<Operand> sourcesList = new();
if (isBindless)
{
@ -996,7 +995,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
TextureFlags flags = TextureFlags.Derivatives;
List<Operand> sourcesList = new List<Operand>();
List<Operand> sourcesList = new();
if (isBindless)
{
@ -1126,7 +1125,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcA++, RegisterType.Gpr));
}
List<Operand> sourcesList = new List<Operand>();
List<Operand> sourcesList = new();
if (isBindless)
{
@ -1195,7 +1194,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
TexDim.Array3d => SamplerType.Texture3D | SamplerType.Array,
TexDim.Cube => SamplerType.TextureCube,
TexDim.ArrayCube => SamplerType.TextureCube | SamplerType.Array,
_ => throw new ArgumentException($"Invalid texture dimensions \"{dimensions}\".")
_ => throw new ArgumentException($"Invalid texture dimensions \"{dimensions}\"."),
};
}
@ -1309,4 +1308,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
return TextureFlags.None;
}
}
}
}

View file

@ -1,7 +1,6 @@
using Ryujinx.Graphics.Shader.Decoders;
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
@ -77,7 +76,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
VideoScale.Shr7 => 7,
VideoScale.Shr15 => 15,
_ => 0
_ => 0,
};
if (shift != 0)
@ -115,4 +114,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
// TODO: CC.
}
}
}
}

View file

@ -180,4 +180,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
context.Copy(Register(op.DestPredInv, RegisterType.Predicate), p1Res);
}
}
}
}

View file

@ -1,7 +1,6 @@
using Ryujinx.Graphics.Shader.Decoders;
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
@ -39,7 +38,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
ShflMode.Up => context.ShuffleUp(srcA, srcB, srcC),
ShflMode.Down => context.ShuffleDown(srcA, srcB, srcC),
ShflMode.Bfly => context.ShuffleXor(srcA, srcB, srcC),
_ => (null, null)
_ => (null, null),
};
context.Copy(GetDest(op.Dest), res);
@ -81,4 +80,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
}
}
}
}
}

View file

@ -3,4 +3,4 @@ using Ryujinx.Graphics.Shader.Translation;
namespace Ryujinx.Graphics.Shader.Instructions
{
delegate void InstEmitter(EmitterContext context);
}
}

View file

@ -1,6 +1,5 @@
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
namespace Ryujinx.Graphics.Shader.Instructions
@ -9,27 +8,27 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
private enum TruthTable : byte
{
False = 0x00, // false
True = 0xff, // true
In = 0xf0, // a
And2 = 0xc0, // a & b
Or2 = 0xfc, // a | b
Xor2 = 0x3c, // a ^ b
And3 = 0x80, // a & b & c
Or3 = 0xfe, // a | b | c
XorAnd = 0x60, // a & (b ^ c)
XorOr = 0xf6, // a | (b ^ c)
OrAnd = 0xe0, // a & (b | c)
AndOr = 0xf8, // a | (b & c)
Onehot = 0x16, // (a & !b & !c) | (!a & b & !c) | (!a & !b & c) - Only one value is true.
Majority = 0xe8, // Popcount(a, b, c) >= 2
Gamble = 0x81, // (a & b & c) | (!a & !b & !c) - All on or all off
False = 0x00, // false
True = 0xff, // true
In = 0xf0, // a
And2 = 0xc0, // a & b
Or2 = 0xfc, // a | b
Xor2 = 0x3c, // a ^ b
And3 = 0x80, // a & b & c
Or3 = 0xfe, // a | b | c
XorAnd = 0x60, // a & (b ^ c)
XorOr = 0xf6, // a | (b ^ c)
OrAnd = 0xe0, // a & (b | c)
AndOr = 0xf8, // a | (b & c)
Onehot = 0x16, // (a & !b & !c) | (!a & b & !c) | (!a & !b & c) - Only one value is true.
Majority = 0xe8, // Popcount(a, b, c) >= 2
Gamble = 0x81, // (a & b & c) | (!a & !b & !c) - All on or all off
InverseGamble = 0x7e, // Inverse of Gamble
Dot = 0x1a, // a ^ (c | (a & b))
Mux = 0xca, // a ? b : c
AndXor = 0x78, // a ^ (b & c)
OrXor = 0x1e, // a ^ (b | c)
Xor3 = 0x96, // a ^ b ^ c
Dot = 0x1a, // a ^ (c | (a & b))
Mux = 0xca, // a ? b : c
AndXor = 0x78, // a ^ (b & c)
OrXor = 0x1e, // a ^ (b | c)
Xor3 = 0x96, // a ^ b ^ c
}
public static Operand GetFromTruthTable(EmitterContext context, Operand srcA, Operand srcB, Operand srcC, int imm)
@ -41,7 +40,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand x = srcA;
Operand y = srcB;
Operand z = srcC;
if ((i & 0x01) != 0)
{
(x, y) = (y, x);
@ -98,6 +97,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
return imm switch
{
#pragma warning disable IDE0055 // Disable formatting
TruthTable.False => Const(0),
TruthTable.True => Const(-1),
TruthTable.In => x,
@ -118,7 +118,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
TruthTable.AndXor => context.BitwiseExclusiveOr(x, context.BitwiseAnd(y, z)),
TruthTable.OrXor => context.BitwiseExclusiveOr(x, context.BitwiseOr(y, z)),
TruthTable.Xor3 => context.BitwiseExclusiveOr(x, context.BitwiseExclusiveOr(y, z)),
_ => null
_ => null,
#pragma warning restore IDE0055
};
}
@ -138,4 +139,4 @@ namespace Ryujinx.Graphics.Shader.Instructions
return (TruthTable)result;
}
}
}
}