aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Shader/InputTopology.cs
blob: 9438263decf603b842348468b40a075c18e35b61 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
namespace Ryujinx.Graphics.Shader
{
    public enum InputTopology : byte
    {
        Points,
        Lines,
        LinesAdjacency,
        Triangles,
        TrianglesAdjacency,
    }

    static class InputTopologyExtensions
    {
        public static string ToGlslString(this InputTopology topology)
        {
            return topology switch
            {
                InputTopology.Points => "points",
                InputTopology.Lines => "lines",
                InputTopology.LinesAdjacency => "lines_adjacency",
                InputTopology.Triangles => "triangles",
                InputTopology.TrianglesAdjacency => "triangles_adjacency",
                _ => "points",
            };
        }

        public static int ToInputVertices(this InputTopology topology)
        {
            return topology switch
            {
                InputTopology.Points => 1,
                InputTopology.Lines => 2,
                InputTopology.LinesAdjacency => 4,
                InputTopology.Triangles => 3,
                InputTopology.TrianglesAdjacency => 6,
                _ => 1,
            };
        }

        public static int ToInputVerticesNoAdjacency(this InputTopology topology)
        {
            return topology switch
            {
                InputTopology.Points => 1,
                InputTopology.Lines or
                InputTopology.LinesAdjacency => 2,
                InputTopology.Triangles or
                InputTopology.TrianglesAdjacency => 3,
                _ => 1,
            };
        }
    }
}