aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Shader/Decoders/BitfieldExtensions.cs
blob: 3bb9bc1f4c2e34e238cbfe66e385c87b15e281ab (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
namespace Ryujinx.Graphics.Shader.Decoders
{
    static class BitfieldExtensions
    {
        public static bool Extract(this int value, int lsb)
        {
            return ((int)(value >> lsb) & 1) != 0;
        }

        public static int Extract(this int value, int lsb, int length)
        {
            return (int)(value >> lsb) & (int)(uint.MaxValue >> (32 - length));
        }

        public static bool Extract(this long value, int lsb)
        {
            return ((int)(value >> lsb) & 1) != 0;
        }

        public static int Extract(this long value, int lsb, int length)
        {
            return (int)(value >> lsb) & (int)(uint.MaxValue >> (32 - length));
        }
    }
}