Counters.cs
1 using Ryujinx.Graphics.GAL; 2 using Silk.NET.Vulkan; 3 using System; 4 5 namespace Ryujinx.Graphics.Vulkan.Queries 6 { 7 class Counters : IDisposable 8 { 9 private readonly CounterQueue[] _counterQueues; 10 private readonly PipelineFull _pipeline; 11 12 public Counters(VulkanRenderer gd, Device device, PipelineFull pipeline) 13 { 14 _pipeline = pipeline; 15 16 int count = Enum.GetNames(typeof(CounterType)).Length; 17 18 _counterQueues = new CounterQueue[count]; 19 20 for (int index = 0; index < _counterQueues.Length; index++) 21 { 22 CounterType type = (CounterType)index; 23 _counterQueues[index] = new CounterQueue(gd, device, pipeline, type); 24 } 25 } 26 27 public void ResetCounterPool() 28 { 29 foreach (var queue in _counterQueues) 30 { 31 queue.ResetCounterPool(); 32 } 33 } 34 35 public void ResetFutureCounters(CommandBuffer cmd, int count) 36 { 37 _counterQueues[(int)CounterType.SamplesPassed].ResetFutureCounters(cmd, count); 38 } 39 40 public CounterQueueEvent QueueReport(CounterType type, EventHandler<ulong> resultHandler, float divisor, bool hostReserved) 41 { 42 return _counterQueues[(int)type].QueueReport(resultHandler, divisor, _pipeline.DrawCount, hostReserved); 43 } 44 45 public void QueueReset(CounterType type) 46 { 47 _counterQueues[(int)type].QueueReset(_pipeline.DrawCount); 48 } 49 50 public void Update() 51 { 52 foreach (var queue in _counterQueues) 53 { 54 queue.Flush(false); 55 } 56 } 57 58 public void Flush(CounterType type) 59 { 60 _counterQueues[(int)type].Flush(true); 61 } 62 63 public void Dispose() 64 { 65 foreach (var queue in _counterQueues) 66 { 67 queue.Dispose(); 68 } 69 } 70 } 71 }