Add Tracy profiler support

This commit is contained in:
Wojtek Figat
2021-05-02 11:24:42 +02:00
parent 1a261597c5
commit 543d1a3c0e
45 changed files with 14752 additions and 108 deletions

View File

@@ -4,6 +4,10 @@
#include "Engine/Threading/IRunnable.h"
#include "Engine/Threading/ThreadRegistry.h"
#include "Engine/Core/Log.h"
#if TRACY_ENABLE
#include "Engine/Core/Math/Math.h"
#include <ThirdParty/tracy/Tracy.h>
#endif
Delegate<Thread*> ThreadBase::ThreadStarting;
Delegate<Thread*, int32> ThreadBase::ThreadExiting;
@@ -70,6 +74,13 @@ int32 ThreadBase::Run()
ASSERT(_runnable);
const auto thread = static_cast<Thread*>(this);
_id = Platform::GetCurrentThreadID();
#if TRACY_ENABLE
char threadName[100];
const int32 threadNameLength = Math::Min<int32>(ARRAY_COUNT(threadName) - 1, _name.Length());
StringUtils::ConvertUTF162ANSI(*_name, threadName, threadNameLength);
threadName[threadNameLength] = 0;
tracy::SetThreadName(threadName);
#endif
ThreadRegistry::Add(thread);
ThreadStarting(thread);
int32 exitCode = 1;