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