Counters.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using Ryujinx.Graphics.GAL;
  2. using System;
  3. namespace Ryujinx.Graphics.OpenGL.Queries
  4. {
  5. class Counters : IDisposable
  6. {
  7. private CounterQueue[] _counterQueues;
  8. public Counters()
  9. {
  10. int count = Enum.GetNames(typeof(CounterType)).Length;
  11. _counterQueues = new CounterQueue[count];
  12. }
  13. public void Initialize()
  14. {
  15. for (int index = 0; index < _counterQueues.Length; index++)
  16. {
  17. CounterType type = (CounterType)index;
  18. _counterQueues[index] = new CounterQueue(type);
  19. }
  20. }
  21. public CounterQueueEvent QueueReport(CounterType type, EventHandler<ulong> resultHandler, ulong lastDrawIndex, bool hostReserved)
  22. {
  23. return _counterQueues[(int)type].QueueReport(resultHandler, lastDrawIndex, hostReserved);
  24. }
  25. public void QueueReset(CounterType type)
  26. {
  27. _counterQueues[(int)type].QueueReset();
  28. }
  29. public void Update()
  30. {
  31. foreach (var queue in _counterQueues)
  32. {
  33. queue.Flush(false);
  34. }
  35. }
  36. public void Flush(CounterType type)
  37. {
  38. _counterQueues[(int)type].Flush(true);
  39. }
  40. public void Dispose()
  41. {
  42. foreach (var queue in _counterQueues)
  43. {
  44. queue.Dispose();
  45. }
  46. }
  47. }
  48. }