Support multiple destination operands on shader IR and shuffle predicates (#1964)

* Support multiple destination operands on shader IR and shuffle predicates

* Cache version change
This commit is contained in:
gdkchan 2021-01-27 20:59:47 -03:00 committed by GitHub
parent dcce407071
commit 4b7c7dab9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 199 additions and 79 deletions

View file

@ -64,7 +64,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
else if ((operation.Inst == Instruction.PackHalf2x16 && PropagatePack(operation)) ||
(operation.Inst == Instruction.ShuffleXor && MatchDdxOrDdy(operation)))
{
if (operation.Dest.UseOps.Count == 0)
if (DestHasNoUses(operation))
{
RemoveNode(block, node);
}
@ -260,6 +260,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
if (src.UseOps.Remove(node) && src.UseOps.Count == 0)
{
Debug.Assert(src.AsgOp != null);
nodes.Enqueue(src.AsgOp);
}
}
@ -268,7 +269,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
private static bool IsUnused(INode node)
{
return !HasSideEffects(node) && DestIsLocalVar(node) && node.Dest.UseOps.Count == 0;
return !HasSideEffects(node) && DestIsLocalVar(node) && DestHasNoUses(node);
}
private static bool HasSideEffects(INode node)
@ -298,7 +299,33 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
private static bool DestIsLocalVar(INode node)
{
return node.Dest != null && node.Dest.Type == OperandType.LocalVariable;
if (node.DestsCount == 0)
{
return false;
}
for (int index = 0; index < node.DestsCount; index++)
{
if (node.GetDest(index).Type != OperandType.LocalVariable)
{
return false;
}
}
return true;
}
private static bool DestHasNoUses(INode node)
{
for (int index = 0; index < node.DestsCount; index++)
{
if (node.GetDest(index).UseOps.Count != 0)
{
return false;
}
}
return true;
}
}
}