aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/Instructions
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.Shader/Instructions')
-rw-r--r--Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs22
1 files changed, 18 insertions, 4 deletions
diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs
index b1524152..8c06a24b 100644
--- a/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs
+++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs
@@ -99,12 +99,26 @@ namespace Ryujinx.Graphics.Shader.Instructions
break;
}
- long min = GetIntMin(intType);
- long max = GetIntMax(intType);
+ if (!isSignedInt)
+ {
+ // Negative float to uint cast is undefined, so we clamp
+ // the value before conversion.
+ srcB = context.FPMaximum(srcB, ConstF(0));
+ }
- srcB = context.FPClamp(srcB, ConstF(min), ConstF(max));
+ srcB = isSignedInt
+ ? context.FPConvertToS32(srcB)
+ : context.FPConvertToU32(srcB);
+
+ if (isSmallInt)
+ {
+ int min = (int)GetIntMin(intType);
+ int max = (int)GetIntMax(intType);
- srcB = context.FPConvertToS32(srcB);
+ srcB = isSignedInt
+ ? context.IClampS32(srcB, Const(min), Const(max))
+ : context.IClampU32(srcB, Const(min), Const(max));
+ }
Operand dest = GetDest(context);