private void RegisterProfiler(GPUProfiler profiler) { if (!profiler.IsRegistered) { global::StatsMonitor.StatsMonitor.Instance.RegistProfiler(profiler); profiler.IsRegistered = true; } }
private void UnregisterProfiler(GPUProfiler profiler) { if (profiler.IsRegistered) { global::StatsMonitor.StatsMonitor.Instance.UnRegistProfiler(profiler); profiler.IsRegistered = false; } }
public void Update() { #if HAVE_FAST_GPU_PROFILER && ENABLE_PROFILER if (!Profiler.profileGPUFast) { Cleanup(); return; } Initialize(); _mainThreadProfiler.SetData(Profiler.MainThreadFrameTime); _renderThreadProfiler.SetData(Profiler.RenderThreadFrameTime); _gpuProfiler.SetData(Profiler.FastGPUTime); _samples.Clear(); if (Profiler.GetFastGpuProfilerSamples(_samples)) { bool reset = false; if (_samples.Count != _profilers.Count) { foreach (var profiler in _profilers) { UnregisterProfiler(profiler); } _profilers.Clear(); reset = true; } for (int i = 0; i < _samples.Count; ++i) { var sample = _samples[i]; var name = GetStackLevelName(sample.StatName, sample.StackLevel); GPUProfiler profiler = null; if (reset) { profiler = new GPUProfiler(name); _profilers.Add(profiler); RegisterProfiler(profiler); } profiler = _profilers[i]; profiler.Name = name; profiler.SetData(sample.ElapsedTime); } } #endif }