Update tracy to v0.9
This commit is contained in:
36
Source/ThirdParty/tracy/common/TracyAlloc.hpp
vendored
36
Source/ThirdParty/tracy/common/TracyAlloc.hpp
vendored
@@ -3,16 +3,33 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef TRACY_ENABLE
|
||||
#if defined TRACY_ENABLE && !defined __EMSCRIPTEN__
|
||||
# include "../client/tracy_rpmalloc.hpp"
|
||||
# define TRACY_USE_RPMALLOC
|
||||
#endif
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
#ifdef TRACY_USE_RPMALLOC
|
||||
TRACY_API void InitRpmalloc();
|
||||
#else
|
||||
static inline void InitRpmalloc() {}
|
||||
#endif
|
||||
|
||||
static inline void* tracy_malloc( size_t size )
|
||||
{
|
||||
#ifdef TRACY_ENABLE
|
||||
#ifdef TRACY_USE_RPMALLOC
|
||||
InitRpmalloc();
|
||||
return rpmalloc( size );
|
||||
#else
|
||||
return malloc( size );
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void* tracy_malloc_fast( size_t size )
|
||||
{
|
||||
#ifdef TRACY_USE_RPMALLOC
|
||||
return rpmalloc( size );
|
||||
#else
|
||||
return malloc( size );
|
||||
@@ -21,7 +38,17 @@ static inline void* tracy_malloc( size_t size )
|
||||
|
||||
static inline void tracy_free( void* ptr )
|
||||
{
|
||||
#ifdef TRACY_ENABLE
|
||||
#ifdef TRACY_USE_RPMALLOC
|
||||
InitRpmalloc();
|
||||
rpfree( ptr );
|
||||
#else
|
||||
free( ptr );
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void tracy_free_fast( void* ptr )
|
||||
{
|
||||
#ifdef TRACY_USE_RPMALLOC
|
||||
rpfree( ptr );
|
||||
#else
|
||||
free( ptr );
|
||||
@@ -30,7 +57,8 @@ static inline void tracy_free( void* ptr )
|
||||
|
||||
static inline void* tracy_realloc( void* ptr, size_t size )
|
||||
{
|
||||
#ifdef TRACY_ENABLE
|
||||
#ifdef TRACY_USE_RPMALLOC
|
||||
InitRpmalloc();
|
||||
return rprealloc( ptr, size );
|
||||
#else
|
||||
return realloc( ptr, size );
|
||||
|
||||
65
Source/ThirdParty/tracy/common/TracyProtocol.hpp
vendored
65
Source/ThirdParty/tracy/common/TracyProtocol.hpp
vendored
@@ -9,8 +9,8 @@ namespace tracy
|
||||
|
||||
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
|
||||
|
||||
enum : uint32_t { ProtocolVersion = 46 };
|
||||
enum : uint16_t { BroadcastVersion = 2 };
|
||||
enum : uint32_t { ProtocolVersion = 63 };
|
||||
enum : uint16_t { BroadcastVersion = 3 };
|
||||
|
||||
using lz4sz_t = uint32_t;
|
||||
|
||||
@@ -34,7 +34,7 @@ enum HandshakeStatus : uint8_t
|
||||
enum { WelcomeMessageProgramNameSize = 64 };
|
||||
enum { WelcomeMessageHostInfoSize = 1024 };
|
||||
|
||||
#pragma pack( 1 )
|
||||
#pragma pack( push, 1 )
|
||||
|
||||
// Must increase left query space after handling!
|
||||
enum ServerQuery : uint8_t
|
||||
@@ -44,14 +44,15 @@ enum ServerQuery : uint8_t
|
||||
ServerQueryThreadString,
|
||||
ServerQuerySourceLocation,
|
||||
ServerQueryPlotName,
|
||||
ServerQueryCallstackFrame,
|
||||
ServerQueryFrameName,
|
||||
ServerQueryDisconnect,
|
||||
ServerQueryExternalName,
|
||||
ServerQueryParameter,
|
||||
ServerQueryFiberName,
|
||||
// Items above are high priority. Split order must be preserved. See IsQueryPrio().
|
||||
ServerQueryDisconnect,
|
||||
ServerQueryCallstackFrame,
|
||||
ServerQueryExternalName,
|
||||
ServerQuerySymbol,
|
||||
ServerQuerySymbolCode,
|
||||
ServerQueryCodeLocation,
|
||||
ServerQuerySourceCode,
|
||||
ServerQueryDataTransfer,
|
||||
ServerQueryDataTransferPart
|
||||
@@ -77,6 +78,18 @@ enum CpuArchitecture : uint8_t
|
||||
};
|
||||
|
||||
|
||||
struct WelcomeFlag
|
||||
{
|
||||
enum _t : uint8_t
|
||||
{
|
||||
OnDemand = 1 << 0,
|
||||
IsApple = 1 << 1,
|
||||
CodeTransfer = 1 << 2,
|
||||
CombineSamples = 1 << 3,
|
||||
IdentifySamples = 1 << 4,
|
||||
};
|
||||
};
|
||||
|
||||
struct WelcomeMessage
|
||||
{
|
||||
double timerMul;
|
||||
@@ -88,10 +101,8 @@ struct WelcomeMessage
|
||||
uint64_t exectime;
|
||||
uint64_t pid;
|
||||
int64_t samplingPeriod;
|
||||
uint8_t onDemand;
|
||||
uint8_t isApple;
|
||||
uint8_t flags;
|
||||
uint8_t cpuArch;
|
||||
uint8_t codeTransfer;
|
||||
char cpuManufacturer[12];
|
||||
uint32_t cpuId;
|
||||
char programName[WelcomeMessageProgramNameSize];
|
||||
@@ -115,13 +126,43 @@ struct BroadcastMessage
|
||||
uint16_t broadcastVersion;
|
||||
uint16_t listenPort;
|
||||
uint32_t protocolVersion;
|
||||
uint64_t pid;
|
||||
int32_t activeTime; // in seconds
|
||||
char programName[WelcomeMessageProgramNameSize];
|
||||
};
|
||||
|
||||
enum { BroadcastMessageSize = sizeof( BroadcastMessage ) };
|
||||
struct BroadcastMessage_v2
|
||||
{
|
||||
uint16_t broadcastVersion;
|
||||
uint16_t listenPort;
|
||||
uint32_t protocolVersion;
|
||||
int32_t activeTime;
|
||||
char programName[WelcomeMessageProgramNameSize];
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
struct BroadcastMessage_v1
|
||||
{
|
||||
uint32_t broadcastVersion;
|
||||
uint32_t protocolVersion;
|
||||
uint32_t listenPort;
|
||||
uint32_t activeTime;
|
||||
char programName[WelcomeMessageProgramNameSize];
|
||||
};
|
||||
|
||||
struct BroadcastMessage_v0
|
||||
{
|
||||
uint32_t broadcastVersion;
|
||||
uint32_t protocolVersion;
|
||||
uint32_t activeTime;
|
||||
char programName[WelcomeMessageProgramNameSize];
|
||||
};
|
||||
|
||||
enum { BroadcastMessageSize = sizeof( BroadcastMessage ) };
|
||||
enum { BroadcastMessageSize_v2 = sizeof( BroadcastMessage_v2 ) };
|
||||
enum { BroadcastMessageSize_v1 = sizeof( BroadcastMessage_v1 ) };
|
||||
enum { BroadcastMessageSize_v0 = sizeof( BroadcastMessage_v0 ) };
|
||||
|
||||
#pragma pack( pop )
|
||||
|
||||
}
|
||||
|
||||
|
||||
282
Source/ThirdParty/tracy/common/TracyQueue.hpp
vendored
282
Source/ThirdParty/tracy/common/TracyQueue.hpp
vendored
@@ -21,6 +21,7 @@ enum class QueueType : uint8_t
|
||||
Callstack,
|
||||
CallstackAlloc,
|
||||
CallstackSample,
|
||||
CallstackSampleContextSwitch,
|
||||
FrameImage,
|
||||
ZoneBegin,
|
||||
ZoneBeginCallstack,
|
||||
@@ -50,11 +51,20 @@ enum class QueueType : uint8_t
|
||||
GpuZoneBeginAllocSrcLocSerial,
|
||||
GpuZoneBeginAllocSrcLocCallstackSerial,
|
||||
GpuZoneEndSerial,
|
||||
PlotData,
|
||||
PlotDataInt,
|
||||
PlotDataFloat,
|
||||
PlotDataDouble,
|
||||
ContextSwitch,
|
||||
ThreadWakeup,
|
||||
GpuTime,
|
||||
GpuContextName,
|
||||
CallstackFrameSize,
|
||||
SymbolInformation,
|
||||
ExternalNameMetadata,
|
||||
SymbolCodeMetadata,
|
||||
SourceCodeMetadata,
|
||||
FiberEnter,
|
||||
FiberLeave,
|
||||
Terminate,
|
||||
KeepAlive,
|
||||
ThreadContext,
|
||||
@@ -67,6 +77,7 @@ enum class QueueType : uint8_t
|
||||
FrameMarkMsg,
|
||||
FrameMarkMsgStart,
|
||||
FrameMarkMsgEnd,
|
||||
FrameVsync,
|
||||
SourceLocation,
|
||||
LockAnnounce,
|
||||
LockTerminate,
|
||||
@@ -76,16 +87,20 @@ enum class QueueType : uint8_t
|
||||
MessageLiteralCallstack,
|
||||
MessageLiteralColorCallstack,
|
||||
GpuNewContext,
|
||||
CallstackFrameSize,
|
||||
CallstackFrame,
|
||||
SymbolInformation,
|
||||
CodeInformation,
|
||||
SysTimeReport,
|
||||
TidToPid,
|
||||
HwSampleCpuCycle,
|
||||
HwSampleInstructionRetired,
|
||||
HwSampleCacheReference,
|
||||
HwSampleCacheMiss,
|
||||
HwSampleBranchRetired,
|
||||
HwSampleBranchMiss,
|
||||
PlotConfig,
|
||||
ParamSetup,
|
||||
AckServerQueryNoop,
|
||||
AckSourceCodeNotAvailable,
|
||||
AckSymbolCodeNotAvailable,
|
||||
CpuTopology,
|
||||
SingleStringData,
|
||||
SecondStringData,
|
||||
@@ -102,14 +117,15 @@ enum class QueueType : uint8_t
|
||||
ExternalThreadName,
|
||||
SymbolCode,
|
||||
SourceCode,
|
||||
FiberName,
|
||||
NUM_TYPES
|
||||
};
|
||||
|
||||
#pragma pack( 1 )
|
||||
#pragma pack( push, 1 )
|
||||
|
||||
struct QueueThreadContext
|
||||
{
|
||||
uint64_t thread;
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueZoneBeginLean
|
||||
@@ -122,16 +138,31 @@ struct QueueZoneBegin : public QueueZoneBeginLean
|
||||
uint64_t srcloc; // ptr
|
||||
};
|
||||
|
||||
struct QueueZoneBeginThread : public QueueZoneBegin
|
||||
{
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueZoneEnd
|
||||
{
|
||||
int64_t time;
|
||||
};
|
||||
|
||||
struct QueueZoneEndThread : public QueueZoneEnd
|
||||
{
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueZoneValidation
|
||||
{
|
||||
uint32_t id;
|
||||
};
|
||||
|
||||
struct QueueZoneValidationThread : public QueueZoneValidation
|
||||
{
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueZoneColor
|
||||
{
|
||||
uint8_t r;
|
||||
@@ -139,11 +170,21 @@ struct QueueZoneColor
|
||||
uint8_t b;
|
||||
};
|
||||
|
||||
struct QueueZoneColorThread : public QueueZoneColor
|
||||
{
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueZoneValue
|
||||
{
|
||||
uint64_t value;
|
||||
};
|
||||
|
||||
struct QueueZoneValueThread : public QueueZoneValue
|
||||
{
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueStringTransfer
|
||||
{
|
||||
uint64_t ptr;
|
||||
@@ -155,6 +196,12 @@ struct QueueFrameMark
|
||||
uint64_t name; // ptr
|
||||
};
|
||||
|
||||
struct QueueFrameVsync
|
||||
{
|
||||
int64_t time;
|
||||
uint32_t id;
|
||||
};
|
||||
|
||||
struct QueueFrameImage
|
||||
{
|
||||
uint32_t frame;
|
||||
@@ -185,6 +232,11 @@ struct QueueZoneTextFat
|
||||
uint16_t size;
|
||||
};
|
||||
|
||||
struct QueueZoneTextFatThread : public QueueZoneTextFat
|
||||
{
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
enum class LockType : uint8_t
|
||||
{
|
||||
Lockable,
|
||||
@@ -199,6 +251,19 @@ struct QueueLockAnnounce
|
||||
LockType type;
|
||||
};
|
||||
|
||||
struct QueueFiberEnter
|
||||
{
|
||||
int64_t time;
|
||||
uint64_t fiber; // ptr
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueFiberLeave
|
||||
{
|
||||
int64_t time;
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueLockTerminate
|
||||
{
|
||||
uint32_t id;
|
||||
@@ -207,28 +272,32 @@ struct QueueLockTerminate
|
||||
|
||||
struct QueueLockWait
|
||||
{
|
||||
uint64_t thread;
|
||||
uint32_t thread;
|
||||
uint32_t id;
|
||||
int64_t time;
|
||||
};
|
||||
|
||||
struct QueueLockObtain
|
||||
{
|
||||
uint64_t thread;
|
||||
uint32_t thread;
|
||||
uint32_t id;
|
||||
int64_t time;
|
||||
};
|
||||
|
||||
struct QueueLockRelease
|
||||
{
|
||||
uint64_t thread;
|
||||
uint32_t id;
|
||||
int64_t time;
|
||||
};
|
||||
|
||||
struct QueueLockReleaseShared : public QueueLockRelease
|
||||
{
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueLockMark
|
||||
{
|
||||
uint64_t thread;
|
||||
uint32_t thread;
|
||||
uint32_t id;
|
||||
uint64_t srcloc; // ptr
|
||||
};
|
||||
@@ -244,24 +313,25 @@ struct QueueLockNameFat : public QueueLockName
|
||||
uint16_t size;
|
||||
};
|
||||
|
||||
enum class PlotDataType : uint8_t
|
||||
{
|
||||
Float,
|
||||
Double,
|
||||
Int
|
||||
};
|
||||
|
||||
struct QueuePlotData
|
||||
struct QueuePlotDataBase
|
||||
{
|
||||
uint64_t name; // ptr
|
||||
int64_t time;
|
||||
PlotDataType type;
|
||||
union
|
||||
{
|
||||
double d;
|
||||
float f;
|
||||
int64_t i;
|
||||
} data;
|
||||
};
|
||||
|
||||
struct QueuePlotDataInt : public QueuePlotDataBase
|
||||
{
|
||||
int64_t val;
|
||||
};
|
||||
|
||||
struct QueuePlotDataFloat : public QueuePlotDataBase
|
||||
{
|
||||
float val;
|
||||
};
|
||||
|
||||
struct QueuePlotDataDouble : public QueuePlotDataBase
|
||||
{
|
||||
double val;
|
||||
};
|
||||
|
||||
struct QueueMessage
|
||||
@@ -281,23 +351,43 @@ struct QueueMessageLiteral : public QueueMessage
|
||||
uint64_t text; // ptr
|
||||
};
|
||||
|
||||
struct QueueMessageLiteralThread : public QueueMessageLiteral
|
||||
{
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueMessageColorLiteral : public QueueMessageColor
|
||||
{
|
||||
uint64_t text; // ptr
|
||||
};
|
||||
|
||||
struct QueueMessageColorLiteralThread : public QueueMessageColorLiteral
|
||||
{
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueMessageFat : public QueueMessage
|
||||
{
|
||||
uint64_t text; // ptr
|
||||
uint16_t size;
|
||||
};
|
||||
|
||||
struct QueueMessageFatThread : public QueueMessageFat
|
||||
{
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueMessageColorFat : public QueueMessageColor
|
||||
{
|
||||
uint64_t text; // ptr
|
||||
uint16_t size;
|
||||
};
|
||||
|
||||
struct QueueMessageColorFatThread : public QueueMessageColorFat
|
||||
{
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
// Don't change order, only add new entries at the end, this is also used on trace dumps!
|
||||
enum class GpuContextType : uint8_t
|
||||
{
|
||||
@@ -305,7 +395,8 @@ enum class GpuContextType : uint8_t
|
||||
OpenGl,
|
||||
Vulkan,
|
||||
OpenCL,
|
||||
Direct3D12
|
||||
Direct3D12,
|
||||
Direct3D11
|
||||
};
|
||||
|
||||
enum GpuContextFlags : uint8_t
|
||||
@@ -317,7 +408,7 @@ struct QueueGpuNewContext
|
||||
{
|
||||
int64_t cpuTime;
|
||||
int64_t gpuTime;
|
||||
uint64_t thread;
|
||||
uint32_t thread;
|
||||
float period;
|
||||
uint8_t context;
|
||||
GpuContextFlags flags;
|
||||
@@ -327,7 +418,7 @@ struct QueueGpuNewContext
|
||||
struct QueueGpuZoneBeginLean
|
||||
{
|
||||
int64_t cpuTime;
|
||||
uint64_t thread;
|
||||
uint32_t thread;
|
||||
uint16_t queryId;
|
||||
uint8_t context;
|
||||
};
|
||||
@@ -340,7 +431,7 @@ struct QueueGpuZoneBegin : public QueueGpuZoneBeginLean
|
||||
struct QueueGpuZoneEnd
|
||||
{
|
||||
int64_t cpuTime;
|
||||
uint64_t thread;
|
||||
uint32_t thread;
|
||||
uint16_t queryId;
|
||||
uint8_t context;
|
||||
};
|
||||
@@ -379,7 +470,7 @@ struct QueueMemNamePayload
|
||||
struct QueueMemAlloc
|
||||
{
|
||||
int64_t time;
|
||||
uint64_t thread;
|
||||
uint32_t thread;
|
||||
uint64_t ptr;
|
||||
char size[6];
|
||||
};
|
||||
@@ -387,7 +478,7 @@ struct QueueMemAlloc
|
||||
struct QueueMemFree
|
||||
{
|
||||
int64_t time;
|
||||
uint64_t thread;
|
||||
uint32_t thread;
|
||||
uint64_t ptr;
|
||||
};
|
||||
|
||||
@@ -396,16 +487,26 @@ struct QueueCallstackFat
|
||||
uint64_t ptr;
|
||||
};
|
||||
|
||||
struct QueueCallstackFatThread : public QueueCallstackFat
|
||||
{
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueCallstackAllocFat
|
||||
{
|
||||
uint64_t ptr;
|
||||
uint64_t nativePtr;
|
||||
};
|
||||
|
||||
struct QueueCallstackAllocFatThread : public QueueCallstackAllocFat
|
||||
{
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueCallstackSample
|
||||
{
|
||||
int64_t time;
|
||||
uint64_t thread;
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueCallstackSampleFat : public QueueCallstackSample
|
||||
@@ -419,6 +520,12 @@ struct QueueCallstackFrameSize
|
||||
uint8_t size;
|
||||
};
|
||||
|
||||
struct QueueCallstackFrameSizeFat : public QueueCallstackFrameSize
|
||||
{
|
||||
uint64_t data;
|
||||
uint64_t imageName;
|
||||
};
|
||||
|
||||
struct QueueCallstackFrame
|
||||
{
|
||||
uint32_t line;
|
||||
@@ -432,10 +539,10 @@ struct QueueSymbolInformation
|
||||
uint64_t symAddr;
|
||||
};
|
||||
|
||||
struct QueueCodeInformation
|
||||
struct QueueSymbolInformationFat : public QueueSymbolInformation
|
||||
{
|
||||
uint64_t ptr;
|
||||
uint32_t line;
|
||||
uint64_t fileString;
|
||||
uint8_t needFree;
|
||||
};
|
||||
|
||||
struct QueueCrashReport
|
||||
@@ -444,6 +551,11 @@ struct QueueCrashReport
|
||||
uint64_t text; // ptr
|
||||
};
|
||||
|
||||
struct QueueCrashReportThread
|
||||
{
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueSysTime
|
||||
{
|
||||
int64_t time;
|
||||
@@ -453,8 +565,8 @@ struct QueueSysTime
|
||||
struct QueueContextSwitch
|
||||
{
|
||||
int64_t time;
|
||||
uint64_t oldThread;
|
||||
uint64_t newThread;
|
||||
uint32_t oldThread;
|
||||
uint32_t newThread;
|
||||
uint8_t cpu;
|
||||
uint8_t reason;
|
||||
uint8_t state;
|
||||
@@ -463,7 +575,7 @@ struct QueueContextSwitch
|
||||
struct QueueThreadWakeup
|
||||
{
|
||||
int64_t time;
|
||||
uint64_t thread;
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueTidToPid
|
||||
@@ -472,10 +584,19 @@ struct QueueTidToPid
|
||||
uint64_t pid;
|
||||
};
|
||||
|
||||
struct QueueHwSample
|
||||
{
|
||||
uint64_t ip;
|
||||
int64_t time;
|
||||
};
|
||||
|
||||
struct QueuePlotConfig
|
||||
{
|
||||
uint64_t name; // ptr
|
||||
uint8_t type;
|
||||
uint8_t step;
|
||||
uint8_t fill;
|
||||
uint32_t color;
|
||||
};
|
||||
|
||||
struct QueueParamSetup
|
||||
@@ -486,6 +607,11 @@ struct QueueParamSetup
|
||||
int32_t val;
|
||||
};
|
||||
|
||||
struct QueueSourceCodeNotAvailable
|
||||
{
|
||||
uint32_t id;
|
||||
};
|
||||
|
||||
struct QueueCpuTopology
|
||||
{
|
||||
uint32_t package;
|
||||
@@ -493,6 +619,27 @@ struct QueueCpuTopology
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueExternalNameMetadata
|
||||
{
|
||||
uint64_t thread;
|
||||
uint64_t name;
|
||||
uint64_t threadName;
|
||||
};
|
||||
|
||||
struct QueueSymbolCodeMetadata
|
||||
{
|
||||
uint64_t symbol;
|
||||
uint64_t ptr;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
struct QueueSourceCodeMetadata
|
||||
{
|
||||
uint64_t ptr;
|
||||
uint32_t size;
|
||||
uint32_t id;
|
||||
};
|
||||
|
||||
struct QueueHeader
|
||||
{
|
||||
union
|
||||
@@ -510,31 +657,45 @@ struct QueueItem
|
||||
QueueThreadContext threadCtx;
|
||||
QueueZoneBegin zoneBegin;
|
||||
QueueZoneBeginLean zoneBeginLean;
|
||||
QueueZoneBeginThread zoneBeginThread;
|
||||
QueueZoneEnd zoneEnd;
|
||||
QueueZoneEndThread zoneEndThread;
|
||||
QueueZoneValidation zoneValidation;
|
||||
QueueZoneValidationThread zoneValidationThread;
|
||||
QueueZoneColor zoneColor;
|
||||
QueueZoneColorThread zoneColorThread;
|
||||
QueueZoneValue zoneValue;
|
||||
QueueZoneValueThread zoneValueThread;
|
||||
QueueStringTransfer stringTransfer;
|
||||
QueueFrameMark frameMark;
|
||||
QueueFrameVsync frameVsync;
|
||||
QueueFrameImage frameImage;
|
||||
QueueFrameImageFat frameImageFat;
|
||||
QueueSourceLocation srcloc;
|
||||
QueueZoneTextFat zoneTextFat;
|
||||
QueueZoneTextFatThread zoneTextFatThread;
|
||||
QueueLockAnnounce lockAnnounce;
|
||||
QueueLockTerminate lockTerminate;
|
||||
QueueLockWait lockWait;
|
||||
QueueLockObtain lockObtain;
|
||||
QueueLockRelease lockRelease;
|
||||
QueueLockReleaseShared lockReleaseShared;
|
||||
QueueLockMark lockMark;
|
||||
QueueLockName lockName;
|
||||
QueueLockNameFat lockNameFat;
|
||||
QueuePlotData plotData;
|
||||
QueuePlotDataInt plotDataInt;
|
||||
QueuePlotDataFloat plotDataFloat;
|
||||
QueuePlotDataDouble plotDataDouble;
|
||||
QueueMessage message;
|
||||
QueueMessageColor messageColor;
|
||||
QueueMessageLiteral messageLiteral;
|
||||
QueueMessageLiteralThread messageLiteralThread;
|
||||
QueueMessageColorLiteral messageColorLiteral;
|
||||
QueueMessageColorLiteralThread messageColorLiteralThread;
|
||||
QueueMessageFat messageFat;
|
||||
QueueMessageFatThread messageFatThread;
|
||||
QueueMessageColorFat messageColorFat;
|
||||
QueueMessageColorFatThread messageColorFatThread;
|
||||
QueueGpuNewContext gpuNewContext;
|
||||
QueueGpuZoneBegin gpuZoneBegin;
|
||||
QueueGpuZoneBeginLean gpuZoneBeginLean;
|
||||
@@ -547,24 +708,35 @@ struct QueueItem
|
||||
QueueMemFree memFree;
|
||||
QueueMemNamePayload memName;
|
||||
QueueCallstackFat callstackFat;
|
||||
QueueCallstackFatThread callstackFatThread;
|
||||
QueueCallstackAllocFat callstackAllocFat;
|
||||
QueueCallstackAllocFatThread callstackAllocFatThread;
|
||||
QueueCallstackSample callstackSample;
|
||||
QueueCallstackSampleFat callstackSampleFat;
|
||||
QueueCallstackFrameSize callstackFrameSize;
|
||||
QueueCallstackFrameSizeFat callstackFrameSizeFat;
|
||||
QueueCallstackFrame callstackFrame;
|
||||
QueueSymbolInformation symbolInformation;
|
||||
QueueCodeInformation codeInformation;
|
||||
QueueSymbolInformationFat symbolInformationFat;
|
||||
QueueCrashReport crashReport;
|
||||
QueueCrashReportThread crashReportThread;
|
||||
QueueSysTime sysTime;
|
||||
QueueContextSwitch contextSwitch;
|
||||
QueueThreadWakeup threadWakeup;
|
||||
QueueTidToPid tidToPid;
|
||||
QueueHwSample hwSample;
|
||||
QueuePlotConfig plotConfig;
|
||||
QueueParamSetup paramSetup;
|
||||
QueueCpuTopology cpuTopology;
|
||||
QueueExternalNameMetadata externalNameMetadata;
|
||||
QueueSymbolCodeMetadata symbolCodeMetadata;
|
||||
QueueSourceCodeMetadata sourceCodeMetadata;
|
||||
QueueSourceCodeNotAvailable sourceCodeNotAvailable;
|
||||
QueueFiberEnter fiberEnter;
|
||||
QueueFiberLeave fiberLeave;
|
||||
};
|
||||
};
|
||||
#pragma pack()
|
||||
#pragma pack( pop )
|
||||
|
||||
|
||||
enum { QueueItemSize = sizeof( QueueItem ) };
|
||||
@@ -583,6 +755,7 @@ static constexpr size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ), // callstack
|
||||
sizeof( QueueHeader ), // callstack alloc
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackSample ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackSample ), // context switch
|
||||
sizeof( QueueHeader ) + sizeof( QueueFrameImage ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // callstack
|
||||
@@ -592,7 +765,7 @@ static constexpr size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueLockRelease ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueLockWait ), // shared
|
||||
sizeof( QueueHeader ) + sizeof( QueueLockObtain ), // shared
|
||||
sizeof( QueueHeader ) + sizeof( QueueLockRelease ), // shared
|
||||
sizeof( QueueHeader ) + sizeof( QueueLockReleaseShared ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueLockName ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueMemAlloc ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueMemAlloc ), // named
|
||||
@@ -612,11 +785,20 @@ static constexpr size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuZoneBeginLean ),// serial, allocated source location
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuZoneBeginLean ),// serial, allocated source location, callstack
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuZoneEnd ), // serial
|
||||
sizeof( QueueHeader ) + sizeof( QueuePlotData ),
|
||||
sizeof( QueueHeader ) + sizeof( QueuePlotDataInt ),
|
||||
sizeof( QueueHeader ) + sizeof( QueuePlotDataFloat ),
|
||||
sizeof( QueueHeader ) + sizeof( QueuePlotDataDouble ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueContextSwitch ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueThreadWakeup ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuTime ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuContextName ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackFrameSize ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueSymbolInformation ),
|
||||
sizeof( QueueHeader ), // ExternalNameMetadata - not for wire transfer
|
||||
sizeof( QueueHeader ), // SymbolCodeMetadata - not for wire transfer
|
||||
sizeof( QueueHeader ), // SourceCodeMetadata - not for wire transfer
|
||||
sizeof( QueueHeader ) + sizeof( QueueFiberEnter ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueFiberLeave ),
|
||||
// above items must be first
|
||||
sizeof( QueueHeader ), // terminate
|
||||
sizeof( QueueHeader ), // keep alive
|
||||
@@ -630,6 +812,7 @@ static constexpr size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // continuous frames
|
||||
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // start
|
||||
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // end
|
||||
sizeof( QueueHeader ) + sizeof( QueueFrameVsync ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueSourceLocation ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueLockAnnounce ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueLockTerminate ),
|
||||
@@ -639,16 +822,20 @@ static constexpr size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueMessageLiteral ), // callstack
|
||||
sizeof( QueueHeader ) + sizeof( QueueMessageColorLiteral ), // callstack
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuNewContext ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackFrameSize ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackFrame ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueSymbolInformation ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueCodeInformation ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueSysTime ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueTidToPid ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueHwSample ), // cpu cycle
|
||||
sizeof( QueueHeader ) + sizeof( QueueHwSample ), // instruction retired
|
||||
sizeof( QueueHeader ) + sizeof( QueueHwSample ), // cache reference
|
||||
sizeof( QueueHeader ) + sizeof( QueueHwSample ), // cache miss
|
||||
sizeof( QueueHeader ) + sizeof( QueueHwSample ), // branch retired
|
||||
sizeof( QueueHeader ) + sizeof( QueueHwSample ), // branch miss
|
||||
sizeof( QueueHeader ) + sizeof( QueuePlotConfig ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueParamSetup ),
|
||||
sizeof( QueueHeader ), // server query acknowledgement
|
||||
sizeof( QueueHeader ), // source code not available
|
||||
sizeof( QueueHeader ) + sizeof( QueueSourceCodeNotAvailable ),
|
||||
sizeof( QueueHeader ), // symbol code not available
|
||||
sizeof( QueueHeader ) + sizeof( QueueCpuTopology ),
|
||||
sizeof( QueueHeader ), // single string data
|
||||
sizeof( QueueHeader ), // second string data
|
||||
@@ -666,6 +853,7 @@ static constexpr size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // external thread name
|
||||
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // symbol code
|
||||
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // source code
|
||||
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // fiber name
|
||||
};
|
||||
|
||||
static_assert( QueueItemSize == 32, "Queue item size not 32 bytes" );
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "TracyAlloc.hpp"
|
||||
#include "TracySocket.hpp"
|
||||
#include "TracySystem.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef NOMINMAX
|
||||
@@ -454,7 +455,7 @@ static int addrinfo_and_socket_for_family( uint16_t port, int ai_family, struct
|
||||
hints.ai_family = ai_family;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
#ifndef TRACY_ONLY_LOCALHOST
|
||||
const char* onlyLocalhost = getenv( "TRACY_ONLY_LOCALHOST" );
|
||||
const char* onlyLocalhost = GetEnvVar( "TRACY_ONLY_LOCALHOST" );
|
||||
if( !onlyLocalhost || onlyLocalhost[0] != '1' )
|
||||
{
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
@@ -475,7 +476,7 @@ bool ListenSocket::Listen( uint16_t port, int backlog )
|
||||
struct addrinfo* res = nullptr;
|
||||
|
||||
#if !defined TRACY_ONLY_IPV4 && !defined TRACY_ONLY_LOCALHOST
|
||||
const char* onlyIPv4 = getenv( "TRACY_ONLY_IPV4" );
|
||||
const char* onlyIPv4 = GetEnvVar( "TRACY_ONLY_IPV4" );
|
||||
if( !onlyIPv4 || onlyIPv4[0] != '1' )
|
||||
{
|
||||
m_sock = addrinfo_and_socket_for_family( port, AF_INET6, &res );
|
||||
@@ -488,7 +489,7 @@ bool ListenSocket::Listen( uint16_t port, int backlog )
|
||||
m_sock = addrinfo_and_socket_for_family( port, AF_INET, &res );
|
||||
if( m_sock == -1 ) return false;
|
||||
}
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
#if defined _WIN32
|
||||
unsigned long val = 0;
|
||||
setsockopt( m_sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&val, sizeof( val ) );
|
||||
#elif defined BSD
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define __TRACYSOCKET_HPP__
|
||||
|
||||
#include <atomic>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct addrinfo;
|
||||
|
||||
122
Source/ThirdParty/tracy/common/TracyStackFrames.cpp
vendored
Normal file
122
Source/ThirdParty/tracy/common/TracyStackFrames.cpp
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
#include "TracyStackFrames.hpp"
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
const char* s_tracyStackFrames_[] = {
|
||||
"tracy::Callstack",
|
||||
"tracy::Callstack(int)",
|
||||
"tracy::GpuCtxScope::{ctor}",
|
||||
"tracy::Profiler::SendCallstack",
|
||||
"tracy::Profiler::SendCallstack(int)",
|
||||
"tracy::Profiler::SendCallstack(int, unsigned long)",
|
||||
"tracy::Profiler::MemAllocCallstack",
|
||||
"tracy::Profiler::MemAllocCallstack(void const*, unsigned long, int)",
|
||||
"tracy::Profiler::MemFreeCallstack",
|
||||
"tracy::Profiler::MemFreeCallstack(void const*, int)",
|
||||
"tracy::ScopedZone::{ctor}",
|
||||
"tracy::ScopedZone::ScopedZone(tracy::SourceLocationData const*, int, bool)",
|
||||
"tracy::Profiler::Message",
|
||||
nullptr
|
||||
};
|
||||
|
||||
const char** s_tracyStackFrames = s_tracyStackFrames_;
|
||||
|
||||
const StringMatch s_tracySkipSubframes_[] = {
|
||||
{ "/include/arm_neon.h", 19 },
|
||||
{ "/include/adxintrin.h", 20 },
|
||||
{ "/include/ammintrin.h", 20 },
|
||||
{ "/include/amxbf16intrin.h", 24 },
|
||||
{ "/include/amxint8intrin.h", 24 },
|
||||
{ "/include/amxtileintrin.h", 24 },
|
||||
{ "/include/avx2intrin.h", 21 },
|
||||
{ "/include/avx5124fmapsintrin.h", 29 },
|
||||
{ "/include/avx5124vnniwintrin.h", 29 },
|
||||
{ "/include/avx512bf16intrin.h", 27 },
|
||||
{ "/include/avx512bf16vlintrin.h", 29 },
|
||||
{ "/include/avx512bitalgintrin.h", 29 },
|
||||
{ "/include/avx512bwintrin.h", 25 },
|
||||
{ "/include/avx512cdintrin.h", 25 },
|
||||
{ "/include/avx512dqintrin.h", 25 },
|
||||
{ "/include/avx512erintrin.h", 25 },
|
||||
{ "/include/avx512fintrin.h", 24 },
|
||||
{ "/include/avx512ifmaintrin.h", 27 },
|
||||
{ "/include/avx512ifmavlintrin.h", 29 },
|
||||
{ "/include/avx512pfintrin.h", 25 },
|
||||
{ "/include/avx512vbmi2intrin.h", 28 },
|
||||
{ "/include/avx512vbmi2vlintrin.h", 30 },
|
||||
{ "/include/avx512vbmiintrin.h", 27 },
|
||||
{ "/include/avx512vbmivlintrin.h", 29 },
|
||||
{ "/include/avx512vlbwintrin.h", 27 },
|
||||
{ "/include/avx512vldqintrin.h", 27 },
|
||||
{ "/include/avx512vlintrin.h", 25 },
|
||||
{ "/include/avx512vnniintrin.h", 27 },
|
||||
{ "/include/avx512vnnivlintrin.h", 29 },
|
||||
{ "/include/avx512vp2intersectintrin.h", 35 },
|
||||
{ "/include/avx512vp2intersectvlintrin.h", 37 },
|
||||
{ "/include/avx512vpopcntdqintrin.h", 32 },
|
||||
{ "/include/avx512vpopcntdqvlintrin.h", 34 },
|
||||
{ "/include/avxintrin.h", 20 },
|
||||
{ "/include/avxvnniintrin.h", 24 },
|
||||
{ "/include/bmi2intrin.h", 21 },
|
||||
{ "/include/bmiintrin.h", 20 },
|
||||
{ "/include/bmmintrin.h", 20 },
|
||||
{ "/include/cetintrin.h", 20 },
|
||||
{ "/include/cldemoteintrin.h", 25 },
|
||||
{ "/include/clflushoptintrin.h", 27 },
|
||||
{ "/include/clwbintrin.h", 21 },
|
||||
{ "/include/clzerointrin.h", 23 },
|
||||
{ "/include/emmintrin.h", 20 },
|
||||
{ "/include/enqcmdintrin.h", 23 },
|
||||
{ "/include/f16cintrin.h", 21 },
|
||||
{ "/include/fma4intrin.h", 21 },
|
||||
{ "/include/fmaintrin.h", 20 },
|
||||
{ "/include/fxsrintrin.h", 21 },
|
||||
{ "/include/gfniintrin.h", 21 },
|
||||
{ "/include/hresetintrin.h", 23 },
|
||||
{ "/include/ia32intrin.h", 21 },
|
||||
{ "/include/immintrin.h", 20 },
|
||||
{ "/include/keylockerintrin.h", 26 },
|
||||
{ "/include/lwpintrin.h", 20 },
|
||||
{ "/include/lzcntintrin.h", 22 },
|
||||
{ "/include/mmintrin.h", 19 },
|
||||
{ "/include/movdirintrin.h", 23 },
|
||||
{ "/include/mwaitxintrin.h", 23 },
|
||||
{ "/include/nmmintrin.h", 20 },
|
||||
{ "/include/pconfigintrin.h", 24 },
|
||||
{ "/include/pkuintrin.h", 20 },
|
||||
{ "/include/pmmintrin.h", 20 },
|
||||
{ "/include/popcntintrin.h", 23 },
|
||||
{ "/include/prfchwintrin.h", 23 },
|
||||
{ "/include/rdseedintrin.h", 23 },
|
||||
{ "/include/rtmintrin.h", 20 },
|
||||
{ "/include/serializeintrin.h", 26 },
|
||||
{ "/include/sgxintrin.h", 20 },
|
||||
{ "/include/shaintrin.h", 20 },
|
||||
{ "/include/smmintrin.h", 20 },
|
||||
{ "/include/tbmintrin.h", 20 },
|
||||
{ "/include/tmmintrin.h", 20 },
|
||||
{ "/include/tsxldtrkintrin.h", 25 },
|
||||
{ "/include/uintrintrin.h", 22 },
|
||||
{ "/include/vaesintrin.h", 21 },
|
||||
{ "/include/vpclmulqdqintrin.h", 27 },
|
||||
{ "/include/waitpkgintrin.h", 24 },
|
||||
{ "/include/wbnoinvdintrin.h", 25 },
|
||||
{ "/include/wmmintrin.h", 20 },
|
||||
{ "/include/x86gprintrin.h", 23 },
|
||||
{ "/include/x86intrin.h", 20 },
|
||||
{ "/include/xmmintrin.h", 20 },
|
||||
{ "/include/xopintrin.h", 20 },
|
||||
{ "/include/xsavecintrin.h", 23 },
|
||||
{ "/include/xsaveintrin.h", 22 },
|
||||
{ "/include/xsaveoptintrin.h", 25 },
|
||||
{ "/include/xsavesintrin.h", 23 },
|
||||
{ "/include/xtestintrin.h", 22 },
|
||||
{ "/bits/atomic_base.h", 19 },
|
||||
{ "/atomic", 7 },
|
||||
{}
|
||||
};
|
||||
|
||||
const StringMatch* s_tracySkipSubframes = s_tracySkipSubframes_;
|
||||
|
||||
}
|
||||
22
Source/ThirdParty/tracy/common/TracyStackFrames.hpp
vendored
Normal file
22
Source/ThirdParty/tracy/common/TracyStackFrames.hpp
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef __TRACYSTACKFRAMES_HPP__
|
||||
#define __TRACYSTACKFRAMES_HPP__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
struct StringMatch
|
||||
{
|
||||
const char* str;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
extern const char** s_tracyStackFrames;
|
||||
extern const StringMatch* s_tracySkipSubframes;
|
||||
|
||||
static constexpr int s_tracySkipSubframesMinLen = 7;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
158
Source/ThirdParty/tracy/common/TracySystem.cpp
vendored
158
Source/ThirdParty/tracy/common/TracySystem.cpp
vendored
@@ -1,16 +1,16 @@
|
||||
#if defined _MSC_VER || defined __CYGWIN__ || defined _WIN32
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# ifndef NOMINMAX
|
||||
# define NOMINMAX
|
||||
# endif
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable:4996)
|
||||
#endif
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
#if defined _WIN32
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# ifndef NOMINMAX
|
||||
# define NOMINMAX
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# include <malloc.h>
|
||||
# include "TracyUwp.hpp"
|
||||
#else
|
||||
# include <pthread.h>
|
||||
# include <string.h>
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
#include "TracySystem.hpp"
|
||||
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
#if defined _WIN32
|
||||
extern "C" typedef HRESULT (WINAPI *t_SetThreadDescription)( HANDLE, PCWSTR );
|
||||
extern "C" typedef HRESULT (WINAPI *t_GetThreadDescription)( HANDLE, PWSTR* );
|
||||
#endif
|
||||
@@ -55,19 +55,19 @@ namespace tracy
|
||||
namespace detail
|
||||
{
|
||||
|
||||
TRACY_API uint64_t GetThreadHandleImpl()
|
||||
TRACY_API uint32_t GetThreadHandleImpl()
|
||||
{
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
static_assert( sizeof( decltype( GetCurrentThreadId() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" );
|
||||
return uint64_t( GetCurrentThreadId() );
|
||||
#if defined _WIN32
|
||||
static_assert( sizeof( decltype( GetCurrentThreadId() ) ) <= sizeof( uint32_t ), "Thread handle too big to fit in protocol" );
|
||||
return uint32_t( GetCurrentThreadId() );
|
||||
#elif defined __APPLE__
|
||||
uint64_t id;
|
||||
pthread_threadid_np( pthread_self(), &id );
|
||||
return id;
|
||||
return uint32_t( id );
|
||||
#elif defined __ANDROID__
|
||||
return (uint64_t)gettid();
|
||||
return (uint32_t)gettid();
|
||||
#elif defined __linux__
|
||||
return (uint64_t)syscall( SYS_gettid );
|
||||
return (uint32_t)syscall( SYS_gettid );
|
||||
#elif defined __FreeBSD__
|
||||
long id;
|
||||
thr_self( &id );
|
||||
@@ -78,9 +78,17 @@ TRACY_API uint64_t GetThreadHandleImpl()
|
||||
return lwp_gettid();
|
||||
#elif defined __OpenBSD__
|
||||
return getthrid();
|
||||
#elif defined __EMSCRIPTEN__
|
||||
// Not supported, but let it compile.
|
||||
return 0;
|
||||
#else
|
||||
static_assert( sizeof( decltype( pthread_self() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" );
|
||||
return uint64_t( pthread_self() );
|
||||
// To add support for a platform, retrieve and return the kernel thread identifier here.
|
||||
//
|
||||
// Note that pthread_t (as for example returned by pthread_self()) is *not* a kernel
|
||||
// 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!"
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -90,18 +98,44 @@ TRACY_API uint64_t GetThreadHandleImpl()
|
||||
#ifdef TRACY_ENABLE
|
||||
struct ThreadNameData
|
||||
{
|
||||
uint64_t id;
|
||||
uint32_t id;
|
||||
const char* name;
|
||||
ThreadNameData* next;
|
||||
};
|
||||
std::atomic<ThreadNameData*>& GetThreadNameData();
|
||||
TRACY_API void InitRPMallocThread();
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma pack( push, 8 )
|
||||
struct THREADNAME_INFO
|
||||
{
|
||||
DWORD dwType;
|
||||
LPCSTR szName;
|
||||
DWORD dwThreadID;
|
||||
DWORD dwFlags;
|
||||
};
|
||||
# pragma pack( pop )
|
||||
|
||||
void ThreadNameMsvcMagic( const THREADNAME_INFO& info )
|
||||
{
|
||||
__try
|
||||
{
|
||||
RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
TRACY_API void SetThreadName( const char* name )
|
||||
{
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
#if defined _WIN32
|
||||
# ifdef TRACY_UWP
|
||||
static auto _SetThreadDescription = &::SetThreadDescription;
|
||||
# else
|
||||
static auto _SetThreadDescription = (t_SetThreadDescription)GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "SetThreadDescription" );
|
||||
# endif
|
||||
if( _SetThreadDescription )
|
||||
{
|
||||
wchar_t buf[256];
|
||||
@@ -111,57 +145,45 @@ TRACY_API void SetThreadName( const char* name )
|
||||
else
|
||||
{
|
||||
# if defined _MSC_VER
|
||||
const DWORD MS_VC_EXCEPTION=0x406D1388;
|
||||
# pragma pack( push, 8 )
|
||||
struct THREADNAME_INFO
|
||||
{
|
||||
DWORD dwType;
|
||||
LPCSTR szName;
|
||||
DWORD dwThreadID;
|
||||
DWORD dwFlags;
|
||||
};
|
||||
# pragma pack(pop)
|
||||
|
||||
DWORD ThreadId = GetCurrentThreadId();
|
||||
THREADNAME_INFO info;
|
||||
info.dwType = 0x1000;
|
||||
info.szName = name;
|
||||
info.dwThreadID = ThreadId;
|
||||
info.dwThreadID = GetCurrentThreadId();
|
||||
info.dwFlags = 0;
|
||||
|
||||
__try
|
||||
{
|
||||
RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
}
|
||||
ThreadNameMsvcMagic( info );
|
||||
# endif
|
||||
}
|
||||
#elif defined _GNU_SOURCE && !defined __EMSCRIPTEN__ && !defined __CYGWIN__
|
||||
#elif defined _GNU_SOURCE && !defined __EMSCRIPTEN__
|
||||
{
|
||||
const auto sz = strlen( name );
|
||||
if( sz <= 15 )
|
||||
{
|
||||
#if defined __APPLE__
|
||||
pthread_setname_np( name );
|
||||
#else
|
||||
pthread_setname_np( pthread_self(), name );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf[16];
|
||||
memcpy( buf, name, 15 );
|
||||
buf[15] = '\0';
|
||||
#if defined __APPLE__
|
||||
pthread_setname_np( buf );
|
||||
#else
|
||||
pthread_setname_np( pthread_self(), buf );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef TRACY_ENABLE
|
||||
{
|
||||
InitRPMallocThread();
|
||||
const auto sz = strlen( name );
|
||||
char* buf = (char*)tracy_malloc( sz+1 );
|
||||
memcpy( buf, name, sz );
|
||||
buf[sz] = '\0';
|
||||
auto data = (ThreadNameData*)tracy_malloc( sizeof( ThreadNameData ) );
|
||||
auto data = (ThreadNameData*)tracy_malloc_fast( sizeof( ThreadNameData ) );
|
||||
data->id = detail::GetThreadHandleImpl();
|
||||
data->name = buf;
|
||||
data->next = GetThreadNameData().load( std::memory_order_relaxed );
|
||||
@@ -170,7 +192,7 @@ TRACY_API void SetThreadName( const char* name )
|
||||
#endif
|
||||
}
|
||||
|
||||
TRACY_API const char* GetThreadName( uint64_t id )
|
||||
TRACY_API const char* GetThreadName( uint32_t id )
|
||||
{
|
||||
static char buf[256];
|
||||
#ifdef TRACY_ENABLE
|
||||
@@ -184,8 +206,12 @@ TRACY_API const char* GetThreadName( uint64_t id )
|
||||
ptr = ptr->next;
|
||||
}
|
||||
#else
|
||||
# if defined _WIN32 || defined __CYGWIN__
|
||||
# if defined _WIN32
|
||||
# ifdef TRACY_UWP
|
||||
static auto _GetThreadDescription = &::GetThreadDescription;
|
||||
# else
|
||||
static auto _GetThreadDescription = (t_GetThreadDescription)GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "GetThreadDescription" );
|
||||
# endif
|
||||
if( _GetThreadDescription )
|
||||
{
|
||||
auto hnd = OpenThread( THREAD_QUERY_LIMITED_INFORMATION, FALSE, (DWORD)id );
|
||||
@@ -210,7 +236,7 @@ TRACY_API const char* GetThreadName( uint64_t id )
|
||||
int tid = (int) syscall( SYS_gettid );
|
||||
# endif
|
||||
snprintf( path, sizeof( path ), "/proc/self/task/%d/comm", tid );
|
||||
sprintf( buf, "%" PRIu64, id );
|
||||
sprintf( buf, "%" PRIu32, id );
|
||||
# ifndef __ANDROID__
|
||||
pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, &cs );
|
||||
# endif
|
||||
@@ -232,8 +258,40 @@ TRACY_API const char* GetThreadName( uint64_t id )
|
||||
return buf;
|
||||
# endif
|
||||
#endif
|
||||
sprintf( buf, "%" PRIu64, id );
|
||||
sprintf( buf, "%" PRIu32, id );
|
||||
return buf;
|
||||
}
|
||||
|
||||
TRACY_API const char* GetEnvVar( const char* name )
|
||||
{
|
||||
#if defined _WIN32
|
||||
// unfortunately getenv() on Windows is just fundamentally broken. It caches the entire
|
||||
// environment block once on startup, then never refreshes it again. If any environment
|
||||
// strings are added or modified after startup of the CRT, those changes will not be
|
||||
// seen by getenv(). This removes the possibility of an app using this SDK from
|
||||
// programmatically setting any of the behaviour controlling envvars here.
|
||||
//
|
||||
// To work around this, we'll instead go directly to the Win32 environment strings APIs
|
||||
// to get the current value.
|
||||
static char buffer[1024];
|
||||
DWORD const kBufferSize = DWORD(sizeof(buffer) / sizeof(buffer[0]));
|
||||
DWORD count = GetEnvironmentVariableA(name, buffer, kBufferSize);
|
||||
|
||||
if( count == 0 )
|
||||
return nullptr;
|
||||
|
||||
if( count >= kBufferSize )
|
||||
{
|
||||
char* buf = reinterpret_cast<char*>(_alloca(count + 1));
|
||||
count = GetEnvironmentVariableA(name, buf, count + 1);
|
||||
memcpy(buffer, buf, kBufferSize);
|
||||
buffer[kBufferSize - 1] = 0;
|
||||
}
|
||||
|
||||
return buffer;
|
||||
#else
|
||||
return getenv(name);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
12
Source/ThirdParty/tracy/common/TracySystem.hpp
vendored
12
Source/ThirdParty/tracy/common/TracySystem.hpp
vendored
@@ -32,7 +32,7 @@ enum class PlotFormatType : uint8_t
|
||||
Percentage
|
||||
};
|
||||
|
||||
typedef void(*ParameterCallback)( uint32_t idx, int32_t val );
|
||||
typedef void(*ParameterCallback)( void* data, uint32_t idx, int32_t val );
|
||||
|
||||
struct TRACY_API SourceLocationData
|
||||
{
|
||||
@@ -80,20 +80,22 @@ private:
|
||||
|
||||
namespace detail
|
||||
{
|
||||
TRACY_API uint64_t GetThreadHandleImpl();
|
||||
TRACY_API uint32_t GetThreadHandleImpl();
|
||||
}
|
||||
|
||||
#ifdef TRACY_ENABLE
|
||||
TRACY_API uint64_t GetThreadHandle();
|
||||
TRACY_API uint32_t GetThreadHandle();
|
||||
#else
|
||||
static inline uint64_t GetThreadHandle()
|
||||
static inline uint32_t GetThreadHandle()
|
||||
{
|
||||
return detail::GetThreadHandleImpl();
|
||||
}
|
||||
#endif
|
||||
|
||||
TRACY_API void SetThreadName( const char* name );
|
||||
TRACY_API const char* GetThreadName( uint64_t id );
|
||||
TRACY_API const char* GetThreadName( uint32_t id );
|
||||
|
||||
TRACY_API const char* GetEnvVar(const char* name);
|
||||
|
||||
}
|
||||
|
||||
|
||||
11
Source/ThirdParty/tracy/common/TracyUwp.hpp
vendored
Normal file
11
Source/ThirdParty/tracy/common/TracyUwp.hpp
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef __TRACYUWP_HPP__
|
||||
#define __TRACYUWP_HPP__
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <winapifamily.h>
|
||||
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
# define TRACY_UWP
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
14
Source/ThirdParty/tracy/common/TracyVersion.hpp
vendored
Normal file
14
Source/ThirdParty/tracy/common/TracyVersion.hpp
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef __TRACYVERSION_HPP__
|
||||
#define __TRACYVERSION_HPP__
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
namespace Version
|
||||
{
|
||||
enum { Major = 0 };
|
||||
enum { Minor = 9 };
|
||||
enum { Patch = 0 };
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
26
Source/ThirdParty/tracy/common/TracyYield.hpp
vendored
Normal file
26
Source/ThirdParty/tracy/common/TracyYield.hpp
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef __TRACYYIELD_HPP__
|
||||
#define __TRACYYIELD_HPP__
|
||||
|
||||
#if defined __SSE2__ || defined _M_AMD64 || (defined _M_IX86_FP && _M_IX86_FP == 2)
|
||||
# include <emmintrin.h>
|
||||
#else
|
||||
# include <thread>
|
||||
#endif
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
static tracy_force_inline void YieldThread()
|
||||
{
|
||||
#if defined __SSE2__ || defined _M_AMD64 || (defined _M_IX86_FP && _M_IX86_FP == 2)
|
||||
_mm_pause();
|
||||
#elif defined __aarch64__
|
||||
asm volatile( "isb" : : );
|
||||
#else
|
||||
std::this_thread::yield();
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user