OperandInfo.cs 1.0 KB

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