mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-08 04:28:36 +00:00
Another workaround for NVIDIA driver 496.13 shader bug (#2750)
* Another workaround for NVIDIA driver 496.13 shader bug This might work better than the other one. Give this a test to see if it fixes/doesn't fix issues with the other one. The problem seems to be when any variable assignment happens with a negation. `temp_1 = -temp_0;` seems to trigger weird behaviour, but `temp_1 = 0.0 - temp_0;` does not. This also might to extend towards integer types? * Update cache version * Add disclaimer comment * Wording
This commit is contained in:
parent
fbf40424f4
commit
052deebf26
|
@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <summary>
|
||||
/// Version of the codegen (to be changed when codegen or guest format change).
|
||||
/// </summary>
|
||||
private const ulong ShaderCodeGenVersion = 2534;
|
||||
private const ulong ShaderCodeGenVersion = 2750;
|
||||
|
||||
// Progress reporting helpers
|
||||
private volatile int _shaderCount;
|
||||
|
|
|
@ -27,6 +27,22 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
|||
throw new ArgumentException($"Invalid node type \"{node?.GetType().Name ?? "null"}\".");
|
||||
}
|
||||
|
||||
public static string Negate(CodeGenContext context, AstOperation operation, InstInfo info)
|
||||
{
|
||||
IAstNode src = operation.GetSource(0);
|
||||
|
||||
VariableType type = GetSrcVarType(operation.Inst, 0);
|
||||
|
||||
string srcExpr = GetSoureExpr(context, src, type);
|
||||
|
||||
NumberFormatter.TryFormat(0, type, out string zero);
|
||||
|
||||
// Starting in the 496.13 NVIDIA driver, there's an issue with assigning variables to negated expressions.
|
||||
// (-expr) does not work, but (0.0 - expr) does. This should be removed once the issue is resolved.
|
||||
|
||||
return $"{zero} - {Enclose(srcExpr, src, operation.Inst, info, false)}";
|
||||
}
|
||||
|
||||
private static string GetExpression(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
Instruction inst = operation.Inst;
|
||||
|
@ -120,7 +136,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
|||
}
|
||||
else if ((info.Type & InstType.Special) != 0)
|
||||
{
|
||||
switch (inst)
|
||||
switch (inst & Instruction.Mask)
|
||||
{
|
||||
case Instruction.Ballot:
|
||||
return Ballot(context, operation);
|
||||
|
@ -151,6 +167,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
|||
case Instruction.Lod:
|
||||
return Lod(context, operation);
|
||||
|
||||
case Instruction.Negate:
|
||||
return Negate(context, operation, info);
|
||||
|
||||
case Instruction.PackDouble2x32:
|
||||
return PackDouble2x32(context, operation);
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
|||
Add(Instruction.Multiply, InstType.OpBinaryCom, "*", 1);
|
||||
Add(Instruction.MultiplyHighS32, InstType.CallBinary, HelperFunctionNames.MultiplyHighS32);
|
||||
Add(Instruction.MultiplyHighU32, InstType.CallBinary, HelperFunctionNames.MultiplyHighU32);
|
||||
Add(Instruction.Negate, InstType.OpUnary, "-", 0);
|
||||
Add(Instruction.Negate, InstType.Special);
|
||||
Add(Instruction.ReciprocalSquareRoot, InstType.CallUnary, "inversesqrt");
|
||||
Add(Instruction.Return, InstType.OpNullary, "return");
|
||||
Add(Instruction.Round, InstType.CallUnary, "roundEven");
|
||||
|
|
Loading…
Reference in a new issue