OperandInfo.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using Ryujinx.Graphics.Shader.IntermediateRepresentation;
  2. using Ryujinx.Graphics.Shader.Translation;
  3. using System;
  4. namespace Ryujinx.Graphics.Shader.StructuredIr
  5. {
  6. static class OperandInfo
  7. {
  8. public static AggregateType GetVarType(AstOperand operand)
  9. {
  10. if (operand.Type == OperandType.LocalVariable)
  11. {
  12. return operand.VarType;
  13. }
  14. else
  15. {
  16. return GetVarType(operand.Type);
  17. }
  18. }
  19. public static AggregateType GetVarType(OperandType type)
  20. {
  21. return type switch
  22. {
  23. OperandType.Argument => AggregateType.S32,
  24. OperandType.Attribute => AggregateType.FP32,
  25. OperandType.AttributePerPatch => AggregateType.FP32,
  26. OperandType.Constant => AggregateType.S32,
  27. OperandType.ConstantBuffer => AggregateType.FP32,
  28. OperandType.Undefined => AggregateType.S32,
  29. _ => throw new ArgumentException($"Invalid operand type \"{type}\".")
  30. };
  31. }
  32. }
  33. }