diff options
| author | gdk <gab.dark.100@gmail.com> | 2019-11-26 01:00:58 -0300 |
|---|---|---|
| committer | Thog <thog@protonmail.com> | 2020-01-09 02:13:00 +0100 |
| commit | 99f236fcf03e4304a91df70c3545b9b79ff15942 (patch) | |
| tree | 2ef9768b932f3fa09efe66340f4e6f32a6130b76 /Ryujinx.Graphics.Shader/Instructions | |
| parent | b8528c6317423d91aefe12d927466df0c09cc172 (diff) | |
Simplified F2I shader instruction codegen
Diffstat (limited to 'Ryujinx.Graphics.Shader/Instructions')
| -rw-r--r-- | Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs | 22 |
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); |
