Fix nested profiler events usage

#https://github.com/FlaxEngine/FlaxEngine/issues/1380
This commit is contained in:
Wojtek Figat
2023-10-01 11:56:54 +02:00
parent 659a70dc81
commit 0eda67bd73
2 changed files with 42 additions and 17 deletions

View File

@@ -129,8 +129,15 @@ void ProfilerCPU::Thread::EndEvent()
{
const double time = Platform::GetTimeSeconds() * 1000.0;
_depth--;
Event& e = (Buffer.Last()--).Event();
e.End = time;
for (auto i = Buffer.Last(); i != Buffer.Begin(); --i)
{
Event& e = i.Event();
if (e.End <= 0)
{
e.End = time;
break;
}
}
}
bool ProfilerCPU::IsProfilingCurrentThread()