aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/State/ViewportTransform.cs
blob: c7db311de9fe0fd51b0dc16639f86ec994ab3585 (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
using Ryujinx.Graphics.GAL;

namespace Ryujinx.Graphics.Gpu.State
{
    /// <summary>
    /// Viewport transform parameters, for viewport transformation.
    /// </summary>
    struct ViewportTransform
    {
        public float ScaleX;
        public float ScaleY;
        public float ScaleZ;
        public float TranslateX;
        public float TranslateY;
        public float TranslateZ;
        public uint  Swizzle;
        public uint  SubpixelPrecisionBias;

        /// <summary>
        /// Unpacks viewport swizzle of the position X component.
        /// </summary>
        /// <returns>Swizzle enum value</returns>
        public ViewportSwizzle UnpackSwizzleX()
        {
            return (ViewportSwizzle)(Swizzle & 7);
        }

        /// <summary>
        /// Unpacks viewport swizzle of the position Y component.
        /// </summary>
        /// <returns>Swizzle enum value</returns>
        public ViewportSwizzle UnpackSwizzleY()
        {
            return (ViewportSwizzle)((Swizzle >> 4) & 7);
        }

        /// <summary>
        /// Unpacks viewport swizzle of the position Z component.
        /// </summary>
        /// <returns>Swizzle enum value</returns>
        public ViewportSwizzle UnpackSwizzleZ()
        {
            return (ViewportSwizzle)((Swizzle >> 8) & 7);
        }

        /// <summary>
        /// Unpacks viewport swizzle of the position W component.
        /// </summary>
        /// <returns>Swizzle enum value</returns>
        public ViewportSwizzle UnpackSwizzleW()
        {
            return (ViewportSwizzle)((Swizzle >> 12) & 7);
        }
    }
}