2017-09-10 18:06:52 +00:00
|
|
|
#ifndef __TRACYQUEUE_HPP__
|
|
|
|
#define __TRACYQUEUE_HPP__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
namespace tracy
|
|
|
|
{
|
|
|
|
|
|
|
|
enum class QueueType : uint8_t
|
|
|
|
{
|
|
|
|
ZoneBegin,
|
2017-09-11 23:14:04 +00:00
|
|
|
ZoneEnd,
|
2017-09-14 17:24:35 +00:00
|
|
|
StringData,
|
2017-09-21 23:51:56 +00:00
|
|
|
ThreadName,
|
2017-09-27 00:18:17 +00:00
|
|
|
CustomStringData,
|
2017-09-28 19:20:33 +00:00
|
|
|
FrameMarkMsg,
|
2017-09-26 00:28:14 +00:00
|
|
|
SourceLocation,
|
2017-09-27 00:18:17 +00:00
|
|
|
ZoneText,
|
2017-09-28 17:28:24 +00:00
|
|
|
ZoneName,
|
2017-10-04 14:16:27 +00:00
|
|
|
LockAnnounce,
|
|
|
|
LockWait,
|
|
|
|
LockObtain,
|
|
|
|
LockRelease,
|
2017-10-06 14:32:32 +00:00
|
|
|
LockMark,
|
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-01 17:11:01 +00:00
|
|
|
int8_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-01 17:11:01 +00:00
|
|
|
int8_t cpu;
|
2017-09-10 18:06:52 +00:00
|
|
|
};
|
|
|
|
|
2017-10-03 14:41:32 +00:00
|
|
|
struct QueueStringTransfer
|
|
|
|
{
|
|
|
|
uint64_t ptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct QueueFrameMark
|
|
|
|
{
|
|
|
|
int64_t time;
|
|
|
|
};
|
|
|
|
|
2017-09-26 00:28:14 +00:00
|
|
|
struct QueueSourceLocation
|
|
|
|
{
|
2017-10-03 14:41:32 +00:00
|
|
|
uint64_t ptr;
|
2017-09-26 00:28:14 +00:00
|
|
|
uint64_t function; // ptr
|
|
|
|
uint64_t file; // ptr
|
|
|
|
uint32_t line;
|
2017-09-26 16:54:48 +00:00
|
|
|
uint32_t color;
|
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-09-28 17:28:24 +00:00
|
|
|
struct QueueZoneName
|
|
|
|
{
|
2017-10-03 14:41:32 +00:00
|
|
|
uint64_t thread;
|
2017-09-28 17:28:24 +00:00
|
|
|
uint64_t name; // ptr
|
|
|
|
};
|
|
|
|
|
2017-10-04 14:16:27 +00:00
|
|
|
struct QueueLockAnnounce
|
|
|
|
{
|
2017-10-04 14:51:51 +00:00
|
|
|
uint64_t id;
|
2017-10-04 14:16:27 +00:00
|
|
|
uint64_t srcloc; // ptr
|
|
|
|
};
|
|
|
|
|
|
|
|
struct QueueLockWait
|
|
|
|
{
|
2017-10-04 14:51:51 +00:00
|
|
|
uint64_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 QueueLockObtain
|
|
|
|
{
|
2017-10-04 14:51:51 +00:00
|
|
|
uint64_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-04 14:51:51 +00:00
|
|
|
uint64_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
|
|
|
|
{
|
|
|
|
uint64_t id;
|
|
|
|
uint64_t thread;
|
|
|
|
uint64_t srcloc; // 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;
|
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-09-28 17:28:24 +00:00
|
|
|
QueueZoneName zoneName;
|
2017-10-04 14:16:27 +00:00
|
|
|
QueueLockAnnounce lockAnnounce;
|
|
|
|
QueueLockWait lockWait;
|
|
|
|
QueueLockObtain lockObtain;
|
|
|
|
QueueLockRelease lockRelease;
|
2017-10-06 14:32:32 +00:00
|
|
|
QueueLockMark lockMark;
|
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[] = {
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ),
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueZoneEnd ),
|
2017-10-03 14:41:32 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // string data
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // thread name
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // custom string data
|
|
|
|
sizeof( QueueHeader ) + sizeof( QueueFrameMark ),
|
2017-09-26 00:28:14 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueSourceLocation ),
|
2017-09-27 00:18:17 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueZoneText ),
|
2017-09-28 17:28:24 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueZoneName ),
|
2017-10-04 14:16:27 +00:00
|
|
|
sizeof( QueueHeader ) + sizeof( QueueLockAnnounce ),
|
|
|
|
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-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" );
|
2017-09-11 23:14:04 +00:00
|
|
|
|
2017-09-10 18:06:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|