aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs
diff options
context:
space:
mode:
authorgdk <gab.dark.100@gmail.com>2019-11-25 16:02:52 -0300
committerThog <thog@protonmail.com>2020-01-09 02:13:00 +0100
commitb8528c6317423d91aefe12d927466df0c09cc172 (patch)
tree15e4f33d48b49504fb79ccf8b442f2f2fa5bb1b5 /Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs
parent65428f5842311e2cacb49d2b9e24a3b803fe1f82 (diff)
Implement HSET2 shader instruction and fix errors uncovered by Rodrigo tests
Diffstat (limited to 'Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs')
-rw-r--r--Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs32
1 files changed, 14 insertions, 18 deletions
diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs
index 5aa925d9..b1524152 100644
--- a/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs
+++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs
@@ -14,18 +14,16 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
OpCodeFArith op = (OpCodeFArith)context.CurrOp;
- FPType srcType = (FPType)op.RawOpCode.Extract(8, 2);
- FPType dstType = (FPType)op.RawOpCode.Extract(10, 2);
+ FPType dstType = (FPType)op.RawOpCode.Extract(8, 2);
+ FPType srcType = (FPType)op.RawOpCode.Extract(10, 2);
- bool pass = op.RawOpCode.Extract(40);
+ bool round = op.RawOpCode.Extract(42);
bool negateB = op.RawOpCode.Extract(45);
bool absoluteB = op.RawOpCode.Extract(49);
- pass &= op.RoundingMode == RoundingMode.TowardsNegativeInfinity;
-
Operand srcB = context.FPAbsNeg(GetSrcB(context, srcType), absoluteB, negateB);
- if (!pass)
+ if (round)
{
switch (op.RoundingMode)
{
@@ -84,6 +82,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
switch (op.RoundingMode)
{
+ case RoundingMode.ToNearest:
+ srcB = context.FPRound(srcB);
+ break;
+
case RoundingMode.TowardsNegativeInfinity:
srcB = context.FPFloor(srcB);
break;
@@ -97,18 +99,12 @@ namespace Ryujinx.Graphics.Shader.Instructions
break;
}
- srcB = context.FPConvertToS32(srcB);
+ long min = GetIntMin(intType);
+ long max = GetIntMax(intType);
- // TODO: S/U64, conversion overflow handling.
- if (intType != IntegerType.S32)
- {
- int min = GetIntMin(intType);
- int max = GetIntMax(intType);
+ srcB = context.FPClamp(srcB, ConstF(min), ConstF(max));
- srcB = isSignedInt
- ? context.IClampS32(srcB, Const(min), Const(max))
- : context.IClampU32(srcB, Const(min), Const(max));
- }
+ srcB = context.FPConvertToS32(srcB);
Operand dest = GetDest(context);
@@ -194,8 +190,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
dstType |= IntegerType.S8;
}
- int min = GetIntMin(dstType);
- int max = GetIntMax(dstType);
+ int min = (int)GetIntMin(dstType);
+ int max = (int)GetIntMax(dstType);
srcB = dstIsSignedInt
? context.IClampS32(srcB, Const(min), Const(max))