OperandInfo.cs 1009 B

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