Counters.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using Ryujinx.Graphics.GAL;
  2. using Silk.NET.Vulkan;
  3. using System;
  4. namespace Ryujinx.Graphics.Vulkan.Queries
  5. {
  6. class Counters : IDisposable
  7. {
  8. private readonly CounterQueue[] _counterQueues;
  9. private readonly PipelineFull _pipeline;
  10. public Counters(VulkanRenderer gd, Device device, PipelineFull pipeline)
  11. {
  12. _pipeline = pipeline;
  13. int count = Enum.GetNames(typeof(CounterType)).Length;
  14. _counterQueues = new CounterQueue[count];
  15. for (int index = 0; index < count; index++)
  16. {
  17. CounterType type = (CounterType)index;
  18. _counterQueues[index] = new CounterQueue(gd, device, pipeline, type);
  19. }
  20. }
  21. public CounterQueueEvent QueueReport(CounterType type, EventHandler<ulong> resultHandler, bool hostReserved)
  22. {
  23. return _counterQueues[(int)type].QueueReport(resultHandler, _pipeline.DrawCount, hostReserved);
  24. }
  25. public void QueueReset(CounterType type)
  26. {
  27. _counterQueues[(int)type].QueueReset(_pipeline.DrawCount);
  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. }