Add support for saturation on some shader instructions, fix ReadTexture alignment and add ColorMask support (#451)
* Add support for saturation on some shader instructions, fix ReadTexture alignment * Add ColorMask support, other tweaks
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
public GalComparisonOp DepthFunc;
|
||||
|
||||
public bool StencilTestEnabled;
|
||||
public bool StencilTwoSideEnabled;
|
||||
|
||||
public GalComparisonOp StencilBackFuncFunc;
|
||||
public int StencilBackFuncRef;
|
||||
@@ -52,6 +53,11 @@
|
||||
public GalBlendFactor BlendFuncSrcAlpha;
|
||||
public GalBlendFactor BlendFuncDstAlpha;
|
||||
|
||||
public bool ColorMaskR;
|
||||
public bool ColorMaskG;
|
||||
public bool ColorMaskB;
|
||||
public bool ColorMaskA;
|
||||
|
||||
public bool PrimitiveRestartEnabled;
|
||||
public uint PrimitiveRestartIndex;
|
||||
|
||||
|
@@ -195,6 +195,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||
Enable(EnableCap.StencilTest, New.StencilTestEnabled);
|
||||
}
|
||||
|
||||
if (New.StencilTwoSideEnabled != Old.StencilTwoSideEnabled)
|
||||
{
|
||||
Enable((EnableCap)All.StencilTestTwoSideExt, New.StencilTwoSideEnabled);
|
||||
}
|
||||
|
||||
if (New.StencilTestEnabled)
|
||||
{
|
||||
if (New.StencilBackFuncFunc != Old.StencilBackFuncFunc ||
|
||||
@@ -298,6 +303,18 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||
}
|
||||
}
|
||||
|
||||
if (New.ColorMaskR != Old.ColorMaskR ||
|
||||
New.ColorMaskG != Old.ColorMaskG ||
|
||||
New.ColorMaskB != Old.ColorMaskB ||
|
||||
New.ColorMaskA != Old.ColorMaskA)
|
||||
{
|
||||
GL.ColorMask(
|
||||
New.ColorMaskR,
|
||||
New.ColorMaskG,
|
||||
New.ColorMaskB,
|
||||
New.ColorMaskA);
|
||||
}
|
||||
|
||||
if (New.PrimitiveRestartEnabled != Old.PrimitiveRestartEnabled)
|
||||
{
|
||||
Enable(EnableCap.PrimitiveRestart, New.PrimitiveRestartEnabled);
|
||||
|
@@ -360,7 +360,7 @@ namespace Ryujinx.Graphics.Gal.Shader
|
||||
|
||||
private void PrintDeclSsy()
|
||||
{
|
||||
SB.AppendLine("uint " + GlslDecl.SsyCursorName + "= 0;");
|
||||
SB.AppendLine("uint " + GlslDecl.SsyCursorName + " = 0;");
|
||||
|
||||
SB.AppendLine("uint " + GlslDecl.SsyStackName + "[" + GlslDecl.SsyStackSize + "];" + Environment.NewLine);
|
||||
}
|
||||
|
@@ -585,6 +585,7 @@ namespace Ryujinx.Graphics.Gal.Shader
|
||||
bool AbsA = OpCode.Read(46);
|
||||
bool NegA = OpCode.Read(48);
|
||||
bool AbsB = OpCode.Read(49);
|
||||
bool Sat = OpCode.Read(50);
|
||||
|
||||
ShaderIrNode OperA = OpCode.Gpr8(), OperB;
|
||||
|
||||
@@ -603,12 +604,13 @@ namespace Ryujinx.Graphics.Gal.Shader
|
||||
|
||||
ShaderIrNode Op = new ShaderIrOp(ShaderIrInst.Fadd, OperA, OperB);
|
||||
|
||||
Block.AddNode(OpCode.PredNode(new ShaderIrAsg(OpCode.Gpr0(), Op)));
|
||||
Block.AddNode(OpCode.PredNode(new ShaderIrAsg(OpCode.Gpr0(), GetAluFsat(Op, Sat))));
|
||||
}
|
||||
|
||||
private static void EmitFmul(ShaderIrBlock Block, long OpCode, ShaderOper Oper)
|
||||
{
|
||||
bool NegB = OpCode.Read(48);
|
||||
bool Sat = OpCode.Read(50);
|
||||
|
||||
ShaderIrNode OperA = OpCode.Gpr8(), OperB;
|
||||
|
||||
@@ -625,13 +627,14 @@ namespace Ryujinx.Graphics.Gal.Shader
|
||||
|
||||
ShaderIrNode Op = new ShaderIrOp(ShaderIrInst.Fmul, OperA, OperB);
|
||||
|
||||
Block.AddNode(OpCode.PredNode(new ShaderIrAsg(OpCode.Gpr0(), Op)));
|
||||
Block.AddNode(OpCode.PredNode(new ShaderIrAsg(OpCode.Gpr0(), GetAluFsat(Op, Sat))));
|
||||
}
|
||||
|
||||
private static void EmitFfma(ShaderIrBlock Block, long OpCode, ShaderOper Oper)
|
||||
{
|
||||
bool NegB = OpCode.Read(48);
|
||||
bool NegC = OpCode.Read(49);
|
||||
bool Sat = OpCode.Read(50);
|
||||
|
||||
ShaderIrNode OperA = OpCode.Gpr8(), OperB, OperC;
|
||||
|
||||
@@ -658,7 +661,7 @@ namespace Ryujinx.Graphics.Gal.Shader
|
||||
|
||||
ShaderIrOp Op = new ShaderIrOp(ShaderIrInst.Ffma, OperA, OperB, OperC);
|
||||
|
||||
Block.AddNode(OpCode.PredNode(new ShaderIrAsg(OpCode.Gpr0(), Op)));
|
||||
Block.AddNode(OpCode.PredNode(new ShaderIrAsg(OpCode.Gpr0(), GetAluFsat(Op, Sat))));
|
||||
}
|
||||
|
||||
private static void EmitIadd(ShaderIrBlock Block, long OpCode, ShaderOper Oper)
|
||||
|
@@ -2,6 +2,9 @@ namespace Ryujinx.Graphics.Gal.Shader
|
||||
{
|
||||
static class ShaderDecodeHelper
|
||||
{
|
||||
private static readonly ShaderIrOperImmf ImmfZero = new ShaderIrOperImmf(0);
|
||||
private static readonly ShaderIrOperImmf ImmfOne = new ShaderIrOperImmf(1);
|
||||
|
||||
public static ShaderIrNode GetAluFabsFneg(ShaderIrNode Node, bool Abs, bool Neg)
|
||||
{
|
||||
return GetAluFneg(GetAluFabs(Node, Abs), Neg);
|
||||
@@ -17,6 +20,11 @@ namespace Ryujinx.Graphics.Gal.Shader
|
||||
return Neg ? new ShaderIrOp(ShaderIrInst.Fneg, Node) : Node;
|
||||
}
|
||||
|
||||
public static ShaderIrNode GetAluFsat(ShaderIrNode Node, bool Sat)
|
||||
{
|
||||
return Sat ? new ShaderIrOp(ShaderIrInst.Fclamp, Node, ImmfZero, ImmfOne) : Node;
|
||||
}
|
||||
|
||||
public static ShaderIrNode GetAluIabsIneg(ShaderIrNode Node, bool Abs, bool Neg)
|
||||
{
|
||||
return GetAluIneg(GetAluIabs(Node, Abs), Neg);
|
||||
|
Reference in New Issue
Block a user