EnumConversion.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Ryujinx.Graphics.Shader.StructuredIr;
  2. using Ryujinx.Graphics.Shader.Translation;
  3. using System;
  4. using static Spv.Specification;
  5. namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
  6. {
  7. static class EnumConversion
  8. {
  9. public static AggregateType Convert(this VariableType type)
  10. {
  11. return type switch
  12. {
  13. VariableType.None => AggregateType.Void,
  14. VariableType.Bool => AggregateType.Bool,
  15. VariableType.F32 => AggregateType.FP32,
  16. VariableType.F64 => AggregateType.FP64,
  17. VariableType.S32 => AggregateType.S32,
  18. VariableType.U32 => AggregateType.U32,
  19. _ => throw new ArgumentException($"Invalid variable type \"{type}\".")
  20. };
  21. }
  22. public static ExecutionModel Convert(this ShaderStage stage)
  23. {
  24. return stage switch
  25. {
  26. ShaderStage.Compute => ExecutionModel.GLCompute,
  27. ShaderStage.Vertex => ExecutionModel.Vertex,
  28. ShaderStage.TessellationControl => ExecutionModel.TessellationControl,
  29. ShaderStage.TessellationEvaluation => ExecutionModel.TessellationEvaluation,
  30. ShaderStage.Geometry => ExecutionModel.Geometry,
  31. ShaderStage.Fragment => ExecutionModel.Fragment,
  32. _ => throw new ArgumentException($"Invalid shader stage \"{stage}\".")
  33. };
  34. }
  35. }
  36. }