VR-Forces 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) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************************/
5 
10 
11 #pragma once
12 
13 #include <vrvUtil/vrvUtil.h>
15 
16 // Single location to define profiling colors
17 #define DTPROFILE_TRACYCOLOR_SILVERLINING 0x0b8bf8
18 #define DTPROFILE_TRACYCOLOR_TRITON 0x123f7b
19 #define DTPROFILE_TRACYCOLOR_SPEEDTREE 0x0f502d
20 #define DTPROFILE_TRACYCOLOR_INDIRECT 0x3333cc
21 #define DTPROFILE_TRACYCOLOR_LIGHTING 0xffaa00
22 #define DTPROFILE_TRACYCOLOR_POSTEFFECT 0xffb31a
23 #define DTPROFILE_TRACYCOLOR_VIRTUALREALITY 0xa3297a
24 #define DTPROFILE_TRACYCOLOR_GLCONTEXT 0xe68a00
25 #define DTPROFILE_TRACYCOLOR_RENDERER 0xb990000
26 
27 
28 
29 
30 //easy to use macro to profile a section
31 // should pass a "const char*" as name because the pointer is getting
32 // used to do the string compare (to be fast)
33 // if a std::string is passed instead it will cause a crashed when
34 // loading/unloading terrain with the performance/stats displayed
35 
36 #define TRACY_ENABLE
37 //#define OPTICK_ENABLE
38 //#define NO_PROFILER
39 
40 #ifndef TRACY_ENABLE
41 #ifndef OPTICK_ENABLE
42 #define NO_PROFILER
43 #endif
44 #endif
45 //optick
47 #ifdef OPTICK_ENABLE
48 #include <optick/optick.h>
49 //#pragma comment(lib, "OptickCore.lib")
50 
51 // win32 creates macros that work with our stats and tracy
52 #define DtPROFILE(name) OPTICK_EVENT(name); DtPROFILE_X(name, __LINE__);
53 #define DtPROFILEC(name, color) OPTICK_EVENT(name); DtPROFILE_X(name, __LINE__);
54 #define DtPROFILE_SECTION(name) {OPTICK_EVENT(name); makVrv::DtProfileSample _profileSample(name);
55 
56 #define DtProfilerFrameMark OPTICK_FRAME("MainThread")
57 #define DtProfilerThreadName(name) OPTICK_THREAD(name);
58 #define DtProfilerMessage(str, stringLen)
59 
60 #define DtProfilerPlot(x,y)
61 #define DtProfilerText(text)
62 
63 #endif
64 
66 //tracy
67 #ifdef TRACY_ENABLE
68 #define TRACY_ON_DEMAND
69 #define TRACY_DELAYED_INIT
70 #define TRACY_MANUAL_LIFETIME
71 //#define TRACY_NO_BROADCAST
72 // TO DO include tracy on linux just to get it's macros for throwing things out
73 #include <TracyClient/Tracy.hpp>
74 #include <TracyClient/client/TracyProfiler.hpp>
75 //#pragma comment(lib, "TracyClient.lib")
76 
77 #define ZoneScopedNA( name, active ) ZoneNamedN( ___tracy_scoped_zone, name, active )
78 #define ZoneScopedNCA( name, color, active ) ZoneNamedNC( ___tracy_scoped_zone, name, color, active )
79 
80 // win32 creates macros that work with our stats and tracy
81 #define DtPROFILEzone ZoneNamed(___tracy_scoped_zone, makVrv::DtProfileManager::collectTracyStats());
82 #define DtPROFILEzoneN(name) ZoneNamedN(___tracy_scoped_zone, name, makVrv::DtProfileManager::collectTracyStats());
83 #define DtPROFILE(name) ZoneScopedNA(name, makVrv::DtProfileManager::collectTracyStats()); DtPROFILE_X(name, __LINE__);
84 #define DtPROFILEC(name, color) ZoneScopedNCA(name, color, makVrv::DtProfileManager::collectTracyStats()); DtPROFILE_X(name, __LINE__);
85 #define DtPROFILE_SECTION(name) {ZoneScopedNA(name, makVrv::DtProfileManager::collectTracyStats()); makVrv::DtProfileSample _profileSample(name);
86 // call stack version doesn't work RtlWalkFrameChain unresolved.
87 //#define DtPROFILE(name) ZoneScopedNS(name, 4); DtPROFILE_X(name, __LINE__);
88 #define DtProfilerFrameMark if(makVrv::DtProfileManager::tracyProfilerInitialized()) { FrameMark; }
89 #define DtProfilerPlot(x,y) TracyPlot(x,y)
90 #define DtProfilerThreadName(name) tracy::SetThreadName(name );
91 #define DtProfilerMessage(str, stringLen) TracyMessage(str, stringLen)
92 #define DtProfilerText(text) _zoneSetText(___tracy_scoped_zone, text)
93 
94 inline void _zoneSetText(tracy::ScopedZone& zone, const char* text) {
95  zone.Text(text, strlen(text));
96 }
97 inline void _zoneSetText(tracy::ScopedZone& zone, const std::string& text) {
98  zone.Text(text.c_str(), text.size());
99 }
100 
101 #define DtProfilerName(text) _zoneSetName(___tracy_scoped_zone, text)
102 
103 inline void _zoneSetName( tracy::ScopedZone& zone, const char* text )
104 {
105  zone.Name( text, strlen( text ) );
106 }
107 inline void _zoneSetName( tracy::ScopedZone& zone, const std::string& text )
108 {
109  zone.Name( text.c_str(), text.size() );
110 }
111 #endif
112 
114 
115 #ifdef NO_PROFILER
116 #define DtPROFILEzone
117 #define DtPROFILE(name) DtPROFILE_X(name, __LINE__);
118 #define DtPROFILEC(name, color) DtPROFILE_X(name, __LINE__);
119 #define DtPROFILE_SECTION(name) {makVrv::DtProfileSample _profileSample(name);
120 #define DtPROFILEzone DtPROFILE_X(__func__, __LINE__);
121 
122 #define DtProfilerPlot(x,y)
123 
124 #define DtProfilerFrameMark
125 #define DtProfilerThreadName(name)
126 #define DtProfilerPlot(x,y)
127 #define DtProfilerMessage(str, stringLen)
128 #define DtProfilerText(text)
129 #endif
130 
131 #define DtPROFILE_RESTRICTED(name, target) makVrv::DtProfileTarget<target> _profileTarget##line(name);
132 
133 #define DtPROFILE_X(name, line) DtPROFILE_ACTUAL(name, line)
134 #define DtPROFILE_ACTUAL(name, line) makVrv::DtProfileSample _profileSample##line(name);
135 //#define DtPROFILE_FUNCTION(name, func) {makVrv::DtProfileSample _profileSample(name); (func);}
136 #define DtPROFILE_SECTION_END }
137 
138 #define DtPERFORMANCE_STAT(name) DtPERFORMANCE_STAT_X(name, __LINE__)
139 #define DtPERFORMANCE_STAT_X(name, line) DtPERFORMANCE_STAT_ACTUAL(name, line)
140 #define DtPERFORMANCE_STAT_ACTUAL(name, line) makVrv::DtPerfomanceStatSample _performanceStatSample##line(name);
141 
142 
143 // These constants configure DtPROFILE_RESTRICTED
144 //
145 // Define them to boost::true_type to enable profiling of those sections
146 const bool Profile_DtSceneObjectUpdater = false;
148 const bool Profile_DtOsgCullVisitor = false;
149 
150 namespace makVrv
151 {
152  void DT_DLL_VRVUTIL SetThreadName(const char* name);
153 
159  {
160  public:
162  DtProfileSample(const char* name )
163  {
165  }
166 
169  {
171  }
172  };
173 
178  template <bool Enabled>
180  {
181  DtProfileTarget(const char* name) {}
182  };
183 
184  template <>
185  struct DtProfileTarget<true>
186  {
188  DtProfileTarget(const char* name )
189  {
191  }
192 
195  {
197  }
198  };
199 
205  {
206  public:
208  DtPerfomanceStatSample(const char* name )
209  {
211  }
212 
215  {
217  }
218  };
219 }
220 
const bool Profile_DtOsgCullVisitor
Definition: DtProfiler.h:148
#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:179
DtProfileSampleClass is used to start/stop a profiled section It is preferable to use the macro at th...
Definition: DtProfiler.h:204
void _zoneSetName(tracy::ScopedZone &zone, const char *text)
Definition: DtProfiler.h:103
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:162
const bool Profile_DtSurfaceClampingUpdater
Definition: DtProfiler.h:147
~DtPerfomanceStatSample()
DTOR stops profile section.
Definition: DtProfiler.h:214
DtProfileTarget(const char *name)
CTOR starts profile section.
Definition: DtProfiler.h:188
DtProfileSampleClass is used to start/stop a profiled section It is preferable to use the macro at th...
Definition: DtProfiler.h:158
void _zoneSetText(tracy::ScopedZone &zone, const char *text)
Definition: DtProfiler.h:94
Contains DLL export macros.
const bool Profile_DtSceneObjectUpdater
Definition: DtProfiler.h:146
void DT_DLL_VRVUTIL SetThreadName(const char *name)
~DtProfileTarget()
DTOR stops profile section.
Definition: DtProfiler.h:194
static void stopPerformanceStat()
begin stop a profile. This function is thread safe
DtProfileTarget(const char *name)
Definition: DtProfiler.h:181
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:208
~DtProfileSample()
DTOR stops profile section.
Definition: DtProfiler.h:168
static void stopProfile()
begin stop a profile. This function is thread safe

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)