summaryrefslogtreecommitdiffstats
path: root/external/optick/optick_message.h
blob: a6d553ef0aaa5459e2b123dc6ac2e75c2a909742 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#pragma once
#include "optick.config.h"

#if USE_OPTICK

#include "optick_common.h"
#include "optick_serialization.h"

namespace Optick
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static const uint32 NETWORK_PROTOCOL_VERSION = 24;
static const uint16 NETWORK_APPLICATION_ID = 0xB50F;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct DataResponse
{
	enum Type : uint16
	{
		FrameDescriptionBoard = 0,		// DescriptionBoard for Instrumental Frames
		EventFrame = 1,					// Instrumental Data
		SamplingFrame = 2,				// Sampling Data
		NullFrame = 3,					// Last Fame Mark
		ReportProgress = 4,				// Report Current Progress
		Handshake = 5,					// Handshake Response
		Reserved_0 = 6,					
		SynchronizationData = 7,		// Synchronization Data for the thread
		TagsPack = 8,					// Pack of tags
		CallstackDescriptionBoard = 9,	// DescriptionBoard with resolved function addresses
		CallstackPack = 10,				// Pack of CallStacks
		Reserved_1 = 11,				
		Reserved_2 = 12,				
		Reserved_3 = 13,				
		Reserved_4 = 14,				
		//...
		Reserved_255 = 255,

		FiberSynchronizationData = 1 << 8, // Synchronization Data for the Fibers
		SyscallPack,
		SummaryPack,
	};

	uint32 version;
	uint32 size;
	Type type;
	uint16 application;

	DataResponse(Type t, uint32 s) : version(NETWORK_PROTOCOL_VERSION), size(s), type(t), application(NETWORK_APPLICATION_ID){}
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
OutputDataStream& operator << (OutputDataStream& os, const DataResponse& val);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class IMessage
{
public:
	enum Type : uint16
	{
		Start,
		Stop,
		Cancel,
		TurnSampling,
		COUNT,
	};

	virtual void Apply() = 0;
	virtual ~IMessage() {}

	static IMessage* Create( InputDataStream& str );
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<IMessage::Type MESSAGE_TYPE>
class Message : public IMessage
{
	enum { id = MESSAGE_TYPE };
public:
	static uint32 GetMessageType() { return id; }
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct CaptureSettings
{
	// Capture Mode
	uint32 mode;
	// Category Filter
	uint32 categoryMask;
	// Tracer: Sampling Frequency
	uint32 samplingFrequency;
	// Max Duration for a capture (frames)
	uint32 frameLimit;
	// Max Duration for a capture (us)
	uint32 timeLimitUs;
	// Max Duration for a capture (us)
	uint32 spikeLimitUs;
	// Max Memory for a capture (MB)
	uint64 memoryLimitMb;
	// Tracer: Root Password for the Device
	string password;

	CaptureSettings() : mode(0), categoryMask(0), samplingFrequency(0), frameLimit(0), timeLimitUs(0), spikeLimitUs(0), memoryLimitMb(0) {}
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct StartMessage : public Message<IMessage::Start>
{
	CaptureSettings settings;
	static IMessage* Create(InputDataStream&);
	virtual void Apply() override;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct StopMessage : public Message<IMessage::Stop>
{
	static IMessage* Create(InputDataStream&);
	virtual void Apply() override;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct CancelMessage : public Message<IMessage::Cancel>
{
	static IMessage* Create(InputDataStream&);
	virtual void Apply() override;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct TurnSamplingMessage : public Message<IMessage::TurnSampling>
{
	int32 index;
	byte isSampling;

	static IMessage* Create(InputDataStream& stream);
	virtual void Apply() override;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

#endif //USE_OPTICK