aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/State/VertexAttribState.cs
blob: dbb75a5b1eedb029e8b5f462f76b5c1b4091e9db (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
namespace Ryujinx.Graphics.Gpu.State
{
    /// <summary>
    /// Vertex buffer attribute state.
    /// </summary>
    struct VertexAttribState
    {
#pragma warning disable CS0649
        public uint Attribute;
#pragma warning restore CS0649

        /// <summary>
        /// Unpacks the index of the vertex buffer this attribute belongs to.
        /// </summary>
        /// <returns>Vertex buffer index</returns>
        public int UnpackBufferIndex()
        {
            return (int)(Attribute & 0x1f);
        }

        /// <summary>
        /// Unpacks the attribute constant flag.
        /// </summary>
        /// <returns>True if the attribute is constant, false otherwise</returns>
        public bool UnpackIsConstant()
        {
            return (Attribute & 0x40) != 0;
        }

        /// <summary>
        /// Unpacks the offset, in bytes, of the attribute on the vertex buffer.
        /// </summary>
        /// <returns>Attribute offset in bytes</returns>
        public int UnpackOffset()
        {
            return (int)((Attribute >> 7) & 0x3fff);
        }

        /// <summary>
        /// Unpacks the Maxwell attribute format integer.
        /// </summary>
        /// <returns>Attribute format integer</returns>
        public uint UnpackFormat()
        {
            return Attribute & 0x3fe00000;
        }
    }
}