OGLEnumConverter.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. using OpenTK.Graphics.OpenGL;
  2. using System;
  3. namespace Ryujinx.Graphics.Gal.OpenGL
  4. {
  5. static class OGLEnumConverter
  6. {
  7. public static FrontFaceDirection GetFrontFace(GalFrontFace FrontFace)
  8. {
  9. switch (FrontFace)
  10. {
  11. case GalFrontFace.CW: return FrontFaceDirection.Cw;
  12. case GalFrontFace.CCW: return FrontFaceDirection.Ccw;
  13. }
  14. throw new ArgumentException(nameof(FrontFace) + " \"" + FrontFace + "\" is not valid!");
  15. }
  16. public static CullFaceMode GetCullFace(GalCullFace CullFace)
  17. {
  18. switch (CullFace)
  19. {
  20. case GalCullFace.Front: return CullFaceMode.Front;
  21. case GalCullFace.Back: return CullFaceMode.Back;
  22. case GalCullFace.FrontAndBack: return CullFaceMode.FrontAndBack;
  23. }
  24. throw new ArgumentException(nameof(CullFace) + " \"" + CullFace + "\" is not valid!");
  25. }
  26. public static StencilOp GetStencilOp(GalStencilOp Op)
  27. {
  28. switch (Op)
  29. {
  30. case GalStencilOp.Keep: return StencilOp.Keep;
  31. case GalStencilOp.Zero: return StencilOp.Zero;
  32. case GalStencilOp.Replace: return StencilOp.Replace;
  33. case GalStencilOp.Incr: return StencilOp.Incr;
  34. case GalStencilOp.Decr: return StencilOp.Decr;
  35. case GalStencilOp.Invert: return StencilOp.Invert;
  36. case GalStencilOp.IncrWrap: return StencilOp.IncrWrap;
  37. case GalStencilOp.DecrWrap: return StencilOp.DecrWrap;
  38. }
  39. throw new ArgumentException(nameof(Op) + " \"" + Op + "\" is not valid!");
  40. }
  41. public static DepthFunction GetDepthFunc(GalComparisonOp Func)
  42. {
  43. return (DepthFunction)GetFunc(Func);
  44. }
  45. public static StencilFunction GetStencilFunc(GalComparisonOp Func)
  46. {
  47. return (StencilFunction)GetFunc(Func);
  48. }
  49. private static All GetFunc(GalComparisonOp Func)
  50. {
  51. if ((int)Func >= (int)All.Never &&
  52. (int)Func <= (int)All.Always)
  53. {
  54. return (All)Func;
  55. }
  56. switch (Func)
  57. {
  58. case GalComparisonOp.Never: return All.Never;
  59. case GalComparisonOp.Less: return All.Less;
  60. case GalComparisonOp.Equal: return All.Equal;
  61. case GalComparisonOp.Lequal: return All.Lequal;
  62. case GalComparisonOp.Greater: return All.Greater;
  63. case GalComparisonOp.NotEqual: return All.Notequal;
  64. case GalComparisonOp.Gequal: return All.Gequal;
  65. case GalComparisonOp.Always: return All.Always;
  66. }
  67. throw new ArgumentException(nameof(Func) + " \"" + Func + "\" is not valid!");
  68. }
  69. public static DrawElementsType GetDrawElementsType(GalIndexFormat Format)
  70. {
  71. switch (Format)
  72. {
  73. case GalIndexFormat.Byte: return DrawElementsType.UnsignedByte;
  74. case GalIndexFormat.Int16: return DrawElementsType.UnsignedShort;
  75. case GalIndexFormat.Int32: return DrawElementsType.UnsignedInt;
  76. }
  77. throw new ArgumentException(nameof(Format) + " \"" + Format + "\" is not valid!");
  78. }
  79. public static PrimitiveType GetPrimitiveType(GalPrimitiveType Type)
  80. {
  81. switch (Type)
  82. {
  83. case GalPrimitiveType.Points: return PrimitiveType.Points;
  84. case GalPrimitiveType.Lines: return PrimitiveType.Lines;
  85. case GalPrimitiveType.LineLoop: return PrimitiveType.LineLoop;
  86. case GalPrimitiveType.LineStrip: return PrimitiveType.LineStrip;
  87. case GalPrimitiveType.Triangles: return PrimitiveType.Triangles;
  88. case GalPrimitiveType.TriangleStrip: return PrimitiveType.TriangleStrip;
  89. case GalPrimitiveType.TriangleFan: return PrimitiveType.TriangleFan;
  90. case GalPrimitiveType.Polygon: return PrimitiveType.Polygon;
  91. case GalPrimitiveType.LinesAdjacency: return PrimitiveType.LinesAdjacency;
  92. case GalPrimitiveType.LineStripAdjacency: return PrimitiveType.LineStripAdjacency;
  93. case GalPrimitiveType.TrianglesAdjacency: return PrimitiveType.TrianglesAdjacency;
  94. case GalPrimitiveType.TriangleStripAdjacency: return PrimitiveType.TriangleStripAdjacency;
  95. case GalPrimitiveType.Patches: return PrimitiveType.Patches;
  96. }
  97. throw new ArgumentException(nameof(Type) + " \"" + Type + "\" is not valid!");
  98. }
  99. public static ShaderType GetShaderType(GalShaderType Type)
  100. {
  101. switch (Type)
  102. {
  103. case GalShaderType.Vertex: return ShaderType.VertexShader;
  104. case GalShaderType.TessControl: return ShaderType.TessControlShader;
  105. case GalShaderType.TessEvaluation: return ShaderType.TessEvaluationShader;
  106. case GalShaderType.Geometry: return ShaderType.GeometryShader;
  107. case GalShaderType.Fragment: return ShaderType.FragmentShader;
  108. }
  109. throw new ArgumentException(nameof(Type) + " \"" + Type + "\" is not valid!");
  110. }
  111. public static (PixelInternalFormat, PixelFormat, PixelType) GetImageFormat(GalImageFormat Format)
  112. {
  113. switch (Format)
  114. {
  115. case GalImageFormat.RGBA32 | GalImageFormat.Float: return (PixelInternalFormat.Rgba32f, PixelFormat.Rgba, PixelType.Float);
  116. case GalImageFormat.RGBA32 | GalImageFormat.Sint: return (PixelInternalFormat.Rgba32i, PixelFormat.RgbaInteger, PixelType.Int);
  117. case GalImageFormat.RGBA32 | GalImageFormat.Uint: return (PixelInternalFormat.Rgba32ui, PixelFormat.RgbaInteger, PixelType.UnsignedInt);
  118. case GalImageFormat.RGBA16 | GalImageFormat.Float: return (PixelInternalFormat.Rgba16f, PixelFormat.Rgba, PixelType.HalfFloat);
  119. case GalImageFormat.RGBA16 | GalImageFormat.Sint: return (PixelInternalFormat.Rgba16i, PixelFormat.RgbaInteger, PixelType.Short);
  120. case GalImageFormat.RGBA16 | GalImageFormat.Uint: return (PixelInternalFormat.Rgba16ui, PixelFormat.RgbaInteger, PixelType.UnsignedShort);
  121. case GalImageFormat.RGBA16 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgba16, PixelFormat.Rgba, PixelType.UnsignedShort);
  122. case GalImageFormat.RG32 | GalImageFormat.Float: return (PixelInternalFormat.Rg32f, PixelFormat.Rg, PixelType.Float);
  123. case GalImageFormat.RG32 | GalImageFormat.Sint: return (PixelInternalFormat.Rg32i, PixelFormat.RgInteger, PixelType.Int);
  124. case GalImageFormat.RG32 | GalImageFormat.Uint: return (PixelInternalFormat.Rg32ui, PixelFormat.RgInteger, PixelType.UnsignedInt);
  125. case GalImageFormat.RGBX8 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgb8, PixelFormat.Rgba, PixelType.UnsignedByte);
  126. case GalImageFormat.RGBA8 | GalImageFormat.Snorm: return (PixelInternalFormat.Rgba8Snorm, PixelFormat.Rgba, PixelType.Byte);
  127. case GalImageFormat.RGBA8 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgba8, PixelFormat.Rgba, PixelType.UnsignedByte);
  128. case GalImageFormat.RGBA8 | GalImageFormat.Sint: return (PixelInternalFormat.Rgba8i, PixelFormat.RgbaInteger, PixelType.Byte);
  129. case GalImageFormat.RGBA8 | GalImageFormat.Uint: return (PixelInternalFormat.Rgba8ui, PixelFormat.RgbaInteger, PixelType.UnsignedByte);
  130. case GalImageFormat.RGBA8 | GalImageFormat.Srgb: return (PixelInternalFormat.Srgb8Alpha8, PixelFormat.Rgba, PixelType.UnsignedByte);
  131. case GalImageFormat.BGRA8 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgba8, PixelFormat.Bgra, PixelType.UnsignedByte);
  132. case GalImageFormat.BGRA8 | GalImageFormat.Srgb: return (PixelInternalFormat.Srgb8Alpha8, PixelFormat.Bgra, PixelType.UnsignedByte);
  133. case GalImageFormat.RGBA4 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgba4, PixelFormat.Rgba, PixelType.UnsignedShort4444Reversed);
  134. case GalImageFormat.RGB10A2 | GalImageFormat.Uint: return (PixelInternalFormat.Rgb10A2ui, PixelFormat.RgbaInteger, PixelType.UnsignedInt2101010Reversed);
  135. case GalImageFormat.RGB10A2 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgb10A2, PixelFormat.Rgba, PixelType.UnsignedInt2101010Reversed);
  136. case GalImageFormat.R32 | GalImageFormat.Float: return (PixelInternalFormat.R32f, PixelFormat.Red, PixelType.Float);
  137. case GalImageFormat.R32 | GalImageFormat.Sint: return (PixelInternalFormat.R32i, PixelFormat.Red, PixelType.Int);
  138. case GalImageFormat.R32 | GalImageFormat.Uint: return (PixelInternalFormat.R32ui, PixelFormat.Red, PixelType.UnsignedInt);
  139. case GalImageFormat.BGR5A1 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgb5A1, PixelFormat.Rgba, PixelType.UnsignedShort5551);
  140. case GalImageFormat.RGB5A1 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgb5A1, PixelFormat.Rgba, PixelType.UnsignedShort1555Reversed);
  141. case GalImageFormat.RGB565 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgba, PixelFormat.Rgb, PixelType.UnsignedShort565Reversed);
  142. case GalImageFormat.RG16 | GalImageFormat.Float: return (PixelInternalFormat.Rg16f, PixelFormat.Rg, PixelType.HalfFloat);
  143. case GalImageFormat.RG16 | GalImageFormat.Sint: return (PixelInternalFormat.Rg16i, PixelFormat.RgInteger, PixelType.Short);
  144. case GalImageFormat.RG16 | GalImageFormat.Snorm: return (PixelInternalFormat.Rg16Snorm, PixelFormat.Rg, PixelType.Short);
  145. case GalImageFormat.RG16 | GalImageFormat.Uint: return (PixelInternalFormat.Rg16ui, PixelFormat.RgInteger, PixelType.UnsignedShort);
  146. case GalImageFormat.RG16 | GalImageFormat.Unorm: return (PixelInternalFormat.Rg16, PixelFormat.Rg, PixelType.UnsignedShort);
  147. case GalImageFormat.RG8 | GalImageFormat.Sint: return (PixelInternalFormat.Rg8i, PixelFormat.RgInteger, PixelType.Byte);
  148. case GalImageFormat.RG8 | GalImageFormat.Snorm: return (PixelInternalFormat.Rg8Snorm, PixelFormat.Rg, PixelType.Byte);
  149. case GalImageFormat.RG8 | GalImageFormat.Uint: return (PixelInternalFormat.Rg8ui, PixelFormat.RgInteger, PixelType.UnsignedByte);
  150. case GalImageFormat.RG8 | GalImageFormat.Unorm: return (PixelInternalFormat.Rg8, PixelFormat.Rg, PixelType.UnsignedByte);
  151. case GalImageFormat.R16 | GalImageFormat.Float: return (PixelInternalFormat.R16f, PixelFormat.Red, PixelType.HalfFloat);
  152. case GalImageFormat.R16 | GalImageFormat.Sint: return (PixelInternalFormat.R16i, PixelFormat.RedInteger, PixelType.Short);
  153. case GalImageFormat.R16 | GalImageFormat.Snorm: return (PixelInternalFormat.R16Snorm, PixelFormat.Red, PixelType.Short);
  154. case GalImageFormat.R16 | GalImageFormat.Uint: return (PixelInternalFormat.R16ui, PixelFormat.RedInteger, PixelType.UnsignedShort);
  155. case GalImageFormat.R16 | GalImageFormat.Unorm: return (PixelInternalFormat.R16, PixelFormat.Red, PixelType.UnsignedShort);
  156. case GalImageFormat.R8 | GalImageFormat.Sint: return (PixelInternalFormat.R8i, PixelFormat.RedInteger, PixelType.Byte);
  157. case GalImageFormat.R8 | GalImageFormat.Snorm: return (PixelInternalFormat.R8Snorm, PixelFormat.Red, PixelType.Byte);
  158. case GalImageFormat.R8 | GalImageFormat.Uint: return (PixelInternalFormat.R8ui, PixelFormat.RedInteger, PixelType.UnsignedByte);
  159. case GalImageFormat.R8 | GalImageFormat.Unorm: return (PixelInternalFormat.R8, PixelFormat.Red, PixelType.UnsignedByte);
  160. case GalImageFormat.R11G11B10 | GalImageFormat.Float: return (PixelInternalFormat.R11fG11fB10f, PixelFormat.Rgb, PixelType.UnsignedInt10F11F11FRev);
  161. case GalImageFormat.D16 | GalImageFormat.Unorm: return (PixelInternalFormat.DepthComponent16, PixelFormat.DepthComponent, PixelType.UnsignedShort);
  162. case GalImageFormat.D24 | GalImageFormat.Unorm: return (PixelInternalFormat.DepthComponent24, PixelFormat.DepthComponent, PixelType.UnsignedInt);
  163. case GalImageFormat.D24S8 | GalImageFormat.Uint: return (PixelInternalFormat.Depth24Stencil8, PixelFormat.DepthStencil, PixelType.UnsignedInt248);
  164. case GalImageFormat.D24S8 | GalImageFormat.Unorm: return (PixelInternalFormat.Depth24Stencil8, PixelFormat.DepthStencil, PixelType.UnsignedInt248);
  165. case GalImageFormat.D32 | GalImageFormat.Float: return (PixelInternalFormat.DepthComponent32f, PixelFormat.DepthComponent, PixelType.Float);
  166. case GalImageFormat.D32S8 | GalImageFormat.Float: return (PixelInternalFormat.Depth32fStencil8, PixelFormat.DepthStencil, PixelType.Float32UnsignedInt248Rev);
  167. }
  168. throw new NotImplementedException($"{Format & GalImageFormat.FormatMask} {Format & GalImageFormat.TypeMask}");
  169. }
  170. public static InternalFormat GetCompressedImageFormat(GalImageFormat Format)
  171. {
  172. switch (Format)
  173. {
  174. case GalImageFormat.BptcSfloat | GalImageFormat.Float: return InternalFormat.CompressedRgbBptcSignedFloat;
  175. case GalImageFormat.BptcUfloat | GalImageFormat.Float: return InternalFormat.CompressedRgbBptcUnsignedFloat;
  176. case GalImageFormat.BptcUnorm | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaBptcUnorm;
  177. case GalImageFormat.BptcUnorm | GalImageFormat.Srgb: return InternalFormat.CompressedSrgbAlphaBptcUnorm;
  178. case GalImageFormat.BC1 | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaS3tcDxt1Ext;
  179. case GalImageFormat.BC1 | GalImageFormat.Srgb: return InternalFormat.CompressedSrgbAlphaS3tcDxt1Ext;
  180. case GalImageFormat.BC2 | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaS3tcDxt3Ext;
  181. case GalImageFormat.BC2 | GalImageFormat.Srgb: return InternalFormat.CompressedSrgbAlphaS3tcDxt3Ext;
  182. case GalImageFormat.BC3 | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaS3tcDxt5Ext;
  183. case GalImageFormat.BC3 | GalImageFormat.Srgb: return InternalFormat.CompressedSrgbAlphaS3tcDxt5Ext;
  184. case GalImageFormat.BC4 | GalImageFormat.Snorm: return InternalFormat.CompressedSignedRedRgtc1;
  185. case GalImageFormat.BC4 | GalImageFormat.Unorm: return InternalFormat.CompressedRedRgtc1;
  186. case GalImageFormat.BC5 | GalImageFormat.Snorm: return InternalFormat.CompressedSignedRgRgtc2;
  187. case GalImageFormat.BC5 | GalImageFormat.Unorm: return InternalFormat.CompressedRgRgtc2;
  188. }
  189. throw new NotImplementedException($"{Format & GalImageFormat.FormatMask} {Format & GalImageFormat.TypeMask}");
  190. }
  191. public static All GetTextureSwizzle(GalTextureSource Source)
  192. {
  193. switch (Source)
  194. {
  195. case GalTextureSource.Zero: return All.Zero;
  196. case GalTextureSource.Red: return All.Red;
  197. case GalTextureSource.Green: return All.Green;
  198. case GalTextureSource.Blue: return All.Blue;
  199. case GalTextureSource.Alpha: return All.Alpha;
  200. case GalTextureSource.OneInt: return All.One;
  201. case GalTextureSource.OneFloat: return All.One;
  202. }
  203. throw new ArgumentException(nameof(Source) + " \"" + Source + "\" is not valid!");
  204. }
  205. public static TextureWrapMode GetTextureWrapMode(GalTextureWrap Wrap)
  206. {
  207. switch (Wrap)
  208. {
  209. case GalTextureWrap.Repeat: return TextureWrapMode.Repeat;
  210. case GalTextureWrap.MirroredRepeat: return TextureWrapMode.MirroredRepeat;
  211. case GalTextureWrap.ClampToEdge: return TextureWrapMode.ClampToEdge;
  212. case GalTextureWrap.ClampToBorder: return TextureWrapMode.ClampToBorder;
  213. case GalTextureWrap.Clamp: return TextureWrapMode.Clamp;
  214. }
  215. if (OGLExtension.TextureMirrorClamp)
  216. {
  217. switch (Wrap)
  218. {
  219. case GalTextureWrap.MirrorClampToEdge: return (TextureWrapMode)ExtTextureMirrorClamp.MirrorClampToEdgeExt;
  220. case GalTextureWrap.MirrorClampToBorder: return (TextureWrapMode)ExtTextureMirrorClamp.MirrorClampToBorderExt;
  221. case GalTextureWrap.MirrorClamp: return (TextureWrapMode)ExtTextureMirrorClamp.MirrorClampExt;
  222. }
  223. }
  224. else
  225. {
  226. //Fallback to non-mirrored clamps
  227. switch (Wrap)
  228. {
  229. case GalTextureWrap.MirrorClampToEdge: return TextureWrapMode.ClampToEdge;
  230. case GalTextureWrap.MirrorClampToBorder: return TextureWrapMode.ClampToBorder;
  231. case GalTextureWrap.MirrorClamp: return TextureWrapMode.Clamp;
  232. }
  233. }
  234. throw new ArgumentException(nameof(Wrap) + " \"" + Wrap + "\" is not valid!");
  235. }
  236. public static TextureMinFilter GetTextureMinFilter(
  237. GalTextureFilter MinFilter,
  238. GalTextureMipFilter MipFilter)
  239. {
  240. //TODO: Mip (needs mipmap support first).
  241. switch (MinFilter)
  242. {
  243. case GalTextureFilter.Nearest: return TextureMinFilter.Nearest;
  244. case GalTextureFilter.Linear: return TextureMinFilter.Linear;
  245. }
  246. throw new ArgumentException(nameof(MinFilter) + " \"" + MinFilter + "\" is not valid!");
  247. }
  248. public static TextureMagFilter GetTextureMagFilter(GalTextureFilter Filter)
  249. {
  250. switch (Filter)
  251. {
  252. case GalTextureFilter.Nearest: return TextureMagFilter.Nearest;
  253. case GalTextureFilter.Linear: return TextureMagFilter.Linear;
  254. }
  255. throw new ArgumentException(nameof(Filter) + " \"" + Filter + "\" is not valid!");
  256. }
  257. public static BlendEquationMode GetBlendEquation(GalBlendEquation BlendEquation)
  258. {
  259. switch (BlendEquation)
  260. {
  261. case GalBlendEquation.FuncAdd:
  262. case GalBlendEquation.FuncAddGl:
  263. return BlendEquationMode.FuncAdd;
  264. case GalBlendEquation.FuncSubtract:
  265. case GalBlendEquation.FuncSubtractGl:
  266. return BlendEquationMode.FuncSubtract;
  267. case GalBlendEquation.FuncReverseSubtract:
  268. case GalBlendEquation.FuncReverseSubtractGl:
  269. return BlendEquationMode.FuncReverseSubtract;
  270. case GalBlendEquation.Min:
  271. case GalBlendEquation.MinGl:
  272. return BlendEquationMode.Min;
  273. case GalBlendEquation.Max:
  274. case GalBlendEquation.MaxGl:
  275. return BlendEquationMode.Max;
  276. }
  277. throw new ArgumentException(nameof(BlendEquation) + " \"" + BlendEquation + "\" is not valid!");
  278. }
  279. public static BlendingFactor GetBlendFactor(GalBlendFactor BlendFactor)
  280. {
  281. switch (BlendFactor)
  282. {
  283. case GalBlendFactor.Zero:
  284. case GalBlendFactor.ZeroGl:
  285. return BlendingFactor.Zero;
  286. case GalBlendFactor.One:
  287. case GalBlendFactor.OneGl:
  288. return BlendingFactor.One;
  289. case GalBlendFactor.SrcColor:
  290. case GalBlendFactor.SrcColorGl:
  291. return BlendingFactor.SrcColor;
  292. case GalBlendFactor.OneMinusSrcColor:
  293. case GalBlendFactor.OneMinusSrcColorGl:
  294. return BlendingFactor.OneMinusSrcColor;
  295. case GalBlendFactor.DstColor:
  296. case GalBlendFactor.DstColorGl:
  297. return BlendingFactor.DstColor;
  298. case GalBlendFactor.OneMinusDstColor:
  299. case GalBlendFactor.OneMinusDstColorGl:
  300. return BlendingFactor.OneMinusDstColor;
  301. case GalBlendFactor.SrcAlpha:
  302. case GalBlendFactor.SrcAlphaGl:
  303. return BlendingFactor.SrcAlpha;
  304. case GalBlendFactor.OneMinusSrcAlpha:
  305. case GalBlendFactor.OneMinusSrcAlphaGl:
  306. return BlendingFactor.OneMinusSrcAlpha;
  307. case GalBlendFactor.DstAlpha:
  308. case GalBlendFactor.DstAlphaGl:
  309. return BlendingFactor.DstAlpha;
  310. case GalBlendFactor.OneMinusDstAlpha:
  311. case GalBlendFactor.OneMinusDstAlphaGl:
  312. return BlendingFactor.OneMinusDstAlpha;
  313. case GalBlendFactor.OneMinusConstantColor:
  314. case GalBlendFactor.OneMinusConstantColorGl:
  315. return BlendingFactor.OneMinusConstantColor;
  316. case GalBlendFactor.ConstantAlpha:
  317. case GalBlendFactor.ConstantAlphaGl:
  318. return BlendingFactor.ConstantAlpha;
  319. case GalBlendFactor.OneMinusConstantAlpha:
  320. case GalBlendFactor.OneMinusConstantAlphaGl:
  321. return BlendingFactor.OneMinusConstantAlpha;
  322. case GalBlendFactor.SrcAlphaSaturate:
  323. case GalBlendFactor.SrcAlphaSaturateGl:
  324. return BlendingFactor.SrcAlphaSaturate;
  325. case GalBlendFactor.Src1Color:
  326. case GalBlendFactor.Src1ColorGl:
  327. return BlendingFactor.Src1Color;
  328. case GalBlendFactor.OneMinusSrc1Color:
  329. case GalBlendFactor.OneMinusSrc1ColorGl:
  330. return (BlendingFactor)BlendingFactorSrc.OneMinusSrc1Color;
  331. case GalBlendFactor.Src1Alpha:
  332. case GalBlendFactor.Src1AlphaGl:
  333. return BlendingFactor.Src1Alpha;
  334. case GalBlendFactor.OneMinusSrc1Alpha:
  335. case GalBlendFactor.OneMinusSrc1AlphaGl:
  336. return (BlendingFactor)BlendingFactorSrc.OneMinusSrc1Alpha;
  337. case GalBlendFactor.ConstantColor:
  338. case GalBlendFactor.ConstantColorGl:
  339. return BlendingFactor.ConstantColor;
  340. }
  341. throw new ArgumentException(nameof(BlendFactor) + " \"" + BlendFactor + "\" is not valid!");
  342. }
  343. }
  344. }