aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/State/CopyBufferSwizzle.cs
blob: 94b650c4e361c4e6002fdada0d0641dcd299d70b (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
63
64
65
66
67
68
69
70
71
72
73
74
75
namespace Ryujinx.Graphics.Gpu.State
{
    /// <summary>
    /// Buffer to buffer copy vector swizzle parameters.
    /// </summary>
    struct CopyBufferSwizzle
    {
#pragma warning disable CS0649
        public uint Swizzle;
#pragma warning restore CS0649

        /// <summary>
        /// Unpacks the source for the buffer destination vector X component.
        /// </summary>
        /// <returns>Destination component</returns>
        public BufferSwizzleComponent UnpackDstX()
        {
            return (BufferSwizzleComponent)(Swizzle & 7);
        }

        /// <summary>
        /// Unpacks the source for the buffer destination vector Y component.
        /// </summary>
        /// <returns>Destination component</returns>
        public BufferSwizzleComponent UnpackDstY()
        {
            return (BufferSwizzleComponent)((Swizzle >> 4) & 7);
        }

        /// <summary>
        /// Unpacks the source for the buffer destination vector Z component.
        /// </summary>
        /// <returns>Destination component</returns>
        public BufferSwizzleComponent UnpackDstZ()
        {
            return (BufferSwizzleComponent)((Swizzle >> 8) & 7);
        }

        /// <summary>
        /// Unpacks the source for the buffer destination vector W component.
        /// </summary>
        /// <returns>Destination component</returns>
        public BufferSwizzleComponent UnpackDstW()
        {
            return (BufferSwizzleComponent)((Swizzle >> 12) & 7);
        }

        /// <summary>
        /// Unpacks the size of each vector component of the copy.
        /// </summary>
        /// <returns>Vector component size</returns>
        public int UnpackComponentSize()
        {
            return (int)((Swizzle >> 16) & 3) + 1;
        }

        /// <summary>
        /// Unpacks the number of components of the source vector of the copy.
        /// </summary>
        /// <returns>Number of vector components</returns>
        public int UnpackSrcComponentsCount()
        {
            return (int)((Swizzle >> 20) & 7) + 1;
        }

        /// <summary>
        /// Unpacks the number of components of the destination vector of the copy.
        /// </summary>
        /// <returns>Number of vector components</returns>
        public int UnpackDstComponentsCount()
        {
            return (int)((Swizzle >> 24) & 7) + 1;
        }
    }
}