Counters.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 < _counterQueues.Length; index++)
  16. {
  17. CounterType type = (CounterType)index;
  18. _counterQueues[index] = new CounterQueue(gd, device, pipeline, type);
  19. }
  20. }
  21. public void ResetCounterPool()
  22. {
  23. foreach (var queue in _counterQueues)
  24. {
  25. queue.ResetCounterPool();
  26. }
  27. }
  28. public void ResetFutureCounters(CommandBuffer cmd, int count)
  29. {
  30. _counterQueues[(int)CounterType.SamplesPassed].ResetFutureCounters(cmd, count);
  31. }
  32. public CounterQueueEvent QueueReport(CounterType type, EventHandler<ulong> resultHandler, bool hostReserved)
  33. {
  34. return _counterQueues[(int)type].QueueReport(resultHandler, _pipeline.DrawCount, hostReserved);
  35. }
  36. public void QueueReset(CounterType type)
  37. {
  38. _counterQueues[(int)type].QueueReset(_pipeline.DrawCount);
  39. }
  40. public void Update()
  41. {
  42. foreach (var queue in _counterQueues)
  43. {
  44. queue.Flush(false);
  45. }
  46. }
  47. public void Flush(CounterType type)
  48. {
  49. _counterQueues[(int)type].Flush(true);
  50. }
  51. public void Dispose()
  52. {
  53. foreach (var queue in _counterQueues)
  54. {
  55. queue.Dispose();
  56. }
  57. }
  58. }
  59. }