IoDefinition.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using Ryujinx.Graphics.Shader.IntermediateRepresentation;
  2. using System;
  3. namespace Ryujinx.Graphics.Shader.StructuredIr
  4. {
  5. readonly struct IoDefinition : IEquatable<IoDefinition>
  6. {
  7. public StorageKind StorageKind { get; }
  8. public IoVariable IoVariable { get; }
  9. public int Location { get; }
  10. public int Component { get; }
  11. public IoDefinition(StorageKind storageKind, IoVariable ioVariable, int location = 0, int component = 0)
  12. {
  13. StorageKind = storageKind;
  14. IoVariable = ioVariable;
  15. Location = location;
  16. Component = component;
  17. }
  18. public override bool Equals(object other)
  19. {
  20. return other is IoDefinition ioDefinition && Equals(ioDefinition);
  21. }
  22. public bool Equals(IoDefinition other)
  23. {
  24. return StorageKind == other.StorageKind &&
  25. IoVariable == other.IoVariable &&
  26. Location == other.Location &&
  27. Component == other.Component;
  28. }
  29. public override int GetHashCode()
  30. {
  31. return (int)StorageKind | ((int)IoVariable << 8) | (Location << 16) | (Component << 24);
  32. }
  33. public override string ToString()
  34. {
  35. return $"{StorageKind}.{IoVariable}.{Location}.{Component}";
  36. }
  37. }
  38. }