OperandInfo.cs 991 B

123456789101112131415161718192021222324252627282930313233
  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.Constant => AggregateType.S32,
  25. OperandType.ConstantBuffer => AggregateType.FP32,
  26. OperandType.Undefined => AggregateType.S32,
  27. _ => throw new ArgumentException($"Invalid operand type \"{type}\".")
  28. };
  29. }
  30. }
  31. }