AttributeType.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Ryujinx.Graphics.Shader.StructuredIr;
  2. using Ryujinx.Graphics.Shader.Translation;
  3. using System;
  4. namespace Ryujinx.Graphics.Shader
  5. {
  6. public enum AttributeType : byte
  7. {
  8. // Generic types.
  9. Float,
  10. Sint,
  11. Uint
  12. }
  13. static class AttributeTypeExtensions
  14. {
  15. public static string ToVec4Type(this AttributeType type)
  16. {
  17. return type switch
  18. {
  19. AttributeType.Float => "vec4",
  20. AttributeType.Sint => "ivec4",
  21. AttributeType.Uint => "uvec4",
  22. _ => throw new ArgumentException($"Invalid attribute type \"{type}\".")
  23. };
  24. }
  25. public static VariableType ToVariableType(this AttributeType type)
  26. {
  27. return type switch
  28. {
  29. AttributeType.Float => VariableType.F32,
  30. AttributeType.Sint => VariableType.S32,
  31. AttributeType.Uint => VariableType.U32,
  32. _ => throw new ArgumentException($"Invalid attribute type \"{type}\".")
  33. };
  34. }
  35. public static AggregateType ToAggregateType(this AttributeType type)
  36. {
  37. return type switch
  38. {
  39. AttributeType.Float => AggregateType.FP32,
  40. AttributeType.Sint => AggregateType.S32,
  41. AttributeType.Uint => AggregateType.U32,
  42. _ => throw new ArgumentException($"Invalid attribute type \"{type}\".")
  43. };
  44. }
  45. }
  46. }