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