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