Disable AOFFI support on non NVIDIA drivers

This commit is contained in:
Thog 2019-02-27 19:51:39 +01:00
parent b879cd89d7
commit 10dc67bc75
No known key found for this signature in database
GPG key ID: 0CD291558FAFDBC6
4 changed files with 22 additions and 9 deletions

View file

@ -9,9 +9,12 @@ namespace Ryujinx.Graphics.Gal.OpenGL
private static Lazy<bool> s_TextureMirrorClamp = new Lazy<bool>(() => HasExtension("GL_EXT_texture_mirror_clamp"));
private static Lazy<bool> s_ViewportArray = new Lazy<bool>(() => HasExtension("GL_ARB_viewport_array"));
private static Lazy<bool> s_NvidiaDriver = new Lazy<bool>(() => IsNvidiaDriver());
public static bool EnhancedLayouts => s_EnhancedLayouts.Value;
public static bool TextureMirrorClamp => s_TextureMirrorClamp.Value;
public static bool ViewportArray => s_ViewportArray.Value;
public static bool NvidiaDrvier => s_NvidiaDriver.Value;
private static bool HasExtension(string Name)
{
@ -27,5 +30,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL
return false;
}
private static bool IsNvidiaDriver() {
return GL.GetString(StringName.Vendor).Equals("NVIDIA Corporation");
}
}
}

View file

@ -53,7 +53,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
{
GlslProgram Program;
GlslDecompiler Decompiler = new GlslDecompiler(OGLLimit.MaxUboSize);
GlslDecompiler Decompiler = new GlslDecompiler(OGLLimit.MaxUboSize, OGLExtension.NvidiaDrvier);
int ShaderDumpIndex = ShaderDumper.DumpIndex;

View file

@ -35,7 +35,9 @@ namespace Ryujinx.Graphics.Gal.Shader
public int MaxUboSize { get; }
public GlslDecompiler(int MaxUboSize)
private bool IsNvidiaDriver;
public GlslDecompiler(int MaxUboSize, bool IsNvidiaDriver)
{
InstsExpr = new Dictionary<ShaderIrInst, GetInstExpr>()
{
@ -113,6 +115,7 @@ namespace Ryujinx.Graphics.Gal.Shader
};
this.MaxUboSize = MaxUboSize / 16;
this.IsNvidiaDriver = IsNvidiaDriver;
}
public GlslProgram Decompile(
@ -1233,6 +1236,7 @@ namespace Ryujinx.Graphics.Gal.Shader
return GetTextureGatherOperation(Op, Sampler, Coords, Ch);
}
// TODO: support AOFFI on non nvidia drivers
private string GetTxlfExpr(ShaderIrOp Op)
{
// TODO: Support all suffixes
@ -1253,7 +1257,7 @@ namespace Ryujinx.Graphics.Gal.Shader
Lod = GetOperExpr(Op, Meta.LevelOfDetail);
}
if ((Suffix & TextureInstructionSuffix.AOffI) != 0)
if ((Suffix & TextureInstructionSuffix.AOffI) != 0 && IsNvidiaDriver)
{
string Offset = GetTextureOffset(Meta, GetOperExpr(Op, Meta.Offset));
return "texelFetchOffset(" + Sampler + ", " + Coords + ", " + Lod + ", " + Offset + ")." + Ch;
@ -1421,6 +1425,7 @@ namespace Ryujinx.Graphics.Gal.Shader
}
}
// TODO: support AOFFI on non nvidia drivers
private string GetTextureGatherOperation(ShaderIrOp Op, string Sampler, string Coords, string Ch)
{
ShaderIrMetaTex Meta = (ShaderIrMetaTex)Op.MetaData;
@ -1436,7 +1441,7 @@ namespace Ryujinx.Graphics.Gal.Shader
Comp = GetOperExpr(Op, Meta.DepthCompare);
}
if ((Suffix & TextureInstructionSuffix.AOffI) != 0)
if ((Suffix & TextureInstructionSuffix.AOffI) != 0 && IsNvidiaDriver)
{
string Offset = GetTextureOffset(Meta, "floatBitsToInt((" + GetOperExpr(Op, Meta.Offset) + "))", 8, 0x3F);
@ -1456,6 +1461,7 @@ namespace Ryujinx.Graphics.Gal.Shader
return "textureGather(" + Sampler + ", " + Coords + ", " + Comp + ")" + ChString;
}
// TODO: support AOFFI on non nvidia drivers
private string GetTextureOperation(ShaderIrOp Op, string Sampler, string Coords, string Ch)
{
ShaderIrMetaTex Meta = (ShaderIrMetaTex)Op.MetaData;
@ -1472,7 +1478,7 @@ namespace Ryujinx.Graphics.Gal.Shader
// TODO: Support LBA and LLA
if ((Suffix & TextureInstructionSuffix.LZ) != 0)
{
if ((Suffix & TextureInstructionSuffix.AOffI) != 0)
if ((Suffix & TextureInstructionSuffix.AOffI) != 0 && IsNvidiaDriver)
{
string Offset = GetTextureOffset(Meta, "floatBitsToInt((" + GetOperExpr(Op, Meta.Offset) + "))");
@ -1483,7 +1489,7 @@ namespace Ryujinx.Graphics.Gal.Shader
}
else if ((Suffix & TextureInstructionSuffix.LB) != 0)
{
if ((Suffix & TextureInstructionSuffix.AOffI) != 0)
if ((Suffix & TextureInstructionSuffix.AOffI) != 0 && IsNvidiaDriver)
{
string Offset = GetTextureOffset(Meta, "floatBitsToInt((" + GetOperExpr(Op, Meta.Offset) + "))");
@ -1494,7 +1500,7 @@ namespace Ryujinx.Graphics.Gal.Shader
}
else if ((Suffix & TextureInstructionSuffix.LL) != 0)
{
if ((Suffix & TextureInstructionSuffix.AOffI) != 0)
if ((Suffix & TextureInstructionSuffix.AOffI) != 0 && IsNvidiaDriver)
{
string Offset = GetTextureOffset(Meta, "floatBitsToInt((" + GetOperExpr(Op, Meta.Offset) + "))");
@ -1503,7 +1509,7 @@ namespace Ryujinx.Graphics.Gal.Shader
return "textureLod(" + Sampler + ", " + Coords + ", " + GetOperExpr(Op, Meta.LevelOfDetail) + ")" + ChString;
}
else if ((Suffix & TextureInstructionSuffix.AOffI) != 0)
else if ((Suffix & TextureInstructionSuffix.AOffI) != 0 && IsNvidiaDriver)
{
string Offset = GetTextureOffset(Meta, "floatBitsToInt((" + GetOperExpr(Op, Meta.Offset) + "))");

View file

@ -13,7 +13,7 @@ namespace Ryujinx.ShaderTools
{
if (args.Length == 2)
{
GlslDecompiler Decompiler = new GlslDecompiler(MaxUboSize);
GlslDecompiler Decompiler = new GlslDecompiler(MaxUboSize, true);
GalShaderType ShaderType = GalShaderType.Vertex;