Add support for using Tracy profiler on Switch
This commit is contained in:
@@ -34,6 +34,7 @@ public class Profiler : EngineModule
|
|||||||
case TargetPlatform.Android:
|
case TargetPlatform.Android:
|
||||||
case TargetPlatform.Linux:
|
case TargetPlatform.Linux:
|
||||||
case TargetPlatform.Windows:
|
case TargetPlatform.Windows:
|
||||||
|
case TargetPlatform.Switch:
|
||||||
options.PublicDependencies.Add("tracy");
|
options.PublicDependencies.Add("tracy");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
14
Source/ThirdParty/tracy/client/TracyProfiler.cpp
vendored
14
Source/ThirdParty/tracy/client/TracyProfiler.cpp
vendored
@@ -113,6 +113,11 @@ extern "C" typedef BOOL (WINAPI *t_GetLogicalProcessorInformationEx)( LOGICAL_PR
|
|||||||
# include <mutex>
|
# include <mutex>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined _WIN32 && !defined __linux__ && !defined __APPLE__
|
||||||
|
#include "Engine/Core/Types/String.h"
|
||||||
|
#include "Engine/Platform/MemoryStats.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -383,7 +388,7 @@ static int64_t SetupHwTimer()
|
|||||||
|
|
||||||
static const char* GetProcessName()
|
static const char* GetProcessName()
|
||||||
{
|
{
|
||||||
const char* processName = "unknown";
|
const char* processName = "FlaxEngine";
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static char buf[_MAX_PATH];
|
static char buf[_MAX_PATH];
|
||||||
GetModuleFileNameA( nullptr, buf, _MAX_PATH );
|
GetModuleFileNameA( nullptr, buf, _MAX_PATH );
|
||||||
@@ -518,7 +523,10 @@ static const char* GetHostInfo()
|
|||||||
#elif defined __OpenBSD__
|
#elif defined __OpenBSD__
|
||||||
ptr += sprintf( ptr, "OS: BSD (OpenBSD)\n" );
|
ptr += sprintf( ptr, "OS: BSD (OpenBSD)\n" );
|
||||||
#else
|
#else
|
||||||
ptr += sprintf( ptr, "OS: unknown\n" );
|
String computerName = Platform::GetComputerName();
|
||||||
|
char computerNameBuf[60];
|
||||||
|
StringUtils::ConvertUTF162ANSI(computerName.Get(), computerNameBuf, computerName.Length());
|
||||||
|
ptr += sprintf( ptr, "OS: %s\n", computerNameBuf );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined _MSC_VER
|
#if defined _MSC_VER
|
||||||
@@ -690,7 +698,7 @@ static const char* GetHostInfo()
|
|||||||
sysctlbyname( "hw.physmem", &memSize, &sz, nullptr, 0 );
|
sysctlbyname( "hw.physmem", &memSize, &sz, nullptr, 0 );
|
||||||
ptr += sprintf( ptr, "RAM: %zu MB\n", memSize / 1024 / 1024 );
|
ptr += sprintf( ptr, "RAM: %zu MB\n", memSize / 1024 / 1024 );
|
||||||
#else
|
#else
|
||||||
ptr += sprintf( ptr, "RAM: unknown\n" );
|
ptr += sprintf( ptr, "RAM: %zu MB\n", (size_t)Platform::GetMemoryStats().TotalPhysicalMemory / 1024 / 1024 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#if defined TRACY_ENABLE && !defined __EMSCRIPTEN__
|
#if defined TRACY_ENABLE && !defined __EMSCRIPTEN__ && !defined TRACY_USE_MALLOC
|
||||||
# include "../client/tracy_rpmalloc.hpp"
|
# include "../client/tracy_rpmalloc.hpp"
|
||||||
# define TRACY_USE_RPMALLOC
|
# define TRACY_USE_RPMALLOC
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -450,6 +450,9 @@ ListenSocket::~ListenSocket()
|
|||||||
|
|
||||||
static int addrinfo_and_socket_for_family( uint16_t port, int ai_family, struct addrinfo** res )
|
static int addrinfo_and_socket_for_family( uint16_t port, int ai_family, struct addrinfo** res )
|
||||||
{
|
{
|
||||||
|
#if PLATFORM_SWITCH
|
||||||
|
Platform::GetNetworkConnectionType(); // Ensure to have network service initialized before using sockets
|
||||||
|
#endif
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
memset( &hints, 0, sizeof( hints ) );
|
memset( &hints, 0, sizeof( hints ) );
|
||||||
hints.ai_family = ai_family;
|
hints.ai_family = ai_family;
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ extern "C" typedef HRESULT (WINAPI *t_GetThreadDescription)( HANDLE, PWSTR* );
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
# include <atomic>
|
# include <atomic>
|
||||||
# include "TracyAlloc.hpp"
|
# include "TracyAlloc.hpp"
|
||||||
|
|
||||||
|
#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__linux__)
|
||||||
|
#include "Engine/Platform/Platform.h"
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace tracy
|
namespace tracy
|
||||||
@@ -88,7 +92,7 @@ TRACY_API uint32_t GetThreadHandleImpl()
|
|||||||
// thread identifier. It is a pointer to a library-allocated data structure instead.
|
// thread identifier. It is a pointer to a library-allocated data structure instead.
|
||||||
// Such pointers will be reused heavily, making the pthread_t non-unique. Additionally
|
// Such pointers will be reused heavily, making the pthread_t non-unique. Additionally
|
||||||
// a 64-bit pointer cannot be reliably truncated to 32 bits.
|
// a 64-bit pointer cannot be reliably truncated to 32 bits.
|
||||||
#error "Unsupported platform!"
|
return Platform::GetCurrentThreadID();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
14
Source/ThirdParty/tracy/tracy.Build.cs
vendored
14
Source/ThirdParty/tracy/tracy.Build.cs
vendored
@@ -40,14 +40,20 @@ public class tracy : ThirdPartyModule
|
|||||||
options.PublicDefinitions.Add("TRACY_ENABLE");
|
options.PublicDefinitions.Add("TRACY_ENABLE");
|
||||||
options.PrivateDefinitions.Add("TRACY_NO_INVARIANT_CHECK");
|
options.PrivateDefinitions.Add("TRACY_NO_INVARIANT_CHECK");
|
||||||
options.PrivateDefinitions.Add("TRACY_NO_FRAME_IMAGE");
|
options.PrivateDefinitions.Add("TRACY_NO_FRAME_IMAGE");
|
||||||
if (options.Platform.Target == TargetPlatform.Windows)
|
|
||||||
{
|
|
||||||
options.PrivateDefinitions.Add("TRACY_DBGHELP_LOCK=DbgHelp");
|
|
||||||
}
|
|
||||||
if (OnDemand)
|
if (OnDemand)
|
||||||
{
|
{
|
||||||
options.PublicDefinitions.Add("TRACY_ON_DEMAND");
|
options.PublicDefinitions.Add("TRACY_ON_DEMAND");
|
||||||
}
|
}
|
||||||
|
switch (options.Platform.Target)
|
||||||
|
{
|
||||||
|
case TargetPlatform.Windows:
|
||||||
|
options.PrivateDefinitions.Add("TRACY_DBGHELP_LOCK=DbgHelp");
|
||||||
|
break;
|
||||||
|
case TargetPlatform.Switch:
|
||||||
|
options.PrivateDefinitions.Add("TRACY_USE_MALLOC");
|
||||||
|
options.PrivateDefinitions.Add("TRACY_ONLY_IPV4");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
Reference in New Issue
Block a user