diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitAlu.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitAlu.cs index 0cb854e91..77df3d8da 100644 --- a/Ryujinx.Graphics.Shader/Instructions/InstEmitAlu.cs +++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitAlu.cs @@ -327,14 +327,18 @@ namespace Ryujinx.Graphics.Shader.Instructions if (boolFloat) { - context.Copy(dest, context.ConditionalSelect(res, ConstF(1), Const(0))); + res = context.ConditionalSelect(res, ConstF(1), Const(0)); + + context.Copy(dest, res); + + SetFPZnFlags(context, res, op.SetCondCode); } else { context.Copy(dest, res); - } - SetZnFlags(context, res, op.SetCondCode, op.Extended); + SetZnFlags(context, res, op.SetCondCode, op.Extended); + } // TODO: X } diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitAluHelper.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitAluHelper.cs index e283c3b77..da5c7fed2 100644 --- a/Ryujinx.Graphics.Shader/Instructions/InstEmitAluHelper.cs +++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitAluHelper.cs @@ -84,5 +84,14 @@ namespace Ryujinx.Graphics.Shader.Instructions context.Copy(GetNF(context), context.ICompareLess(dest, Const(0))); } + + public static void SetFPZnFlags(EmitterContext context, Operand dest, bool setCC) + { + if (setCC) + { + context.Copy(GetZF(context), context.FPCompareEqual(dest, ConstF(0))); + context.Copy(GetNF(context), context.FPCompareLess (dest, ConstF(0))); + } + } } } \ No newline at end of file diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitFArith.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitFArith.cs index 63d1efcbc..23f40d469 100644 --- a/Ryujinx.Graphics.Shader/Instructions/InstEmitFArith.cs +++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitFArith.cs @@ -163,14 +163,20 @@ namespace Ryujinx.Graphics.Shader.Instructions if (boolFloat) { - context.Copy(dest, context.ConditionalSelect(res, ConstF(1), Const(0))); + res = context.ConditionalSelect(res, ConstF(1), Const(0)); + + context.Copy(dest, res); + + SetFPZnFlags(context, res, op.SetCondCode); } else { context.Copy(dest, res); + + SetZnFlags(context, res, op.SetCondCode, op.Extended); } - // TODO: CC, X + // TODO: X } public static void Fsetp(EmitterContext context) @@ -453,15 +459,6 @@ namespace Ryujinx.Graphics.Shader.Instructions return res; } - private static void SetFPZnFlags(EmitterContext context, Operand dest, bool setCC) - { - if (setCC) - { - context.Copy(GetZF(context), context.FPCompareEqual(dest, ConstF(0))); - context.Copy(GetNF(context), context.FPCompareLess (dest, ConstF(0))); - } - } - private static Operand[] GetHfmaSrcA(EmitterContext context) { IOpCodeHfma op = (IOpCodeHfma)context.CurrOp;