aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2023-08-07 12:20:37 -0300
committerGitHub <noreply@github.com>2023-08-07 12:20:37 -0300
commit42750a74f82ee69cabfaf3c5497af6a8ebc13eca (patch)
tree5d42a8945c0e692a0a96752752aac00666fe2c43
parent3ab0a71c7bfb60b20008894db3fb6534436753e6 (diff)
Do not add more code after alpha test discard on fragment shader (#5529)1.1.976
* Do not add more code after alpha test discard on fragment shader * Shader cache version bump
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs2
-rw-r--r--src/Ryujinx.Graphics.Shader/Instructions/InstEmitFlowControl.cs14
-rw-r--r--src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs16
3 files changed, 23 insertions, 9 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
index 4bab165d..512ae94b 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
@@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
private const ushort FileFormatVersionMajor = 1;
private const ushort FileFormatVersionMinor = 2;
private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
- private const uint CodeGenVersion = 4675;
+ private const uint CodeGenVersion = 5529;
private const string SharedTocFileName = "shared.toc";
private const string SharedDataFileName = "shared.data";
diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFlowControl.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFlowControl.cs
index fc1a696f..7462fc5a 100644
--- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFlowControl.cs
+++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFlowControl.cs
@@ -162,8 +162,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
if (op.Ccc == Ccc.T)
{
- context.PrepareForReturn();
- context.Return();
+ if (context.PrepareForReturn())
+ {
+ context.Return();
+ }
}
else
{
@@ -174,8 +176,12 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
Operand lblSkip = Label();
context.BranchIfFalse(lblSkip, cond);
- context.PrepareForReturn();
- context.Return();
+
+ if (context.PrepareForReturn())
+ {
+ context.Return();
+ }
+
context.MarkLabel(lblSkip);
}
}
diff --git a/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs b/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs
index 08d4b915..614b275b 100644
--- a/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs
+++ b/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs
@@ -304,11 +304,11 @@ namespace Ryujinx.Graphics.Shader.Translation
PrepareForVertexReturn();
}
- public void PrepareForReturn()
+ public bool PrepareForReturn()
{
if (IsNonMain)
{
- return;
+ return true;
}
if (Config.LastInVertexPipeline &&
@@ -383,13 +383,13 @@ namespace Ryujinx.Graphics.Shader.Translation
AlphaTestOp alphaTestOp = Config.GpuAccessor.QueryAlphaTestCompare();
- if (alphaTestOp != AlphaTestOp.Always && (Config.OmapTargets & 8) != 0)
+ if (alphaTestOp != AlphaTestOp.Always)
{
if (alphaTestOp == AlphaTestOp.Never)
{
this.Discard();
}
- else
+ else if ((Config.OmapTargets & 8) != 0)
{
Instruction comparator = alphaTestOp switch
{
@@ -415,6 +415,12 @@ namespace Ryujinx.Graphics.Shader.Translation
}
}
+ // We don't need to output anything if alpha test always fails.
+ if (alphaTestOp == AlphaTestOp.Never)
+ {
+ return false;
+ }
+
int regIndexBase = 0;
for (int rtIndex = 0; rtIndex < 8; rtIndex++)
@@ -462,6 +468,8 @@ namespace Ryujinx.Graphics.Shader.Translation
}
}
}
+
+ return true;
}
private void GenerateAlphaToCoverageDitherDiscard()