diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2021-11-14 21:37:07 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-14 21:37:07 -0300 |
| commit | b9d83cc97ee1cb8c60d9b01c162bab742567fe6e (patch) | |
| tree | 7cfe5cffd688dd8ca5a06e91c85e5e4cfbcce9c6 /Ryujinx.Graphics.Shader/Instructions | |
| parent | 788aec511ffe64c9a22024d1b88334ec8e3b5ad6 (diff) | |
Fix shader integer from/to double conversion (#2831)
Diffstat (limited to 'Ryujinx.Graphics.Shader/Instructions')
| -rw-r--r-- | Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs | 40 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs | 2 |
2 files changed, 33 insertions, 9 deletions
diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs index 01cdc445..62124554 100644 --- a/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs +++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs @@ -179,27 +179,40 @@ namespace Ryujinx.Graphics.Shader.Instructions return; } + Instruction fpType = srcType.ToInstFPType(); + bool isSignedInt = dstType == IDstFmt.S16 || dstType == IDstFmt.S32 || dstType == IDstFmt.S64; bool isSmallInt = dstType == IDstFmt.U16 || dstType == IDstFmt.S16; - Operand srcB = context.FPAbsNeg(src, absolute, negate); + Operand srcB = context.FPAbsNeg(src, absolute, negate, fpType); srcB = roundingMode switch { - RoundMode2.Round => context.FPRound(srcB), - RoundMode2.Floor => context.FPFloor(srcB), - RoundMode2.Ceil => context.FPCeiling(srcB), - RoundMode2.Trunc => context.FPTruncate(srcB), + RoundMode2.Round => context.FPRound(srcB, fpType), + RoundMode2.Floor => context.FPFloor(srcB, fpType), + RoundMode2.Ceil => context.FPCeiling(srcB, fpType), + RoundMode2.Trunc => context.FPTruncate(srcB, fpType), _ => srcB }; if (!isSignedInt) { // Negative float to uint cast is undefined, so we clamp the value before conversion. - srcB = context.FPMaximum(srcB, ConstF(0)); + srcB = context.FPMaximum(srcB, ConstF(0), fpType); } - srcB = isSignedInt ? context.FPConvertToS32(srcB) : context.FPConvertToU32(srcB); + if (srcType == DstFmt.F64) + { + srcB = isSignedInt + ? context.FP64ConvertToS32(srcB) + : context.FP64ConvertToU32(srcB); + } + else + { + srcB = isSignedInt + ? context.FP32ConvertToS32(srcB) + : context.FP32ConvertToU32(srcB); + } if (isSmallInt) { @@ -252,7 +265,18 @@ namespace Ryujinx.Graphics.Shader.Instructions : context.BitfieldExtractU32(srcB, Const((int)byteSelection * 8), Const(size)); } - srcB = isSignedInt ? context.IConvertS32ToFP(srcB) : context.IConvertU32ToFP(srcB); + if (dstType == DstFmt.F64) + { + srcB = isSignedInt + ? context.IConvertS32ToFP64(srcB) + : context.IConvertU32ToFP64(srcB); + } + else + { + srcB = isSignedInt + ? context.IConvertS32ToFP32(srcB) + : context.IConvertU32ToFP32(srcB); + } WriteFP(context, dstType, srcB, rd); diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs index ba1fdf17..33cc6af7 100644 --- a/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs +++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs @@ -939,7 +939,7 @@ namespace Ryujinx.Graphics.Shader.Instructions tempDest = context.FPMultiply(tempDest, ConstF(256.0f)); - Operand fixedPointValue = context.FPConvertToS32(tempDest); + Operand fixedPointValue = context.FP32ConvertToS32(tempDest); context.Copy(GetDest(), fixedPointValue); } |
