VR-Vantage 3.0 API Documentation
Home
Modules
Namespaces
Classes
Files
Libraries
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
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_MANUAL_LIFETIME
57
//#define TRACY_NO_BROADCAST
58
// TO DO include tracy on linux just to get it's macros for throwing things out
59
#include <
TracyClient/Tracy.hpp
>
60
#include <
TracyClient/client/TracyProfiler.hpp
>
61
//#pragma comment(lib, "TracyClient.lib")
62
63
#define ZoneScopedNA( name, active ) ZoneNamedN( ___tracy_scoped_zone, name, active )
64
#define ZoneScopedNCA( name, color, active ) ZoneNamedNC( ___tracy_scoped_zone, name, color, active )
65
66
// win32 creates macros that work with our stats and tracy
67
#define DtPROFILEzone ZoneNamed(___tracy_scoped_zone, makVrv::DtProfileManager::collectTracyStats());
68
#define DtPROFILE(name) ZoneScopedNA(name, makVrv::DtProfileManager::collectTracyStats()); DtPROFILE_X(name, __LINE__);
69
#define DtPROFILEC(name, color) ZoneScopedNCA(name, color, makVrv::DtProfileManager::collectTracyStats()); DtPROFILE_X(name, __LINE__);
70
#define DtPROFILE_SECTION(name) {ZoneScopedNA(name, makVrv::DtProfileManager::collectTracyStats()); makVrv::DtProfileSample _profileSample(name);
71
// call stack version doesn't work RtlWalkFrameChain unresolved.
72
//#define DtPROFILE(name) ZoneScopedNS(name, 4); DtPROFILE_X(name, __LINE__);
73
#define DtProfilerFrameMark if(makVrv::DtProfileManager::tracyProfilerInitialized()) { FrameMark; }
74
#define DtProfilerPlot(x,y) TracyPlot(x,y)
75
#define DtProfilerThreadName(name) tracy::SetThreadName(name );
76
#define DtProfilerMessage(str, stringLen) TracyMessage(str, stringLen)
77
#define DtProfilerText(text) _zoneSetText(___tracy_scoped_zone, text)
78
79
inline
void
_zoneSetText
(
tracy::ScopedZone
& zone,
const
char
* text) {
80
zone.
Text
(text, strlen(text));
81
}
82
inline
void
_zoneSetText
(
tracy::ScopedZone
& zone,
const
std::string
& text) {
83
zone.
Text
(text.c_str(), text.size());
84
}
85
#endif
86
88
89
#ifdef NO_PROFILER
90
#define DtPROFILEzone
91
#define DtPROFILE(name) DtPROFILE_X(name, __LINE__);
92
#define DtPROFILEC(name, color) DtPROFILE_X(name, __LINE__);
93
#define DtPROFILE_SECTION(name) {makVrv::DtProfileSample _profileSample(name);
94
#define DtPROFILEzone DtPROFILE_X(__func__, __LINE__);
95
96
#define DtProfilerPlot(x,y)
97
98
#define DtProfilerFrameMark
99
#define DtProfilerThreadName(name)
100
#define DtProfilerPlot(x,y)
101
#define DtProfilerMessage(str, stringLen)
102
#define DtProfilerText(text)
103
#endif
104
105
#define DtPROFILE_RESTRICTED(name, target) makVrv::DtProfileTarget<target> _profileTarget##line(name);
106
107
#define DtPROFILE_X(name, line) DtPROFILE_ACTUAL(name, line)
108
#define DtPROFILE_ACTUAL(name, line) makVrv::DtProfileSample _profileSample##line(name);
109
//#define DtPROFILE_FUNCTION(name, func) {makVrv::DtProfileSample _profileSample(name); (func);}
110
#define DtPROFILE_SECTION_END }
111
112
#define DtPERFORMANCE_STAT(name) DtPERFORMANCE_STAT_X(name, __LINE__)
113
#define DtPERFORMANCE_STAT_X(name, line) DtPERFORMANCE_STAT_ACTUAL(name, line)
114
#define DtPERFORMANCE_STAT_ACTUAL(name, line) makVrv::DtPerfomanceStatSample _performanceStatSample##line(name);
115
116
117
// These constants configure DtPROFILE_RESTRICTED
118
//
119
// Define them to boost::true_type to enable profiling of those sections
120
const
bool
Profile_DtSceneObjectUpdater
=
false
;
121
const
bool
Profile_DtSurfaceClampingUpdater
=
false
;
122
const
bool
Profile_DtOsgCullVisitor
=
false
;
123
124
namespace
makVrv
125
{
126
void
DT_DLL_VRVUTIL
SetThreadName
(
const
char
*
name
);
127
132
class
DT_DLL_VRVUTIL
DtProfileSample
133
{
134
public
:
136
DtProfileSample
(
const
char
* name )
137
{
138
DtProfileManager::startProfile
( name );
139
}
140
142
~
DtProfileSample
( )
143
{
144
DtProfileManager::stopProfile
();
145
}
146
};
147
152
template
<
bool
Enabled>
153
struct
DtProfileTarget
154
{
155
DtProfileTarget
(
const
char
* name) {}
156
};
157
158
template
<>
159
struct
DtProfileTarget
<true>
160
{
162
DtProfileTarget
(
const
char
* name )
163
{
164
DtProfileManager::startProfile
( name );
165
}
166
168
~
DtProfileTarget
( )
169
{
170
DtProfileManager::stopProfile
();
171
}
172
};
173
178
class
DT_DLL_VRVUTIL
DtPerfomanceStatSample
179
{
180
public
:
182
DtPerfomanceStatSample
(
const
char
* name )
183
{
184
DtProfileManager::startPerformanceStat
( name );
185
}
186
188
~
DtPerfomanceStatSample
( )
189
{
190
DtProfileManager::stopPerformanceStat
();
191
}
192
};
193
}
194
Copyright © 2005-2022 MAK Technologies. All Rights Reserved (
www.mak.com
)