From e93ca84b14cc325364f1ccc45a6e8622978e959d Mon Sep 17 00:00:00 2001 From: gdkchan Date: Thu, 2 Apr 2020 21:20:47 -0300 Subject: Better IPA shader instruction implementation (#1082) * Fix varying interpolation on fragment shader * Some nits * Alignment --- .../Instructions/InstEmitMemory.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'Ryujinx.Graphics.Shader/Instructions') diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs index 1fddcc8c..7eb88883 100644 --- a/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs +++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs @@ -96,17 +96,27 @@ namespace Ryujinx.Graphics.Shader.Instructions { OpCodeIpa op = (OpCodeIpa)context.CurrOp; - InterpolationQualifier iq = InterpolationQualifier.None; + Operand res = Attribute(op.AttributeOffset); - switch (op.Mode) + if (op.AttributeOffset >= AttributeConsts.UserAttributeBase && + op.AttributeOffset < AttributeConsts.UserAttributeEnd) { - case InterpolationMode.Constant: iq = InterpolationQualifier.Flat; break; - case InterpolationMode.Pass: iq = InterpolationQualifier.NoPerspective; break; + int index = (op.AttributeOffset - AttributeConsts.UserAttributeBase) >> 4; + + if (context.Config.ImapTypes[index].GetFirstUsedType() == PixelImap.Perspective) + { + res = context.FPMultiply(res, Attribute(AttributeConsts.PositionW)); + } } + + if (op.Mode == InterpolationMode.Default) + { + Operand srcB = GetSrcB(context); - Operand srcA = Attribute(op.AttributeOffset, iq); + res = context.FPMultiply(res, srcB); + } - Operand res = context.FPSaturate(srcA, op.Saturate); + res = context.FPSaturate(res, op.Saturate); context.Copy(GetDest(context), res); } -- cgit v1.2.3