diff options
author | gdkchan <gab.dark.100@gmail.com> | 2023-05-19 11:52:31 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-19 11:52:31 -0300 |
commit | fc26189fe1338ffcba12d83a922da9c706738902 (patch) | |
tree | 7dea976db639a73d81793d8b9ee8b9803cdce1c4 /src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs | |
parent | a40c90e7dd0c37ae6fb7be84ad720cbf88fd8d28 (diff) |
Eliminate redundant multiplications by gl_FragCoord.w on the shader (#4578)1.1.807
* Eliminate redundant multiplications by gl_FragCoord.w on the shader
* Shader cache version bump
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs')
-rw-r--r-- | src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs index 4ca6d687..a0d58d07 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs @@ -4,6 +4,35 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations { static class Utils { + public static bool IsInputLoad(INode node) + { + return (node is Operation operation) && + operation.Inst == Instruction.Load && + operation.StorageKind == StorageKind.Input; + } + + public static bool IsInputLoad(INode node, IoVariable ioVariable, int elemIndex) + { + if (!(node is Operation operation) || + operation.Inst != Instruction.Load || + operation.StorageKind != StorageKind.Input || + operation.SourcesCount != 2) + { + return false; + } + + Operand ioVariableSrc = operation.GetSource(0); + + if (ioVariableSrc.Type != OperandType.Constant || (IoVariable)ioVariableSrc.Value != ioVariable) + { + return false; + } + + Operand elemIndexSrc = operation.GetSource(1); + + return elemIndexSrc.Type == OperandType.Constant && elemIndexSrc.Value == elemIndex; + } + private static Operation FindBranchSource(BasicBlock block) { foreach (BasicBlock sourceBlock in block.Predecessors) |