aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Shader/StructuredIr/AstOperation.cs
blob: 1607ffecde5c7dc9b81915bde2de67cf301f6350 (plain) (blame)
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
using Ryujinx.Graphics.Shader.IntermediateRepresentation;

using static Ryujinx.Graphics.Shader.StructuredIr.AstHelper;

namespace Ryujinx.Graphics.Shader.StructuredIr
{
    class AstOperation : AstNode
    {
        public Instruction Inst { get; }

        public int ComponentMask { get; }

        private IAstNode[] _sources;

        public int SourcesCount => _sources.Length;

        public AstOperation(Instruction inst, params IAstNode[] sources)
        {
            Inst     = inst;
            _sources = sources;

            foreach (IAstNode source in sources)
            {
                AddUse(source, this);
            }

            ComponentMask = 1;
        }

        public AstOperation(Instruction inst, int compMask, params IAstNode[] sources) : this(inst, sources)
        {
            ComponentMask = compMask;
        }

        public IAstNode GetSource(int index)
        {
            return _sources[index];
        }

        public void SetSource(int index, IAstNode source)
        {
            RemoveUse(_sources[index], this);

            AddUse(source, this);

            _sources[index] = source;
        }
    }
}