Exemplo n.º 1
0
 private void RegisterProfiler(GPUProfiler profiler)
 {
     if (!profiler.IsRegistered)
     {
         global::StatsMonitor.StatsMonitor.Instance.RegistProfiler(profiler);
         profiler.IsRegistered = true;
     }
 }
Exemplo n.º 2
0
 private void UnregisterProfiler(GPUProfiler profiler)
 {
     if (profiler.IsRegistered)
     {
         global::StatsMonitor.StatsMonitor.Instance.UnRegistProfiler(profiler);
         profiler.IsRegistered = false;
     }
 }
Exemplo n.º 3
0
        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
        }