aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2024-09-19 21:23:09 -0300
committerGitHub <noreply@github.com>2024-09-19 21:23:09 -0300
commitd717aef2be6043ef5a5f064e13db444ef873f6bb (patch)
treeecbdf5505c24701d58cb09137e38a666bc7ddca5 /src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs
parent24ee8c39f1fd8ae2dc2d92cda1cdb41e8af45f0a (diff)
Shader: Assume the only remaining source is the right one when all others are undefined (#7331)1.1.1397
* Shader: Assume the only remaining source is the right one when all other are undefined * Shader cache version bump * Improve comment
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs')
-rw-r--r--src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs
index 23180ff8..6ec90fa3 100644
--- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs
+++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs
@@ -138,6 +138,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
// Ensure that conditions met for that branch are also met for the current one.
// Prefer the latest sources for the phi node.
+ int undefCount = 0;
+
for (int i = phiNode.SourcesCount - 1; i >= 0; i--)
{
BasicBlock phiBlock = phiNode.GetBlock(i);
@@ -159,6 +161,26 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
return match;
}
}
+ else if (phiSource.Type == OperandType.Undefined)
+ {
+ undefCount++;
+ }
+ }
+
+ // If all sources but one are undefined, we can assume that the one
+ // that is not undefined is the right one.
+
+ if (undefCount == phiNode.SourcesCount - 1)
+ {
+ for (int i = phiNode.SourcesCount - 1; i >= 0; i--)
+ {
+ Operand phiSource = phiNode.GetSource(i);
+
+ if (phiSource.Type != OperandType.Undefined)
+ {
+ return phiSource;
+ }
+ }
}
}