AstOperation.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Ryujinx.Graphics.Shader.IntermediateRepresentation;
  2. using static Ryujinx.Graphics.Shader.StructuredIr.AstHelper;
  3. namespace Ryujinx.Graphics.Shader.StructuredIr
  4. {
  5. class AstOperation : AstNode
  6. {
  7. public Instruction Inst { get; }
  8. public int ComponentMask { get; }
  9. private IAstNode[] _sources;
  10. public int SourcesCount => _sources.Length;
  11. public AstOperation(Instruction inst, params IAstNode[] sources)
  12. {
  13. Inst = inst;
  14. _sources = sources;
  15. foreach (IAstNode source in sources)
  16. {
  17. AddUse(source, this);
  18. }
  19. ComponentMask = 1;
  20. }
  21. public AstOperation(Instruction inst, int compMask, params IAstNode[] sources) : this(inst, sources)
  22. {
  23. ComponentMask = compMask;
  24. }
  25. public IAstNode GetSource(int index)
  26. {
  27. return _sources[index];
  28. }
  29. public void SetSource(int index, IAstNode source)
  30. {
  31. RemoveUse(_sources[index], this);
  32. AddUse(source, this);
  33. _sources[index] = source;
  34. }
  35. }
  36. }