2017-09-10 18:06:52 +00:00
|
|
|
#ifndef __TRACYQUEUE_HPP__
|
|
|
|
#define __TRACYQUEUE_HPP__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
namespace tracy
|
|
|
|
{
|
|
|
|
|
|
|
|
enum class QueueType : uint8_t
|
|
|
|
{
|
2017-11-22 01:28:12 +00:00
|
|
|
ZoneText,
|
2018-06-29 14:01:31 +00:00
|
|
|
ZoneName,
|
2017-11-22 01:28:12 +00:00
|
|
|
Message,
|
|
|
|
ZoneBeginAllocSrcLoc,
|
2018-06-19 17:09:57 +00:00
|
|
|
CallstackMemory,
|
2018-06-21 22:56:01 +00:00
|
|
|
Callstack,
|
2017-10-18 16:48:51 +00:00
|
|
|
Terminate,
|
2018-07-10 19:23:19 +00:00
|
|
|
KeepAlive,
|
2018-08-19 23:03:16 +00:00
|
|
|
Crash,
|
2018-08-20 00:07:31 +00:00
|
|
|
CrashReport,
|
2017-09-10 18:06:52 +00:00
|
|
|
ZoneBegin,
|
2018-06-21 22:56:01 +00:00
|
|
|
ZoneBeginCallstack,
|
2017-09-11 23:14:04 +00:00
|
|
|
ZoneEnd,
|
2019-01-14 21:16:14 +00:00
|
|
|
ZoneValidation,
|
2017-09-28 19:20:33 +00:00
|
|
|
FrameMarkMsg,
|
2018-08-05 00:09:59 +00:00
|
|
|
FrameMarkMsgStart,
|
|
|
|
FrameMarkMsgEnd,
|
2017-09-26 00:28:14 +00:00
|
|
|
SourceLocation,
|
2017-12-10 20:37:39 +00:00
|
|
|
LockAnnounce,
|
2018-12-16 19:37:48 +00:00
|
|
|
LockTerminate,
|
2017-10-04 14:16:27 +00:00
|
|
|
LockWait,
|
|
|
|
LockObtain,
|
|
|
|
LockRelease,
|
2017-12-10 21:04:49 +00:00
|
|
|
LockSharedWait,
|
|
|
|
LockSharedObtain,
|
|
|
|
LockSharedRelease,
|
2017-10-06 14:32:32 +00:00
|
|
|
LockMark,
|
2017-10-13 00:07:03 +00:00
|
|
|
PlotData,
|
2017-10-15 11:06:49 +00:00
|
|
|
MessageLiteral,
|
2017-11-11 18:44:09 +00:00
|
|
|
GpuNewContext,
|
2017-11-11 20:09:48 +00:00
|
|
|
GpuZoneBegin,
|
2018-06-21 23:47:08 +00:00
|
|
|
GpuZoneBeginCallstack,
|
2017-11-11 20:09:48 +00:00
|
|
|
GpuZoneEnd,
|
2017-11-11 21:08:47 +00:00
|
|
|
GpuTime,
|
2018-03-31 19:56:05 +00:00
|
|
|
MemAlloc,
|
|
|
|
MemFree,
|
2018-06-19 16:50:29 +00:00
|
|
|
MemAllocCallstack,
|
|
|
|
MemFreeCallstack,
|
2018-06-19 23:06:31 +00:00
|
|
|
CallstackFrame,
|
2017-11-19 01:42:04 +00:00
|
|
|
StringData,
|
|
|
|
ThreadName,
|
|
|
|
CustomStringData,
|
|
|
|
PlotName,
|
|
|
|
SourceLocationPayload,
|
2018-06-19 17:09:43 +00:00
|
|
|
CallstackPayload,
|
2018-08-04 18:48:21 +00:00
|
|
|
FrameName,
|
2017-09-11 23:14:04 +00:00
|
|
|
NUM_TYPES
|
2017-09-10 18:06:52 +00:00
|
|
|
};
|
|
|
|
|
2017-09-11 22:28:50 +00:00
|
|
|
#pragma pack( 1 )
|
|
|
|
|
2017-09-10 18:06:52 +00:00
|
|
|
struct QueueZoneBegin
|
|
|
|
{
|
2017-09-13 23:07:14 +00:00
|
|
|
int64_t time;
|
2017-09-21 23:11:53 +00:00
|
|
|
uint64_t thread;
|
2017-10-03 14:41:32 +00:00
|
|
|
uint64_t srcloc; // ptr
|
2017-10-10 21:21:30 +00:00
|
|
|
uint32_t cpu;
|
2017-09-10 18:06:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct QueueZoneEnd
|
|
|
|
{
|
2017-09-13 23:07:14 +00:00
|
|
|
int64_t time;
|
2017-10-03 14:41:32 +00:00
|
|
|
uint64_t thread;
|
2017-10-10 21:21:30 +00:00
|
|
|
uint32_t cpu;
|
2017-09-10 18:06:52 +00:00
|
|
|
};
|
|
|
|
|
2019-01-14 21:16:14 +00:00
|
|
|
struct QueueZoneValidation
|
|
|
|
{
|
|
|
|
uint64_t thread;
|
|
|
|
uint32_t id;
|
|
|
|
};
|
|
|
|
|
2017-10-03 14:41:32 +00:00
|
|
|
struct QueueStringTransfer
|
|
|
|
{
|
|
|
|
uint64_t ptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct QueueFrameMark
|
|
|
|
{
|
|
|
|
int64_t time;
|
2018-08-04 13:03:47 +00:00
|
|
|
uint64_t name; // ptr
|
2017-10-03 14:41:32 +00:00
|
|
|
};
|
|
|
|
|
2017-09-26 00:28:14 +00:00
|
|
|
struct QueueSourceLocation
|
|
|
|
{
|
2017-11-14 22:06:45 +00:00
|
|
|
uint64_t name;
|
2017-09-26 00:28:14 +00:00
|
|
|
uint64_t function; // ptr
|
|
|
|
uint64_t file; // ptr
|
|
|
|
uint32_t line;
|
2017-10-13 17:59:18 +00:00
|
|
|
uint8_t r;
|
|
|
|
uint8_t g;
|
|
|
|
uint8_t b;
|
2017-09-26 00:28:14 +00:00
|
|
|
};
|
|
|
|
|
2017-09-27 00:18:17 +00:00
|
|
|
struct QueueZoneText
|
|
|
|
{
|
2017-10-03 14:41:32 +00:00
|
|
|
uint64_t thread;
|
2017-09-27 00:18:17 +00:00
|
|
|
uint64_t text; // ptr
|
|
|
|
};
|
|
|
|
|
2017-12-10 20:37:39 +00:00
|
|
|
enum class LockType : uint8_t
|
|
|
|
{
|
2017-12-10 20:49:45 +00:00
|
|
|
Lockable,
|
|
|
|
SharedLockable
|
2017-12-10 20:37:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct QueueLockAnnounce
|
|
|
|
{
|
|
|
|
uint32_t id;
|
2018-12-16 19:33:18 +00:00
|
|
|
int64_t time;
|
2017-12-10 20:37:39 +00:00
|
|
|
uint64_t lckloc; // ptr
|
|
|
|
LockType type;
|
|
|
|
};
|
|
|
|
|
2018-12-16 19:37:48 +00:00
|
|
|
struct QueueLockTerminate
|
|
|
|
{
|
|
|
|
uint32_t id;
|
|
|
|
int64_t time;
|
|
|
|
LockType type;
|
|
|
|
};
|
|
|
|
|
2017-10-04 14:16:27 +00:00
|
|
|
struct QueueLockWait
|
|
|
|
{
|
2017-10-13 18:05:38 +00:00
|
|
|
uint32_t id;
|
2017-10-04 14:45:46 +00:00
|
|
|
int64_t time;
|
|
|
|
uint64_t thread;
|
2017-12-17 17:30:34 +00:00
|
|
|
LockType type;
|
2017-10-04 14:16:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct QueueLockObtain
|
|
|
|
{
|
2017-10-13 18:05:38 +00:00
|
|
|
uint32_t id;
|
2017-10-04 14:45:46 +00:00
|
|
|
int64_t time;
|
|
|
|
uint64_t thread;
|
2017-10-04 14:16:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct QueueLockRelease
|
|
|
|
{
|
2017-10-13 18:05:38 +00:00
|
|
|
uint32_t id;
|
2017-10-04 14:45:46 +00:00
|
|
|
int64_t time;
|
|
|
|
uint64_t thread;
|
2017-10-04 14:16:27 +00:00
|
|
|
};
|
|
|
|
|
2017-10-06 14:32:32 +00:00
|
|
|
struct QueueLockMark
|
|
|
|
{
|
2017-10-13 18:05:38 +00:00
|
|
|
uint32_t id;
|
2017-10-06 14:32:32 +00:00
|
|
|
uint64_t thread;
|
|
|
|
uint64_t srcloc; // ptr
|
|
|
|
};
|
|
|
|
|
2017-10-13 00:21:29 +00:00
|
|
|
enum class PlotDataType : uint8_t
|
|
|
|
{
|
|
|
|
Float,
|
|
|
|
Double,
|
|
|
|
Int
|
|
|
|
};
|
|
|
|
|
2017-10-13 00:07:03 +00:00
|
|
|
struct QueuePlotData
|
|
|
|
{
|
|
|
|
uint64_t name; // ptr
|
|
|
|
int64_t time;
|
2017-10-13 00:21:29 +00:00
|
|
|
PlotDataType type;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
double d;
|
|
|
|
float f;
|
|
|
|
int64_t i;
|
|
|
|
} data;
|
2017-10-13 00:07:03 +00:00
|
|
|
};
|
|
|
|
|
2017-10-14 11:23:13 +00:00
|
|
|
struct QueueMessage
|
|
|
|
{
|
|
|
|
int64_t time;
|
|
|
|
uint64_t thread;
|
|
|
|
uint64_t text; // ptr
|
|
|
|
};
|
|
|
|
|
2017-11-11 18:44:09 +00:00
|
|
|
struct QueueGpuNewContext
|
|
|
|
{
|
2017-11-25 12:14:16 +00:00
|
|
|
int64_t cpuTime;
|
|
|
|
int64_t gpuTime;
|
2017-11-13 23:48:26 +00:00
|
|
|
uint64_t thread;
|
2018-06-17 16:21:15 +00:00
|
|
|
float period;
|
2018-06-22 13:10:23 +00:00
|
|
|
uint8_t context;
|
2017-11-17 13:07:42 +00:00
|
|
|
uint8_t accuracyBits;
|
2017-11-11 18:44:09 +00:00
|
|
|
};
|
|
|
|
|
2017-11-11 20:09:48 +00:00
|
|
|
struct QueueGpuZoneBegin
|
|
|
|
{
|
|
|
|
int64_t cpuTime;
|
|
|
|
uint64_t srcloc;
|
2018-06-17 16:55:12 +00:00
|
|
|
uint64_t thread;
|
2018-06-22 13:57:54 +00:00
|
|
|
uint16_t queryId;
|
2018-06-22 13:10:23 +00:00
|
|
|
uint8_t context;
|
2017-11-11 20:09:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct QueueGpuZoneEnd
|
|
|
|
{
|
|
|
|
int64_t cpuTime;
|
2018-06-22 13:57:54 +00:00
|
|
|
uint16_t queryId;
|
2018-06-22 13:10:23 +00:00
|
|
|
uint8_t context;
|
2017-11-11 20:09:48 +00:00
|
|
|
};
|
|
|
|
|
2017-11-11 21:08:47 +00:00
|
|
|
struct QueueGpuTime
|
|
|
|
{
|
|
|
|
int64_t gpuTime;
|
2018-06-22 14:19:53 +00:00
|
|
|
uint16_t queryId;
|
2018-06-22 13:10:23 +00:00
|
|
|
uint8_t context;
|
2017-11-11 21:08:47 +00:00
|
|
|
};
|
|
|
|
|
2018-03-31 19:56:05 +00:00
|
|
|
struct QueueMemAlloc
|
|
|
|
{
|
|
|
|
int64_t time;
|
|
|
|
uint64_t thread;
|
|
|
|
uint64_t ptr;
|
|
|
|
char size[6];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct QueueMemFree
|
|
|
|
{
|
|
|
|
int64_t time;
|
|
|
|
uint64_t thread;
|
|
|
|
uint64_t ptr;
|
|
|
|
};
|
|
|
|
|
2018-06-19 16:50:29 +00:00
|
|
|
struct QueueCallstackMemory
|
|
|
|
{
|
|
|
|
uint64_t ptr;
|
|
|
|
};
|
|
|
|
|
2018-06-21 22:56:01 +00:00
|
|
|
struct QueueCallstack
|
|
|
|
{
|
|
|
|
uint64_t ptr;
|
|
|
|
uint64_t thread;
|
|
|
|
};
|
|
|
|
|
2018-06-19 23:06:31 +00:00
|
|
|
struct QueueCallstackFrame
|
|
|
|
{
|
|
|
|
uint64_t ptr;
|
|
|
|
uint64_t name;
|
|
|
|
uint64_t file;
|
|
|
|
uint32_t line;
|
|
|
|
};
|
|
|
|
|
2018-08-20 00:07:31 +00:00
|
|
|
struct QueueCrashReport
|
|
|
|
{
|
|
|
|
int64_t time;
|
|
|
|
uint64_t thread;
|
|
|
|
uint64_t text; // ptr
|
|
|
|
};
|
|
|
|
|
2017-09-11 22:56:31 +00:00
|
|
|
struct QueueHeader
|
2017-09-10 18:06:52 +00:00
|
|
|
{
|
2017-09-13 23:05:08 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
QueueType type;
|
|
|
|
uint8_t idx;
|
|
|
|
};
|
2017-09-11 22:56:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct QueueItem
|
|
|
|
{
|
|
|
|
QueueHeader hdr;
|
2017-09-10 18:06:52 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
QueueZoneBegin zoneBegin;
|
|
|
|
QueueZoneEnd zoneEnd;
|
2019-01-14 21:16:14 +00:00
|
|
|
QueueZoneValidation zoneValidation;
|
2017-10-03 14:41:32 +00:00
|
|
|
QueueStringTransfer stringTransfer;
|
|
|
|
QueueFrameMark frameMark;
|
2017-09-26 00:28:14 +00:00
|
|
|
QueueSourceLocation srcloc;
|
2017-09-27 00:18:17 +00:00
|
|
|
QueueZoneText zoneText;
|
2017-12-10 20:37:39 +00:00
|
|
|
QueueLockAnnounce lockAnnounce;
|
2018-12-16 19:37:48 +00:00
|
|
|
QueueLockTerminate lockTerminate;
|
2017-10-04 14:16:27 +00:00
|
|
|
QueueLockWait lockWait;
|
|
|
|
QueueLockObtain lockObtain;
|
|
|
|
QueueLockRelease lockRelease;
|
2017-10-06 14:32:32 +00:00
|
|
|
QueueLockMark lockMark;
|
2017-10-13 00:07:03 +00:00
|
|
|
QueuePlotData plotData;
|
2017-10-14 11:23:13 +00:00
|
|
|
QueueMessage message;
|
2017-11-11 18:44:09 +00:00
|
|
|
QueueGpuNewContext gpuNewContext;
|
2017-11-11 20:09:48 +00:00
|
|
|
QueueGpuZoneBegin gpuZoneBegin;
|
|
|
|
QueueGpuZoneEnd gpuZoneEnd;
|
2017-11-11 21:08:47 +00:00
|
|
|
QueueGpuTime gpuTime;
|
2018-03-31 19:56:05 +00:00
|
|
|
QueueMemAlloc memAlloc;
|
|
|
|
QueueMemFree memFree;
|
2018-06-19 16:50:29 +00:00
|
|
|
QueueCallstackMemory callstackMemory;
|
2018-06-21 22:56:01 +00:00
|
|
|
QueueCallstack callstack;
|
2018-06-19 23:06:31 +00:00
|
|
|
QueueCallstackFrame callstackFrame;
|
2018-08-20 00:07:31 +00:00
|
|
|
QueueCrashReport crashReport;
|
2017-09-10 18:06:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-09-11 22:28:50 +00:00
|
|
|
#pragma pack()
|
|
|
|
|
2017-09-10 18:06:52 +00:00
|
|
|
enum { QueueItemSize = sizeof( QueueItem ) };
|
|
|
|
|
2017-09-11 23:14:04 +00:00
|
|
|
static const size_t QueueDataSize[] = {
|
2017-11-22 01:28:12 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueZoneText ),
|
2018-06-29 14:01:31 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueZoneText ), // zone name
|
2017-11-22 01:28:12 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueMessage ),
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location
|
2018-06-19 17:09:57 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueCallstackMemory ),
|
2018-06-21 22:56:01 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueCallstack ),
|
2017-11-22 01:28:12 +00:00
|
|
|
// above items must be first
|
2017-10-18 16:48:51 +00:00
|
|
|
sizeof( QueueHeader ), // terminate
|
2018-07-10 19:23:19 +00:00
|
|
|
sizeof( QueueHeader ), // keep alive
|
2018-08-19 23:03:16 +00:00
|
|
|
sizeof( QueueHeader ), // crash
|
2018-08-20 00:07:31 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueCrashReport ),
|
2017-09-11 23:14:04 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ),
|
2018-06-21 22:56:01 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // callstack
|
2017-09-11 23:14:04 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueZoneEnd ),
|
2019-01-14 21:16:14 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueZoneValidation ),
|
2018-08-05 00:09:59 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // continuous frames
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // start
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // end
|
2017-09-26 00:28:14 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueSourceLocation ),
|
2017-12-10 20:37:39 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueLockAnnounce ),
|
2018-12-16 19:37:48 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueLockTerminate ),
|
2017-10-04 14:16:27 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueLockWait ),
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueLockObtain ),
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueLockRelease ),
|
2017-12-10 21:04:49 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueLockWait ),
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueLockObtain ),
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueLockRelease ),
|
2017-10-06 14:32:32 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueLockMark ),
|
2017-10-13 00:07:03 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueuePlotData ),
|
2017-10-15 11:06:49 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal
|
2017-11-11 18:44:09 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueGpuNewContext ),
|
2017-11-11 20:09:48 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueGpuZoneBegin ),
|
2018-06-21 23:47:08 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueGpuZoneBegin ), // callstack
|
2017-11-11 20:09:48 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueGpuZoneEnd ),
|
2017-11-11 21:08:47 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueGpuTime ),
|
2018-03-31 19:56:05 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueMemAlloc ),
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueMemFree ),
|
2018-06-19 16:50:29 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueMemAlloc ), // callstack
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueMemFree ), // callstack
|
2018-06-19 23:06:31 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueCallstackFrame ),
|
2017-11-19 01:42:04 +00:00
|
|
|
// keep all QueueStringTransfer below
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // string data
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // thread name
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // custom string data
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // plot name
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // allocated source location payload
|
2018-06-19 17:09:43 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // callstack payload
|
2018-08-04 18:48:21 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // frame name
|
2017-09-11 23:14:04 +00:00
|
|
|
};
|
|
|
|
|
2017-10-13 18:05:38 +00:00
|
|
|
static_assert( QueueItemSize == 32, "Queue item size not 32 bytes" );
|
2017-09-11 23:14:04 +00:00
|
|
|
static_assert( sizeof( QueueDataSize ) / sizeof( size_t ) == (uint8_t)QueueType::NUM_TYPES, "QueueDataSize mismatch" );
|
2017-09-12 23:24:42 +00:00
|
|
|
static_assert( sizeof( void* ) <= sizeof( uint64_t ), "Pointer size > 8 bytes" );
|
2018-06-19 15:51:55 +00:00
|
|
|
static_assert( sizeof( void* ) == sizeof( uintptr_t ), "Pointer size != uintptr_t" );
|
2017-09-11 23:14:04 +00:00
|
|
|
|
2017-09-10 18:06:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|