aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Shader/Decoders/Register.cs
blob: 2e6d61996919b42d8b06a5347e98b504f942ebb7 (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
using System;

namespace Ryujinx.Graphics.Shader.Decoders
{
    readonly struct Register : IEquatable<Register>
    {
        public int Index { get; }

        public RegisterType Type { get; }

        public bool IsRZ => Type == RegisterType.Gpr && Index == RegisterConsts.RegisterZeroIndex;
        public bool IsPT => Type == RegisterType.Predicate && Index == RegisterConsts.PredicateTrueIndex;

        public Register(int index, RegisterType type)
        {
            Index = index;
            Type = type;
        }

        public override int GetHashCode()
        {
            return (ushort)Index | ((ushort)Type << 16);
        }

        public override bool Equals(object obj)
        {
            return obj is Register reg && Equals(reg);
        }

        public bool Equals(Register other)
        {
            return other.Index == Index &&
                   other.Type == Type;
        }
    }
}