Better IPA shader instruction implementation (#1082)

* Fix varying interpolation on fragment shader

* Some nits

* Alignment
This commit is contained in:
gdkchan 2020-04-02 21:20:47 -03:00 committed by GitHub
parent 2365ddfc36
commit e93ca84b14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 97 additions and 89 deletions

View file

@ -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);
res = context.FPMultiply(res, srcB);
}
Operand srcA = Attribute(op.AttributeOffset, iq);
Operand res = context.FPSaturate(srcA, op.Saturate);
res = context.FPSaturate(res, op.Saturate);
context.Copy(GetDest(context), res);
}