Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ShaderModel.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System.Globalization;
4 
5 namespace SiliconStudio.Shaders.Convertor
6 {
7  /// <summary>
8  /// Describes a HLSL ShaderModel (SM2, SM3, SM4...etc.)
9  /// </summary>
10  public enum ShaderModel
11  {
12  /// <summary>
13  /// SM 1.1
14  /// </summary>
15  Model11,
16 
17  /// <summary>
18  /// SM 2.0
19  /// </summary>
20  Model20,
21 
22  /// <summary>
23  /// SM 3.0
24  /// </summary>
25  Model30,
26 
27  /// <summary>
28  /// SM 4.0
29  /// </summary>
30  Model40,
31 
32  /// <summary>
33  /// SM 4.1
34  /// </summary>
35  Model41,
36 
37  /// <summary>
38  /// SM 5.0
39  /// </summary>
40  Model50,
41  }
42 
43  internal class ShaderModelHelper
44  {
45  /// <summary>
46  /// Parses the specified short profile (4_0, 3_0, 5_0)
47  /// </summary>
48  /// <param name="profile">The profile.</param>
49  /// <returns>ShaderModel.</returns>
50  public static ShaderModel Parse(string profile)
51  {
52  var model = ShaderModel.Model30;
53 
54  switch (profile)
55  {
56  case "1_1":
57  model = ShaderModel.Model11;
58  break;
59  case "2_0":
60  model = ShaderModel.Model20;
61  break;
62  case "3_0":
63  model = ShaderModel.Model30;
64  break;
65  case "4_0":
66  model = ShaderModel.Model40;
67  break;
68  case "4_1":
69  model = ShaderModel.Model41;
70  break;
71  case "5_0":
72  model = ShaderModel.Model50;
73  break;
74  }
75 
76  return model;
77  }
78 
79  /// <summary>
80  /// Parses the specified full profile (vs_4_0) and output the stage as well.
81  /// </summary>
82  /// <param name="profile">The profile.</param>
83  /// <param name="stage">The stage.</param>
84  /// <returns>Return the ShaderModel default to 3.0 if not parsed correctly.</returns>
85  public static ShaderModel Parse(string profile, out PipelineStage stage)
86  {
87  profile = profile.ToLower(CultureInfo.InvariantCulture);
88 
89  if (profile.StartsWith("vs"))
90  stage = PipelineStage.Vertex;
91  else if (profile.StartsWith("ps"))
92  stage = PipelineStage.Pixel;
93  else if (profile.StartsWith("gs"))
94  stage = PipelineStage.Geometry;
95  else if (profile.StartsWith("cs"))
96  stage = PipelineStage.Compute;
97  else if (profile.StartsWith("hs"))
98  stage = PipelineStage.Hull;
99  else if (profile.StartsWith("ds"))
100  stage = PipelineStage.Domain;
101  else
102  {
103  stage = PipelineStage.None;
104  }
105 
106  return profile.Length > 4 ? Parse(profile.Substring(3)) : ShaderModel.Model30;
107  }
108  }
109 }
ShaderModel
Describes a HLSL ShaderModel (SM2, SM3, SM4...etc.)
Definition: ShaderModel.cs:10
PipelineStage
Enum to specify pipeline stage.