2018-04-08 12:17:35 -07:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Gal.Shader
|
|
|
|
{
|
|
|
|
class ShaderIrBlock
|
|
|
|
{
|
|
|
|
private List<ShaderIrNode> Nodes;
|
|
|
|
|
2018-05-22 18:43:31 -07:00
|
|
|
private Dictionary<long, ShaderIrLabel> LabelsToInsert;
|
2018-05-17 11:25:42 -07:00
|
|
|
|
2018-05-22 18:43:31 -07:00
|
|
|
public long Position;
|
2018-05-17 11:25:42 -07:00
|
|
|
|
2018-04-08 12:17:35 -07:00
|
|
|
public ShaderIrBlock()
|
|
|
|
{
|
|
|
|
Nodes = new List<ShaderIrNode>();
|
2018-05-17 11:25:42 -07:00
|
|
|
|
2018-05-22 18:43:31 -07:00
|
|
|
LabelsToInsert = new Dictionary<long, ShaderIrLabel>();
|
2018-04-08 12:17:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public void AddNode(ShaderIrNode Node)
|
|
|
|
{
|
|
|
|
Nodes.Add(Node);
|
|
|
|
}
|
|
|
|
|
2018-05-22 18:43:31 -07:00
|
|
|
public ShaderIrLabel GetLabel(long Position)
|
2018-05-17 11:25:42 -07:00
|
|
|
{
|
|
|
|
if (LabelsToInsert.TryGetValue(Position, out ShaderIrLabel Label))
|
|
|
|
{
|
|
|
|
return Label;
|
|
|
|
}
|
|
|
|
|
|
|
|
Label = new ShaderIrLabel();
|
|
|
|
|
|
|
|
LabelsToInsert.Add(Position, Label);
|
|
|
|
|
|
|
|
return Label;
|
|
|
|
}
|
|
|
|
|
2018-05-22 18:43:31 -07:00
|
|
|
public void MarkLabel(long Position)
|
2018-05-17 11:25:42 -07:00
|
|
|
{
|
|
|
|
if (LabelsToInsert.TryGetValue(Position, out ShaderIrLabel Label))
|
|
|
|
{
|
|
|
|
Nodes.Add(Label);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-08 12:17:35 -07:00
|
|
|
public ShaderIrNode[] GetNodes()
|
|
|
|
{
|
|
|
|
return Nodes.ToArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
public ShaderIrNode GetLastNode()
|
|
|
|
{
|
|
|
|
if (Nodes.Count > 0)
|
|
|
|
{
|
|
|
|
return Nodes[Nodes.Count - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|