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

@ -6,25 +6,42 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
{
public Instruction Inst { get; private set; }
private Operand _dest;
private Operand[] _dests;
public Operand Dest
{
get => _dest;
set => _dest = AssignDest(value);
get
{
return _dests.Length != 0 ? _dests[0] : null;
}
set
{
if (value != null && value.Type == OperandType.LocalVariable)
{
value.AsgOp = this;
}
if (value != null)
{
_dests = new[] { value };
}
else
{
_dests = Array.Empty<Operand>();
}
}
}
public int DestsCount => _dests.Length;
private Operand[] _sources;
public int SourcesCount => _sources.Length;
public int Index { get; }
public Operation(Instruction inst, Operand dest, params Operand[] sources)
private Operation(Operand[] sources)
{
Inst = inst;
Dest = dest;
// The array may be modified externally, so we store a copy.
_sources = (Operand[])sources.Clone();
@ -39,11 +56,42 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
}
}
public Operation(
Instruction inst,
int index,
Operand dest,
params Operand[] sources) : this(inst, dest, sources)
public Operation(Instruction inst, int index, Operand[] dests, Operand[] sources) : this(sources)
{
Inst = inst;
Index = index;
// The array may be modified externally, so we store a copy.
_dests = (Operand[])dests.Clone();
for (int dstIndex = 0; dstIndex < dests.Length; dstIndex++)
{
Operand dest = dests[dstIndex];
if (dest != null && dest.Type == OperandType.LocalVariable)
{
dest.AsgOp = this;
}
}
}
public Operation(Instruction inst, Operand dest, params Operand[] sources) : this(sources)
{
Inst = inst;
if (dest != null)
{
dest.AsgOp = this;
_dests = new[] { dest };
}
else
{
_dests = Array.Empty<Operand>();
}
}
public Operation(Instruction inst, int index, Operand dest, params Operand[] sources) : this(inst, dest, sources)
{
Index = index;
}
@ -67,14 +115,9 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
}
}
private Operand AssignDest(Operand dest)
public Operand GetDest(int index)
{
if (dest != null && dest.Type == OperandType.LocalVariable)
{
dest.AsgOp = this;
}
return dest;
return _dests[index];
}
public Operand GetSource(int index)
@ -82,6 +125,23 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
return _sources[index];
}
public void SetDest(int index, Operand dest)
{
Operand oldDest = _dests[index];
if (oldDest != null && oldDest.Type == OperandType.LocalVariable)
{
oldDest.AsgOp = null;
}
if (dest != null && dest.Type == OperandType.LocalVariable)
{
dest.AsgOp = this;
}
_dests[index] = dest;
}
public void SetSource(int index, Operand source)
{
Operand oldSrc = _sources[index];