Shaders: Handle Ipa PASS argument as needed in Fragment Shaders (#392)

This commit is contained in:
ReinUsesLisp 2018-09-01 18:44:19 -03:00 committed by gdkchan
parent bf28d8f1aa
commit e72fd3f7a7
4 changed files with 52 additions and 2 deletions

View File

@ -1026,7 +1026,31 @@ namespace Ryujinx.Graphics.Gal.Shader
return "int(uint(" + GetOperExpr(Op, Op.OperandA) + "))";
}
private string GetIpaExpr(ShaderIrOp Op) => GetSrcExpr(Op.OperandA);
private string GetIpaExpr(ShaderIrOp Op)
{
ShaderIrMetaIpa Meta = (ShaderIrMetaIpa)Op.MetaData;
ShaderIrOperAbuf Abuf = (ShaderIrOperAbuf)Op.OperandA;
if (Meta.Mode == ShaderIpaMode.Pass)
{
int Index = Abuf.Offs >> 4;
int Elem = (Abuf.Offs >> 2) & 3;
if (Decl.ShaderType == GalShaderType.Fragment && Index == GlslDecl.GlPositionVec4Index)
{
switch (Elem)
{
case 0: return "gl_FragCoord.x";
case 1: return "gl_FragCoord.y";
case 2: return "gl_FragCoord.z";
case 3: return "1";
}
}
}
return GetSrcExpr(Op.OperandA);
}
private string GetKilExpr(ShaderIrOp Op) => "discard";

View File

@ -208,7 +208,11 @@ namespace Ryujinx.Graphics.Gal.Shader
ShaderIrNode OperA = GetOperAbuf28(OpCode);
ShaderIrNode OperB = GetOperGpr20 (OpCode);
ShaderIrOp Op = new ShaderIrOp(ShaderIrInst.Ipa, OperA, OperB);
ShaderIpaMode Mode = (ShaderIpaMode)((OpCode >> 54) & 3);
ShaderIrMetaIpa Meta = new ShaderIrMetaIpa(Mode);
ShaderIrOp Op = new ShaderIrOp(ShaderIrInst.Ipa, OperA, OperB, null, Meta);
Block.AddNode(GetPredNode(new ShaderIrAsg(GetOperGpr0(OpCode), Op), OpCode));
}

View File

@ -0,0 +1,10 @@
namespace Ryujinx.Graphics.Gal.Shader
{
enum ShaderIpaMode
{
Pass = 0,
None = 1,
Constant = 2,
Sc = 3
}
}

View File

@ -0,0 +1,12 @@
namespace Ryujinx.Graphics.Gal.Shader
{
class ShaderIrMetaIpa : ShaderIrMeta
{
public ShaderIpaMode Mode { get; private set; }
public ShaderIrMetaIpa(ShaderIpaMode Mode)
{
this.Mode = Mode;
}
}
}