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