VR-Vantage 2.7 API Documentation
Home
Modules
Namespaces
Classes
Files
Libraries
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
vrvUtil
DtProfiler.h
Go to the documentation of this file.
1
/*********************************************************************************
2
** Copyright (c) 2020 MAK Technologies, Inc.
3
** All rights reserved.
4
*********************************************************************************/
5
10
11
#pragma once
12
13
#include <
vrvUtil/vrvUtil.h
>
14
#include <
vrvUtil/DtProfileManager.h
>
15
16
//easy to use macro to profile a section
17
// should pass a "const char*" as name because the pointer is getting
18
// used to do the string compare (to be fast)
19
// if a std::string is passed instead it will cause a crashed when
20
// loading/unloading terrain with the performance/stats displayed
21
22
#define TRACY_ENABLE
23
//#define OPTICK_ENABLE
24
//#define NO_PROFILER
25
26
#ifndef TRACY_ENABLE
27
#ifndef OPTICK_ENABLE
28
#define NO_PROFILER
29
#endif
30
#endif
31
32
//optick
33
#ifdef OPTICK_ENABLE
34
#include <optick/optick.h>
35
//#pragma comment(lib, "OptickCore.lib")
36
37
// win32 creates macros that work with our stats and tracy
38
#define DtPROFILE(name) OPTICK_EVENT(name); DtPROFILE_X(name, __LINE__);
39
#define DtPROFILEC(name, color) OPTICK_EVENT(name); DtPROFILE_X(name, __LINE__);
40
#define DtPROFILE_SECTION(name) {OPTICK_EVENT(name); makVrv::DtProfileSample _profileSample(name);
41
42
#define DtProfilerFrameMark OPTICK_FRAME("MainThread")
43
#define DtProfilerThreadName(name) OPTICK_THREAD(name);
44
#define DtProfilerMessage(str, stringLen)
45
46
#define DtProfilerPlot(x,y)
47
#define DtProfilerText(text)
48
49
#endif
50
52
//tracy
53
#ifdef TRACY_ENABLE
54
#define TRACY_ON_DEMAND
55
#define TRACY_DELAYED_INIT
56
//#define TRACY_NO_BROADCAST
57
// TO DO include tracy on linux just to get it's macros for throwing things out
58
#include <
TracyClient/Tracy.hpp
>
59
//#pragma comment(lib, "TracyClient.lib")
60
61
#define ZoneScopedNA( name, active ) ZoneNamedN( ___tracy_scoped_zone, name, active )
62
#define ZoneScopedNCA( name, color, active ) ZoneNamedNC( ___tracy_scoped_zone, name, color, active )
63
64
// win32 creates macros that work with our stats and tracy
65
#define DtPROFILEzone ZoneNamed(___tracy_scoped_zone, makVrv::DtProfileManager::collectTracyStats());
66
#define DtPROFILE(name) ZoneScopedNA(name, makVrv::DtProfileManager::collectTracyStats()); DtPROFILE_X(name, __LINE__);
67
#define DtPROFILEC(name, color) ZoneScopedNCA(name, color, makVrv::DtProfileManager::collectTracyStats()); DtPROFILE_X(name, __LINE__);
68
#define DtPROFILE_SECTION(name) {ZoneScopedNA(name, makVrv::DtProfileManager::collectTracyStats()); makVrv::DtProfileSample _profileSample(name);
69
// call stack version doesn't work RtlWalkFrameChain unresolved.
70
//#define DtPROFILE(name) ZoneScopedNS(name, 4); DtPROFILE_X(name, __LINE__);
71
#define DtProfilerFrameMark if(makVrv::DtProfileManager::collectTracyStats()) { FrameMark; }
72
#define DtProfilerPlot(x,y) TracyPlot(x,y)
73
#define DtProfilerThreadName(name) tracy::SetThreadName(name );
74
#define DtProfilerMessage(str, stringLen) TracyMessage(str, stringLen)
75
#define DtProfilerText(text) _zoneSetText(___tracy_scoped_zone, text)
76
77
inline
void
_zoneSetText
(
tracy::ScopedZone
& zone,
const
char
* text) {
78
zone.
Text
(text, strlen(text));
79
}
80
inline
void
_zoneSetText
(
tracy::ScopedZone
& zone,
const
std::string
& text) {
81
zone.
Text
(text.c_str(), text.size());
82
}
83
#endif
84
86
// linux
87
#ifdef NO_PROFILER
88
#define DtPROFILE(name) DtPROFILE_X(name, __LINE__);
89
#define DtPROFILEC(name, color) DtPROFILE_X(name, __LINE__);
90
#define DtPROFILE_SECTION(name) {makVrv::DtProfileSample _profileSample(name);
91
#define DtPROFILEzone DtPROFILE_X(__func__, __LINE__);
92
93
#define DtProfilerPlot(x,y)
94
95
#define DtProfilerFrameMark
96
#define DtProfilerThreadName(name)
97
#define DtProfilerPlot(x,y)
98
#define DtProfilerMessage(str, stringLen)
99
#define DtProfilerText(text)
100
#endif
101
102
#define DtPROFILE_RESTRICTED(name, target) makVrv::DtProfileTarget<target> _profileTarget##line(name);
103
104
#define DtPROFILE_X(name, line) DtPROFILE_ACTUAL(name, line)
105
#define DtPROFILE_ACTUAL(name, line) makVrv::DtProfileSample _profileSample##line(name);
106
//#define DtPROFILE_FUNCTION(name, func) {makVrv::DtProfileSample _profileSample(name); (func);}
107
#define DtPROFILE_SECTION_END }
108
109
#define DtPERFORMANCE_STAT(name) DtPERFORMANCE_STAT_X(name, __LINE__)
110
#define DtPERFORMANCE_STAT_X(name, line) DtPERFORMANCE_STAT_ACTUAL(name, line)
111
#define DtPERFORMANCE_STAT_ACTUAL(name, line) makVrv::DtPerfomanceStatSample _performanceStatSample##line(name);
112
113
114
// These constants configure DtPROFILE_RESTRICTED
115
//
116
// Define them to boost::true_type to enable profiling of those sections
117
const
bool
Profile_DtSceneObjectUpdater
=
false
;
118
const
bool
Profile_DtSurfaceClampingUpdater
=
false
;
119
const
bool
Profile_DtOsgCullVisitor
=
false
;
120
121
namespace
makVrv
122
{
123
void
DT_DLL_VRVUTIL
SetThreadName
(
const
char
*
name
);
124
129
class
DT_DLL_VRVUTIL
DtProfileSample
130
{
131
public
:
133
DtProfileSample
(
const
char
* name )
134
{
135
DtProfileManager::startProfile
( name );
136
}
137
139
~
DtProfileSample
( )
140
{
141
DtProfileManager::stopProfile
();
142
}
143
};
144
149
template
<
bool
Enabled>
150
struct
DtProfileTarget
151
{
152
DtProfileTarget
(
const
char
* name) {}
153
};
154
155
template
<>
156
struct
DtProfileTarget
<true>
157
{
159
DtProfileTarget
(
const
char
* name )
160
{
161
DtProfileManager::startProfile
( name );
162
}
163
165
~
DtProfileTarget
( )
166
{
167
DtProfileManager::stopProfile
();
168
}
169
};
170
175
class
DT_DLL_VRVUTIL
DtPerfomanceStatSample
176
{
177
public
:
179
DtPerfomanceStatSample
(
const
char
* name )
180
{
181
DtProfileManager::startPerformanceStat
( name );
182
}
183
185
~
DtPerfomanceStatSample
( )
186
{
187
DtProfileManager::stopPerformanceStat
();
188
}
189
};
190
}
191
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (
www.mak.com
)