aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/Shader/ShaderDecodeHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics/Gal/Shader/ShaderDecodeHelper.cs')
-rw-r--r--Ryujinx.Graphics/Gal/Shader/ShaderDecodeHelper.cs65
1 files changed, 61 insertions, 4 deletions
diff --git a/Ryujinx.Graphics/Gal/Shader/ShaderDecodeHelper.cs b/Ryujinx.Graphics/Gal/Shader/ShaderDecodeHelper.cs
index efbce20f..73775cca 100644
--- a/Ryujinx.Graphics/Gal/Shader/ShaderDecodeHelper.cs
+++ b/Ryujinx.Graphics/Gal/Shader/ShaderDecodeHelper.cs
@@ -35,6 +35,13 @@ namespace Ryujinx.Graphics.Gal.Shader
(int)(OpCode >> 20) & 0x3fff);
}
+ public static ShaderIrOperCbuf GetOperCbuf36(long OpCode)
+ {
+ return new ShaderIrOperCbuf(
+ (int)(OpCode >> 36) & 0x1f,
+ (int)(OpCode >> 22) & 0x3fff, GetOperGpr8(OpCode));
+ }
+
public static ShaderIrOperGpr GetOperGpr8(long OpCode)
{
return new ShaderIrOperGpr((int)(OpCode >> 8) & 0xff);
@@ -60,6 +67,11 @@ namespace Ryujinx.Graphics.Gal.Shader
return new ShaderIrOperGpr((int)(OpCode >> 28) & 0xff);
}
+ public static ShaderIrOperImm GetOperImm5_39(long OpCode)
+ {
+ return new ShaderIrOperImm((int)(OpCode >> 39) & 0x1f);
+ }
+
public static ShaderIrOperImm GetOperImm13_36(long OpCode)
{
return new ShaderIrOperImm((int)(OpCode >> 36) & 0x1fff);
@@ -210,24 +222,69 @@ namespace Ryujinx.Graphics.Gal.Shader
return new ShaderIrOperPred(Pred);
}
- public static ShaderIrNode GetAluAbsNeg(ShaderIrNode Node, bool Abs, bool Neg)
+ public static ShaderIrNode GetAluFabsFneg(ShaderIrNode Node, bool Abs, bool Neg)
{
- return GetAluNeg(GetAluAbs(Node, Abs), Neg);
+ return GetAluFneg(GetAluFabs(Node, Abs), Neg);
}
- public static ShaderIrNode GetAluAbs(ShaderIrNode Node, bool Abs)
+ public static ShaderIrNode GetAluFabs(ShaderIrNode Node, bool Abs)
{
return Abs ? new ShaderIrOp(ShaderIrInst.Fabs, Node) : Node;
}
- public static ShaderIrNode GetAluNeg(ShaderIrNode Node, bool Neg)
+ public static ShaderIrNode GetAluFneg(ShaderIrNode Node, bool Neg)
{
return Neg ? new ShaderIrOp(ShaderIrInst.Fneg, Node) : Node;
}
+ public static ShaderIrNode GetAluIabsIneg(ShaderIrNode Node, bool Abs, bool Neg)
+ {
+ return GetAluIneg(GetAluIabs(Node, Abs), Neg);
+ }
+
+ public static ShaderIrNode GetAluIabs(ShaderIrNode Node, bool Abs)
+ {
+ return Abs ? new ShaderIrOp(ShaderIrInst.Abs, Node) : Node;
+ }
+
+ public static ShaderIrNode GetAluIneg(ShaderIrNode Node, bool Neg)
+ {
+ return Neg ? new ShaderIrOp(ShaderIrInst.Neg, Node) : Node;
+ }
+
public static ShaderIrNode GetAluNot(ShaderIrNode Node, bool Not)
{
return Not ? new ShaderIrOp(ShaderIrInst.Not, Node) : Node;
}
+
+ public static ShaderIrNode ExtendTo32(ShaderIrNode Node, bool Signed, int Size)
+ {
+ int Shift = 32 - Size;
+
+ ShaderIrInst RightShift = Signed
+ ? ShaderIrInst.Asr
+ : ShaderIrInst.Lsr;
+
+ Node = new ShaderIrOp(ShaderIrInst.Lsl, Node, new ShaderIrOperImm(Shift));
+ Node = new ShaderIrOp(RightShift, Node, new ShaderIrOperImm(Shift));
+
+ return Node;
+ }
+
+ public static ShaderIrNode ExtendTo32(ShaderIrNode Node, bool Signed, ShaderIrNode Size)
+ {
+ ShaderIrOperImm WordSize = new ShaderIrOperImm(32);
+
+ ShaderIrOp Shift = new ShaderIrOp(ShaderIrInst.Sub, WordSize, Size);
+
+ ShaderIrInst RightShift = Signed
+ ? ShaderIrInst.Asr
+ : ShaderIrInst.Lsr;
+
+ Node = new ShaderIrOp(ShaderIrInst.Lsl, Node, Shift);
+ Node = new ShaderIrOp(RightShift, Node, Shift);
+
+ return Node;
+ }
}
} \ No newline at end of file