aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/TextureOperation.cs
blob: 7eee8f2e9c40e84d9a9da2cbdd68cbd5a4e4b1f0 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
{
    class TextureOperation : Operation
    {
        public const int DefaultCbufSlot = -1;

        public SamplerType Type { get; set; }
        public TextureFormat Format { get; set; }
        public TextureFlags Flags { get; private set; }

        public int Set { get; private set; }
        public int Binding { get; private set; }
        public int SamplerSet { get; private set; }
        public int SamplerBinding { get; private set; }

        public TextureOperation(
            Instruction inst,
            SamplerType type,
            TextureFormat format,
            TextureFlags flags,
            int set,
            int binding,
            int compIndex,
            Operand[] dests,
            Operand[] sources) : base(inst, compIndex, dests, sources)
        {
            Type = type;
            Format = format;
            Flags = flags;
            Set = set;
            Binding = binding;
            SamplerSet = -1;
            SamplerBinding = -1;
        }

        public void TurnIntoArray(SetBindingPair setAndBinding)
        {
            Flags &= ~TextureFlags.Bindless;
            Set = setAndBinding.SetIndex;
            Binding = setAndBinding.Binding;
        }

        public void TurnIntoArray(SetBindingPair textureSetAndBinding, SetBindingPair samplerSetAndBinding)
        {
            TurnIntoArray(textureSetAndBinding);

            SamplerSet = samplerSetAndBinding.SetIndex;
            SamplerBinding = samplerSetAndBinding.Binding;
        }

        public void SetBinding(SetBindingPair setAndBinding)
        {
            if ((Flags & TextureFlags.Bindless) != 0)
            {
                Flags &= ~TextureFlags.Bindless;

                RemoveSource(0);
            }

            Set = setAndBinding.SetIndex;
            Binding = setAndBinding.Binding;
        }

        public void SetLodLevelFlag()
        {
            Flags |= TextureFlags.LodLevel;
        }
    }
}