Add conditional profiling in Editor (run only when using Profiler window)
This commit is contained in:
@@ -93,7 +93,7 @@ namespace FlaxEditor.Windows.Profiler
|
||||
_liveRecordingButton = toolstrip.AddButton(editor.Icons.Play64);
|
||||
_liveRecordingButton.LinkTooltip("Live profiling events recording");
|
||||
_liveRecordingButton.AutoCheck = true;
|
||||
_liveRecordingButton.Clicked += () => _liveRecordingButton.Icon = LiveRecording ? editor.Icons.Stop64 : editor.Icons.Play64;
|
||||
_liveRecordingButton.Clicked += OnLiveRecordingChanged;
|
||||
_clearButton = toolstrip.AddButton(editor.Icons.Rotate32, Clear);
|
||||
_clearButton.LinkTooltip("Clear data");
|
||||
toolstrip.AddSeparator();
|
||||
@@ -118,6 +118,12 @@ namespace FlaxEditor.Windows.Profiler
|
||||
_tabs.SelectedTabChanged += OnSelectedTabChanged;
|
||||
}
|
||||
|
||||
private void OnLiveRecordingChanged()
|
||||
{
|
||||
_liveRecordingButton.Icon = LiveRecording ? Editor.Icons.Stop64 : Editor.Icons.Play64;
|
||||
ProfilingTools.Enabled = LiveRecording;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the mode.
|
||||
/// </summary>
|
||||
|
||||
@@ -102,9 +102,6 @@ int32 Engine::Main(const Char* cmdLine)
|
||||
|
||||
Platform::SetHighDpiAwarenessEnabled(!CommandLine::Options.LowDPI.IsTrue());
|
||||
Time::StartupTime = DateTime::Now();
|
||||
#if COMPILE_WITH_PROFILER
|
||||
ProfilerCPU::Enabled = true;
|
||||
#endif
|
||||
Globals::StartupFolder = Globals::BinariesFolder = Platform::GetMainDirectory();
|
||||
#if USE_EDITOR
|
||||
Globals::StartupFolder /= TEXT("../../../..");
|
||||
|
||||
@@ -205,7 +205,7 @@ int32 ProfilerCPU::BeginEvent(const char* name)
|
||||
|
||||
void ProfilerCPU::EndEvent(int32 index)
|
||||
{
|
||||
if (Enabled && Thread::Current)
|
||||
if (index != -1 && Thread::Current)
|
||||
Thread::Current->EndEvent(index);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ RenderStatsData RenderStatsData::Counter;
|
||||
int32 ProfilerGPU::_depth = 0;
|
||||
Array<GPUTimerQuery*> ProfilerGPU::_timerQueriesPool;
|
||||
Array<GPUTimerQuery*> ProfilerGPU::_timerQueriesFree;
|
||||
bool ProfilerGPU::Enabled = true;
|
||||
bool ProfilerGPU::Enabled = false;
|
||||
int32 ProfilerGPU::CurrentBuffer = 0;
|
||||
ProfilerGPU::EventBuffer ProfilerGPU::Buffers[PROFILER_GPU_EVENTS_FRAMES];
|
||||
|
||||
|
||||
@@ -175,4 +175,15 @@ void ProfilingToolsService::Dispose()
|
||||
ProfilingTools::EventsGPU.SetCapacity(0);
|
||||
}
|
||||
|
||||
bool ProfilingTools::GetEnabled()
|
||||
{
|
||||
return ProfilerCPU::Enabled && ProfilerGPU::Enabled;
|
||||
}
|
||||
|
||||
void ProfilingTools::SetEnabled(bool enabled)
|
||||
{
|
||||
ProfilerCPU::Enabled = enabled;
|
||||
ProfilerGPU::Enabled = enabled;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -106,6 +106,16 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Controls the engine profiler (CPU, GPU, etc.) usage.
|
||||
/// </summary>
|
||||
API_PROPERTY() static bool GetEnabled();
|
||||
|
||||
/// <summary>
|
||||
/// Controls the engine profiler (CPU, GPU, etc.) usage.
|
||||
/// </summary>
|
||||
API_PROPERTY() static void SetEnabled(bool enabled);
|
||||
|
||||
/// <summary>
|
||||
/// The current collected main stats by the profiler from the local session. Updated every frame.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user