From 92cc37e365d02aaa2e2d499acac6bdcb7a13d069 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 14 Apr 2020 20:01:26 -0300 Subject: [PATCH] Fix negation of HADD2 constant buffer source (#1116) --- Ryujinx.Graphics.Shader/Instructions/InstEmitFArith.cs | 2 +- Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitFArith.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitFArith.cs index c171a9862..1da5158f8 100644 --- a/Ryujinx.Graphics.Shader/Instructions/InstEmitFArith.cs +++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitFArith.cs @@ -203,7 +203,7 @@ namespace Ryujinx.Graphics.Shader.Instructions bool saturate = op.RawOpCode.Extract(op is IOpCodeReg ? 32 : 52); Operand[] srcA = GetHalfSrcA(context, isAdd); - Operand[] srcB = GetHalfSrcB(context); + Operand[] srcB = GetHalfSrcB(context, !isAdd); Operand[] res = new Operand[2]; diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs index 09d90e157..352d16c07 100644 --- a/Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs +++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs @@ -173,7 +173,7 @@ namespace Ryujinx.Graphics.Shader.Instructions return FPAbsNeg(context, operands, absoluteA, negateA); } - public static Operand[] GetHalfSrcB(EmitterContext context) + public static Operand[] GetHalfSrcB(EmitterContext context, bool isMul = false) { OpCode op = context.CurrOp; @@ -193,6 +193,11 @@ namespace Ryujinx.Graphics.Shader.Instructions swizzle = FPHalfSwizzle.FP32; absoluteB = op.RawOpCode.Extract(54); + + if (!isMul) + { + negateB = op.RawOpCode.Extract(56); + } } Operand[] operands = GetHalfUnpacked(context, GetSrcB(context), swizzle);