Eliminate redundant multiplications by gl_FragCoord.w on the shader (#4578)
* Eliminate redundant multiplications by gl_FragCoord.w on the shader * Shader cache version bump
This commit is contained in:
parent
a40c90e7dd
commit
fc26189fe1
3 changed files with 105 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue