diff --git a/Source/Engine/Profiler/Profiler.Build.cs b/Source/Engine/Profiler/Profiler.Build.cs index 1f324fb48..ae6577473 100644 --- a/Source/Engine/Profiler/Profiler.Build.cs +++ b/Source/Engine/Profiler/Profiler.Build.cs @@ -34,6 +34,7 @@ public class Profiler : EngineModule case TargetPlatform.Android: case TargetPlatform.Linux: case TargetPlatform.Windows: + case TargetPlatform.Switch: options.PublicDependencies.Add("tracy"); break; } diff --git a/Source/ThirdParty/tracy/client/TracyProfiler.cpp b/Source/ThirdParty/tracy/client/TracyProfiler.cpp index 59c31d6f8..6d67eabf2 100644 --- a/Source/ThirdParty/tracy/client/TracyProfiler.cpp +++ b/Source/ThirdParty/tracy/client/TracyProfiler.cpp @@ -113,6 +113,11 @@ extern "C" typedef BOOL (WINAPI *t_GetLogicalProcessorInformationEx)( LOGICAL_PR # include #endif +#if !defined _WIN32 && !defined __linux__ && !defined __APPLE__ +#include "Engine/Core/Types/String.h" +#include "Engine/Platform/MemoryStats.h" +#endif + namespace tracy { @@ -383,7 +388,7 @@ static int64_t SetupHwTimer() static const char* GetProcessName() { - const char* processName = "unknown"; + const char* processName = "FlaxEngine"; #ifdef _WIN32 static char buf[_MAX_PATH]; GetModuleFileNameA( nullptr, buf, _MAX_PATH ); @@ -518,7 +523,10 @@ static const char* GetHostInfo() #elif defined __OpenBSD__ ptr += sprintf( ptr, "OS: BSD (OpenBSD)\n" ); #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 #if defined _MSC_VER @@ -690,7 +698,7 @@ static const char* GetHostInfo() sysctlbyname( "hw.physmem", &memSize, &sz, nullptr, 0 ); ptr += sprintf( ptr, "RAM: %zu MB\n", memSize / 1024 / 1024 ); #else - ptr += sprintf( ptr, "RAM: unknown\n" ); + ptr += sprintf( ptr, "RAM: %zu MB\n", (size_t)Platform::GetMemoryStats().TotalPhysicalMemory / 1024 / 1024 ); #endif return buf; diff --git a/Source/ThirdParty/tracy/common/TracyAlloc.hpp b/Source/ThirdParty/tracy/common/TracyAlloc.hpp index 4e49df84d..a352c8478 100644 --- a/Source/ThirdParty/tracy/common/TracyAlloc.hpp +++ b/Source/ThirdParty/tracy/common/TracyAlloc.hpp @@ -3,7 +3,7 @@ #include -#if defined TRACY_ENABLE && !defined __EMSCRIPTEN__ +#if defined TRACY_ENABLE && !defined __EMSCRIPTEN__ && !defined TRACY_USE_MALLOC # include "../client/tracy_rpmalloc.hpp" # define TRACY_USE_RPMALLOC #endif diff --git a/Source/ThirdParty/tracy/common/TracySocket.cpp b/Source/ThirdParty/tracy/common/TracySocket.cpp index 259678989..42e815232 100644 --- a/Source/ThirdParty/tracy/common/TracySocket.cpp +++ b/Source/ThirdParty/tracy/common/TracySocket.cpp @@ -450,6 +450,9 @@ ListenSocket::~ListenSocket() 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; memset( &hints, 0, sizeof( hints ) ); hints.ai_family = ai_family; diff --git a/Source/ThirdParty/tracy/common/TracySystem.cpp b/Source/ThirdParty/tracy/common/TracySystem.cpp index 9a477aa31..4de80185d 100644 --- a/Source/ThirdParty/tracy/common/TracySystem.cpp +++ b/Source/ThirdParty/tracy/common/TracySystem.cpp @@ -47,6 +47,10 @@ extern "C" typedef HRESULT (WINAPI *t_GetThreadDescription)( HANDLE, PWSTR* ); #ifdef TRACY_ENABLE # include # include "TracyAlloc.hpp" + +#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__linux__) +#include "Engine/Platform/Platform.h" +#endif #endif namespace tracy @@ -88,7 +92,7 @@ TRACY_API uint32_t GetThreadHandleImpl() // 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 // a 64-bit pointer cannot be reliably truncated to 32 bits. - #error "Unsupported platform!" + return Platform::GetCurrentThreadID(); #endif } diff --git a/Source/ThirdParty/tracy/tracy.Build.cs b/Source/ThirdParty/tracy/tracy.Build.cs index ca5f485b2..0edda1679 100644 --- a/Source/ThirdParty/tracy/tracy.Build.cs +++ b/Source/ThirdParty/tracy/tracy.Build.cs @@ -40,14 +40,20 @@ public class tracy : ThirdPartyModule options.PublicDefinitions.Add("TRACY_ENABLE"); options.PrivateDefinitions.Add("TRACY_NO_INVARIANT_CHECK"); options.PrivateDefinitions.Add("TRACY_NO_FRAME_IMAGE"); - if (options.Platform.Target == TargetPlatform.Windows) - { - options.PrivateDefinitions.Add("TRACY_DBGHELP_LOCK=DbgHelp"); - } if (OnDemand) { 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; + } } ///