diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index 67a397b3..4e1e130c 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// /// Version of the codegen (to be changed when codegen or guest format change). /// - private const ulong ShaderCodeGenVersion = 2822; + private const ulong ShaderCodeGenVersion = 2826; // Progress reporting helpers private volatile int _shaderCount; diff --git a/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs b/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs index 83ff8c40..4ca6d687 100644 --- a/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs +++ b/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs @@ -10,11 +10,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations { if (sourceBlock.Operations.Count > 0) { - Operation lastOp = sourceBlock.Operations.Last.Value as Operation; - - if (lastOp != null && - ((sourceBlock.Next == block && lastOp.Inst == Instruction.BranchIfFalse) || - (sourceBlock.Branch == block && lastOp.Inst == Instruction.BranchIfTrue))) + if (sourceBlock.GetLastOp() is Operation lastOp && IsConditionalBranch(lastOp.Inst) && sourceBlock.Next == block) { return lastOp; } @@ -24,6 +20,11 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations return null; } + private static bool IsConditionalBranch(Instruction inst) + { + return inst == Instruction.BranchIfFalse || inst == Instruction.BranchIfTrue; + } + private static bool BlockConditionsMatch(BasicBlock currentBlock, BasicBlock queryBlock) { // Check if all the conditions for the query block are satisfied by the current block.