tracy/common/TracyQueue.hpp

92 lines
1.5 KiB
C++
Raw Normal View History

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,
StringData,
2017-09-21 23:51:56 +00:00
ThreadName,
2017-09-27 00:18:17 +00:00
CustomStringData,
2017-09-15 22:30:27 +00:00
FrameMark,
SourceLocation,
2017-09-27 00:18:17 +00:00
ZoneText,
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
{
int64_t time;
uint64_t srcloc; // ptr
uint64_t thread;
2017-09-10 18:06:52 +00:00
};
struct QueueZoneEnd
{
int64_t time;
2017-09-10 18:06:52 +00:00
};
struct QueueSourceLocation
{
uint64_t function; // ptr
uint64_t file; // ptr
uint32_t line;
uint32_t color;
};
2017-09-27 00:18:17 +00:00
struct QueueZoneText
{
uint64_t text; // ptr
};
struct QueueHeader
2017-09-10 18:06:52 +00:00
{
union
{
QueueType type;
uint8_t idx;
};
uint64_t id;
};
struct QueueItem
{
QueueHeader hdr;
2017-09-10 18:06:52 +00:00
union
{
QueueZoneBegin zoneBegin;
QueueZoneEnd zoneEnd;
QueueSourceLocation srcloc;
2017-09-27 00:18:17 +00:00
QueueZoneText zoneText;
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 ),
sizeof( QueueHeader ),
2017-09-15 22:30:27 +00:00
sizeof( QueueHeader ),
2017-09-21 23:51:56 +00:00
sizeof( QueueHeader ),
2017-09-27 00:18:17 +00:00
sizeof( QueueHeader ),
sizeof( QueueHeader ) + sizeof( QueueSourceLocation ),
2017-09-27 00:18:17 +00:00
sizeof( QueueHeader ) + sizeof( QueueZoneText ),
2017-09-11 23:14:04 +00:00
};
static_assert( sizeof( QueueDataSize ) / sizeof( size_t ) == (uint8_t)QueueType::NUM_TYPES, "QueueDataSize mismatch" );
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