aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/Shader/ShaderIrBlock.cs
blob: 5f365d8c8f71da80c35c4a0c0e5c20b8c49e754a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System.Collections.Generic;

namespace Ryujinx.Graphics.Gal.Shader
{
    class ShaderIrBlock
    {
        private List<ShaderIrNode> Nodes;

        private Dictionary<int, ShaderIrLabel> LabelsToInsert;

        public int Position;

        public ShaderIrBlock()
        {
            Nodes = new List<ShaderIrNode>();

            LabelsToInsert = new Dictionary<int, ShaderIrLabel>();
        }

        public void AddNode(ShaderIrNode Node)
        {
            Nodes.Add(Node);
        }

        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);
            }
        }

        public ShaderIrNode[] GetNodes()
        {
            return Nodes.ToArray();
        }

        public ShaderIrNode GetLastNode()
        {
            if (Nodes.Count > 0)
            {
                return Nodes[Nodes.Count - 1];
            }

            return null;
        }
    }
}