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-22 21:43:31 -04:00
|
|
|
private Dictionary<long, ShaderIrLabel> LabelsToInsert;
|
2018-05-17 14:25:42 -04:00
|
|
|
|
2018-05-22 21:43:31 -04:00
|
|
|
public long Position;
|
2018-05-17 14:25:42 -04:00
|
|
|
|
2018-04-08 15:17:35 -04:00
|
|
|
public ShaderIrBlock()
|
|
|
|
{
|
|
|
|
Nodes = new List<ShaderIrNode>();
|
2018-05-17 14:25:42 -04:00
|
|
|
|
2018-05-22 21:43:31 -04:00
|
|
|
LabelsToInsert = new Dictionary<long, ShaderIrLabel>();
|
2018-04-08 15:17:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void AddNode(ShaderIrNode Node)
|
|
|
|
{
|
|
|
|
Nodes.Add(Node);
|
|
|
|
}
|
|
|
|
|
2018-05-22 21:43:31 -04:00
|
|
|
public ShaderIrLabel GetLabel(long Position)
|
2018-05-17 14:25:42 -04:00
|
|
|
{
|
|
|
|
if (LabelsToInsert.TryGetValue(Position, out ShaderIrLabel Label))
|
|
|
|
{
|
|
|
|
return Label;
|
|
|
|
}
|
|
|
|
|
|
|
|
Label = new ShaderIrLabel();
|
|
|
|
|
|
|
|
LabelsToInsert.Add(Position, Label);
|
|
|
|
|
|
|
|
return Label;
|
|
|
|
}
|
|
|
|
|
2018-05-22 21:43:31 -04:00
|
|
|
public void MarkLabel(long Position)
|
2018-05-17 14:25:42 -04:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|