Fix bindless/global memory elimination with inverted predicates (#2826)

* Fix bindless/global memory elimination with inverted predicates

* Shader cache version bump
This commit is contained in:
gdkchan 2021-11-08 12:57:28 -03:00 committed by GitHub
parent b7a1544e8b
commit 3dee712164
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View file

@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <summary> /// <summary>
/// Version of the codegen (to be changed when codegen or guest format change). /// Version of the codegen (to be changed when codegen or guest format change).
/// </summary> /// </summary>
private const ulong ShaderCodeGenVersion = 2822; private const ulong ShaderCodeGenVersion = 2826;
// Progress reporting helpers // Progress reporting helpers
private volatile int _shaderCount; private volatile int _shaderCount;

View file

@ -10,11 +10,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
{ {
if (sourceBlock.Operations.Count > 0) if (sourceBlock.Operations.Count > 0)
{ {
Operation lastOp = sourceBlock.Operations.Last.Value as Operation; if (sourceBlock.GetLastOp() is Operation lastOp && IsConditionalBranch(lastOp.Inst) && sourceBlock.Next == block)
if (lastOp != null &&
((sourceBlock.Next == block && lastOp.Inst == Instruction.BranchIfFalse) ||
(sourceBlock.Branch == block && lastOp.Inst == Instruction.BranchIfTrue)))
{ {
return lastOp; return lastOp;
} }
@ -24,6 +20,11 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
return null; return null;
} }
private static bool IsConditionalBranch(Instruction inst)
{
return inst == Instruction.BranchIfFalse || inst == Instruction.BranchIfTrue;
}
private static bool BlockConditionsMatch(BasicBlock currentBlock, BasicBlock queryBlock) private static bool BlockConditionsMatch(BasicBlock currentBlock, BasicBlock queryBlock)
{ {
// Check if all the conditions for the query block are satisfied by the current block. // Check if all the conditions for the query block are satisfied by the current block.