aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/CodeGen/Spirv/EnumConversion.cs
blob: 0ddb426400e533c99f11cf17a63f724e22527469 (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
using Ryujinx.Graphics.Shader.StructuredIr;
using Ryujinx.Graphics.Shader.Translation;
using System;
using static Spv.Specification;

namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
{
    static class EnumConversion
    {
        public static AggregateType Convert(this VariableType type)
        {
            return type switch
            {
                VariableType.None => AggregateType.Void,
                VariableType.Bool => AggregateType.Bool,
                VariableType.F32 => AggregateType.FP32,
                VariableType.F64 => AggregateType.FP64,
                VariableType.S32 => AggregateType.S32,
                VariableType.U32 => AggregateType.U32,
                _ => throw new ArgumentException($"Invalid variable type \"{type}\".")
            };
        }

        public static ExecutionModel Convert(this ShaderStage stage)
        {
            return stage switch
            {
                ShaderStage.Compute => ExecutionModel.GLCompute,
                ShaderStage.Vertex => ExecutionModel.Vertex,
                ShaderStage.TessellationControl => ExecutionModel.TessellationControl,
                ShaderStage.TessellationEvaluation => ExecutionModel.TessellationEvaluation,
                ShaderStage.Geometry => ExecutionModel.Geometry,
                ShaderStage.Fragment => ExecutionModel.Fragment,
                _ => throw new ArgumentException($"Invalid shader stage \"{stage}\".")
            };
        }
    }
}