/ src / Ryujinx.Graphics.Shader / AttributeType.cs
AttributeType.cs
 1  using Ryujinx.Graphics.Shader.Translation;
 2  using System;
 3  
 4  namespace Ryujinx.Graphics.Shader
 5  {
 6      public enum AttributeType : byte
 7      {
 8          // Generic types.
 9          Float,
10          Sint,
11          Uint,
12          Sscaled,
13          Uscaled,
14  
15          Packed = 1 << 6,
16          PackedRgb10A2Signed = 1 << 7,
17          AnyPacked = Packed | PackedRgb10A2Signed,
18      }
19  
20      static class AttributeTypeExtensions
21      {
22          public static AggregateType ToAggregateType(this AttributeType type)
23          {
24              return (type & ~AttributeType.AnyPacked) switch
25              {
26                  AttributeType.Float => AggregateType.FP32,
27                  AttributeType.Sint => AggregateType.S32,
28                  AttributeType.Uint => AggregateType.U32,
29                  _ => throw new ArgumentException($"Invalid attribute type \"{type}\"."),
30              };
31          }
32  
33          public static AggregateType ToAggregateType(this AttributeType type, bool supportsScaledFormats)
34          {
35              return (type & ~AttributeType.AnyPacked) switch
36              {
37                  AttributeType.Float => AggregateType.FP32,
38                  AttributeType.Sint => AggregateType.S32,
39                  AttributeType.Uint => AggregateType.U32,
40                  AttributeType.Sscaled => supportsScaledFormats ? AggregateType.FP32 : AggregateType.S32,
41                  AttributeType.Uscaled => supportsScaledFormats ? AggregateType.FP32 : AggregateType.U32,
42                  _ => throw new ArgumentException($"Invalid attribute type \"{type}\"."),
43              };
44          }
45      }
46  }