From bccd6ec41fa3a75bbb8a4081f508345e4e0d7aae Mon Sep 17 00:00:00 2001 From: gdkchan Date: Mon, 2 Mar 2020 00:35:07 -0300 Subject: [PATCH] Correct double immediate --- .../Decoders/DecoderHelper.cs | 16 ++++++++++++++++ .../Decoders/OpCodeDArithImm.cs | 14 ++++++++++++++ Ryujinx.Graphics.Shader/Decoders/OpCodeTable.cs | 6 +++--- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 Ryujinx.Graphics.Shader/Decoders/OpCodeDArithImm.cs diff --git a/Ryujinx.Graphics.Shader/Decoders/DecoderHelper.cs b/Ryujinx.Graphics.Shader/Decoders/DecoderHelper.cs index 77cd1bf728..7ee9ccb60f 100644 --- a/Ryujinx.Graphics.Shader/Decoders/DecoderHelper.cs +++ b/Ryujinx.Graphics.Shader/Decoders/DecoderHelper.cs @@ -54,5 +54,21 @@ namespace Ryujinx.Graphics.Shader.Decoders return BitConverter.Int32BitsToSingle(imm); } + + public static float DecodeD20Immediate(long opCode) + { + long imm = opCode.Extract(20, 19); + + bool negate = opCode.Extract(56); + + imm <<= 44; + + if (negate) + { + imm |= 1 << 63; + } + + return (float)BitConverter.Int64BitsToDouble(imm); + } } } \ No newline at end of file diff --git a/Ryujinx.Graphics.Shader/Decoders/OpCodeDArithImm.cs b/Ryujinx.Graphics.Shader/Decoders/OpCodeDArithImm.cs new file mode 100644 index 0000000000..99d4cdfdd1 --- /dev/null +++ b/Ryujinx.Graphics.Shader/Decoders/OpCodeDArithImm.cs @@ -0,0 +1,14 @@ +using Ryujinx.Graphics.Shader.Instructions; + +namespace Ryujinx.Graphics.Shader.Decoders +{ + class OpCodeDArithImm : OpCodeFArith, IOpCodeImmF + { + public float Immediate { get; } + + public OpCodeDArithImm(InstEmitter emitter, ulong address, long opCode) : base(emitter, address, opCode) + { + Immediate = DecoderHelper.DecodeD20Immediate(opCode); + } + } +} \ No newline at end of file diff --git a/Ryujinx.Graphics.Shader/Decoders/OpCodeTable.cs b/Ryujinx.Graphics.Shader/Decoders/OpCodeTable.cs index 0186af38d2..72f66f4aa3 100644 --- a/Ryujinx.Graphics.Shader/Decoders/OpCodeTable.cs +++ b/Ryujinx.Graphics.Shader/Decoders/OpCodeTable.cs @@ -46,14 +46,14 @@ namespace Ryujinx.Graphics.Shader.Decoders Set("111000100101xx", InstEmit.Brx, typeof(OpCodeBranchIndir)); Set("0101000010100x", InstEmit.Csetp, typeof(OpCodePset)); Set("0100110001110x", InstEmit.Dadd, typeof(OpCodeFArithCbuf)); - Set("0011100x01110x", InstEmit.Dadd, typeof(OpCodeFArithImm)); + Set("0011100x01110x", InstEmit.Dadd, typeof(OpCodeDArithImm)); Set("0101110001110x", InstEmit.Dadd, typeof(OpCodeFArithReg)); Set("010010110111xx", InstEmit.Dfma, typeof(OpCodeFArithCbuf)); - Set("0011011x0111xx", InstEmit.Dfma, typeof(OpCodeFArithImm)); + Set("0011011x0111xx", InstEmit.Dfma, typeof(OpCodeDArithImm)); Set("010100110111xx", InstEmit.Dfma, typeof(OpCodeFArithRegCbuf)); Set("010110110111xx", InstEmit.Dfma, typeof(OpCodeFArithReg)); Set("0100110010000x", InstEmit.Dmul, typeof(OpCodeFArithCbuf)); - Set("0011100x10000x", InstEmit.Dmul, typeof(OpCodeFArithImm)); + Set("0011100x10000x", InstEmit.Dmul, typeof(OpCodeDArithImm)); Set("0101110010000x", InstEmit.Dmul, typeof(OpCodeFArithReg)); Set("111000110000xx", InstEmit.Exit, typeof(OpCodeExit)); Set("0100110010101x", InstEmit.F2F, typeof(OpCodeFArithCbuf));