VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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>
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 //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;
122 const bool Profile_DtOsgCullVisitor = false;
123 
124 namespace makVrv
125 {
126  void DT_DLL_VRVUTIL SetThreadName(const char* name);
127 
133  {
134  public:
136  DtProfileSample(const char* name )
137  {
139  }
140 
143  {
145  }
146  };
147 
152  template <bool Enabled>
154  {
155  DtProfileTarget(const char* name) {}
156  };
157 
158  template <>
159  struct DtProfileTarget<true>
160  {
162  DtProfileTarget(const char* name )
163  {
165  }
166 
169  {
171  }
172  };
173 
179  {
180  public:
182  DtPerfomanceStatSample(const char* name )
183  {
185  }
186 
189  {
191  }
192  };
193 }
194 
const bool Profile_DtOsgCullVisitor
Definition: DtProfiler.h:122
#define DT_DLL_VRVUTIL
Definition: vrvUtil.h:34
DtProfileTarget is used to start/stop a profiled section It is preferable to use the macro at the top...
Definition: DtProfiler.h:153
DtProfileSampleClass is used to start/stop a profiled section It is preferable to use the macro at th...
Definition: DtProfiler.h:178
static void startProfile(const char *name)
begin a profile. This function is thread safe
DtProfileSample(const char *name)
CTOR starts profile section.
Definition: DtProfiler.h:136
const bool Profile_DtSurfaceClampingUpdater
Definition: DtProfiler.h:121
~DtPerfomanceStatSample()
DTOR stops profile section.
Definition: DtProfiler.h:188
DtProfileTarget(const char *name)
CTOR starts profile section.
Definition: DtProfiler.h:162
DtProfileSampleClass is used to start/stop a profiled section It is preferable to use the macro at th...
Definition: DtProfiler.h:132
void _zoneSetText(tracy::ScopedZone &zone, const char *text)
Definition: DtProfiler.h:79
Contains DLL export macros.
const bool Profile_DtSceneObjectUpdater
Definition: DtProfiler.h:120
void DT_DLL_VRVUTIL SetThreadName(const char *name)
~DtProfileTarget()
DTOR stops profile section.
Definition: DtProfiler.h:168
static void stopPerformanceStat()
begin stop a profile. This function is thread safe
DtProfileTarget(const char *name)
Definition: DtProfiler.h:155
static void startPerformanceStat(const char *name)
begin a performance stat. This function is thread safe
DtPerfomanceStatSample(const char *name)
CTOR starts profile section.
Definition: DtProfiler.h:182
~DtProfileSample()
DTOR stops profile section.
Definition: DtProfiler.h:142
static void stopProfile()
begin stop a profile. This function is thread safe

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)