VR-Vantage 2.8 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tracy.hpp
Go to the documentation of this file.
1 #ifndef __TRACY_HPP__
2 #define __TRACY_HPP__
3 
4 #include "common/TracyColor.hpp"
5 #include "common/TracySystem.hpp"
6 
7 #ifndef TRACY_ENABLE
8 
9 #define ZoneNamed(x,y)
10 #define ZoneNamedN(x,y,z)
11 #define ZoneNamedC(x,y,z)
12 #define ZoneNamedNC(x,y,z,w)
13 
14 #define ZoneTransient(x,y)
15 #define ZoneTransientN(x,y,z)
16 
17 #define ZoneScoped
18 #define ZoneScopedN(x)
19 #define ZoneScopedC(x)
20 #define ZoneScopedNC(x,y)
21 
22 #define ZoneText(x,y)
23 #define ZoneTextV(x,y,z)
24 #define ZoneName(x,y)
25 #define ZoneNameV(x,y,z)
26 #define ZoneValue(x)
27 #define ZoneValueV(x,y)
28 
29 #define FrameMark
30 #define FrameMarkNamed(x)
31 #define FrameMarkStart(x)
32 #define FrameMarkEnd(x)
33 
34 #define FrameImage(x,y,z,w,a)
35 
36 #define TracyLockable( type, varname ) type varname;
37 #define TracyLockableN( type, varname, desc ) type varname;
38 #define TracySharedLockable( type, varname ) type varname;
39 #define TracySharedLockableN( type, varname, desc ) type varname;
40 #define LockableBase( type ) type
41 #define SharedLockableBase( type ) type
42 #define LockMark(x) (void)x;
43 #define LockableName(x,y,z);
44 
45 #define TracyPlot(x,y)
46 #define TracyPlotConfig(x,y)
47 
48 #define TracyMessage(x,y)
49 #define TracyMessageL(x)
50 #define TracyMessageC(x,y,z)
51 #define TracyMessageLC(x,y)
52 #define TracyAppInfo(x,y)
53 
54 #define TracyAlloc(x,y)
55 #define TracyFree(x)
56 #define TracySecureAlloc(x,y)
57 #define TracySecureFree(x)
58 
59 #define ZoneNamedS(x,y,z)
60 #define ZoneNamedNS(x,y,z,w)
61 #define ZoneNamedCS(x,y,z,w)
62 #define ZoneNamedNCS(x,y,z,w,a)
63 
64 #define ZoneTransientS(x,y,z)
65 #define ZoneTransientNS(x,y,z,w)
66 
67 #define ZoneScopedS(x)
68 #define ZoneScopedNS(x,y)
69 #define ZoneScopedCS(x,y)
70 #define ZoneScopedNCS(x,y,z)
71 
72 #define TracyAllocS(x,y,z)
73 #define TracyFreeS(x,y)
74 #define TracySecureAllocS(x,y,z)
75 #define TracySecureFreeS(x,y)
76 
77 #define TracyMessageS(x,y,z)
78 #define TracyMessageLS(x,y)
79 #define TracyMessageCS(x,y,z,w)
80 #define TracyMessageLCS(x,y,z)
81 
82 #define TracyParameterRegister(x)
83 #define TracyParameterSetup(x,y,z,w)
84 #define TracyIsConnected false
85 
86 #else
87 
88 #include <string.h>
89 
90 #include "client/TracyLock.hpp"
91 #include "client/TracyProfiler.hpp"
92 #include "client/TracyScoped.hpp"
93 
94 #if defined TRACY_USE_CONSTEXPR
95 #if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK
96 # define ZoneNamed( varname, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active );
97 # define ZoneNamedN( varname, name, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active );
98 # define ZoneNamedC( varname, color, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active );
99 # define ZoneNamedNC( varname, name, color, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active );
100 
101 # define ZoneTransient( varname, active ) tracy::ScopedZone varname( __LINE__, __FILE__, strlen( __FILE__ ), __FUNCTION__, strlen( __FUNCTION__ ), nullptr, 0, TRACY_CALLSTACK, active );
102 # define ZoneTransientN( varname, name, active ) tracy::ScopedZone varname( __LINE__, __FILE__, strlen( __FILE__ ), __FUNCTION__, strlen( __FUNCTION__ ), name, strlen( name ), TRACY_CALLSTACK, active );
103 #else
104 # define ZoneNamed( varname, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
105 # define ZoneNamedN( varname, name, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
106 # define ZoneNamedC( varname, color, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
107 # define ZoneNamedNC( varname, name, color, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
108 
109 # define ZoneTransient( varname, active ) tracy::ScopedZone varname( __LINE__, __FILE__, strlen( __FILE__ ), __FUNCTION__, strlen( __FUNCTION__ ), nullptr, 0, active );
110 # define ZoneTransientN( varname, name, active ) tracy::ScopedZone varname( __LINE__, __FILE__, strlen( __FILE__ ), __FUNCTION__, strlen( __FUNCTION__ ), name, strlen( name ), active );
111 #endif
112 #else
113 #if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK
114 # define ZoneNamed( varname, active ) static tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active );
115 # define ZoneNamedN( varname, name, active ) static tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active );
116 # define ZoneNamedC( varname, color, active ) static tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active );
117 # define ZoneNamedNC( varname, name, color, active ) static tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active );
118 
119 # define ZoneTransient( varname, active ) tracy::ScopedZone varname( __LINE__, __FILE__, strlen( __FILE__ ), __FUNCTION__, strlen( __FUNCTION__ ), nullptr, 0, TRACY_CALLSTACK, active );
120 # define ZoneTransientN( varname, name, active ) tracy::ScopedZone varname( __LINE__, __FILE__, strlen( __FILE__ ), __FUNCTION__, strlen( __FUNCTION__ ), name, strlen( name ), TRACY_CALLSTACK, active );
121 #else
122 # define ZoneNamed( varname, active ) static tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
123 # define ZoneNamedN( varname, name, active ) static tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
124 # define ZoneNamedC( varname, color, active ) static tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
125 # define ZoneNamedNC( varname, name, color, active ) static tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
126 
127 # define ZoneTransient( varname, active ) tracy::ScopedZone varname( __LINE__, __FILE__, strlen( __FILE__ ), __FUNCTION__, strlen( __FUNCTION__ ), nullptr, 0, active );
128 # define ZoneTransientN( varname, name, active ) tracy::ScopedZone varname( __LINE__, __FILE__, strlen( __FILE__ ), __FUNCTION__, strlen( __FUNCTION__ ), name, strlen( name ), active );
129 #endif
130 #endif
131 
132 #define ZoneScoped ZoneNamed( ___tracy_scoped_zone, true )
133 #define ZoneScopedN( name ) ZoneNamedN( ___tracy_scoped_zone, name, true )
134 #define ZoneScopedC( color ) ZoneNamedC( ___tracy_scoped_zone, color, true )
135 #define ZoneScopedNC( name, color ) ZoneNamedNC( ___tracy_scoped_zone, name, color, true )
136 
137 #define ZoneText( txt, size ) ___tracy_scoped_zone.Text( txt, size );
138 #define ZoneTextV( varname, txt, size ) varname.Text( txt, size );
139 #define ZoneName( txt, size ) ___tracy_scoped_zone.Name( txt, size );
140 #define ZoneNameV( varname, txt, size ) varname.Name( txt, size );
141 #define ZoneValue( value ) ___tracy_scoped_zone.Value( value );
142 #define ZoneValueV( varname, value ) varname.Value( value );
143 
144 #define FrameMark tracy::Profiler::SendFrameMark( nullptr );
145 #define FrameMarkNamed( name ) tracy::Profiler::SendFrameMark( name );
146 #define FrameMarkStart( name ) tracy::Profiler::SendFrameMark( name, tracy::QueueType::FrameMarkMsgStart );
147 #define FrameMarkEnd( name ) tracy::Profiler::SendFrameMark( name, tracy::QueueType::FrameMarkMsgEnd );
148 
149 #define FrameImage( image, width, height, offset, flip ) tracy::Profiler::SendFrameImage( image, width, height, offset, flip );
150 
151 #define TracyLockable( type, varname ) tracy::Lockable<type> varname { [] () -> const tracy::SourceLocationData* { static constexpr tracy::SourceLocationData srcloc { nullptr, #type " " #varname, __FILE__, __LINE__, 0 }; return &srcloc; }() };
152 #define TracyLockableN( type, varname, desc ) tracy::Lockable<type> varname { [] () -> const tracy::SourceLocationData* { static constexpr tracy::SourceLocationData srcloc { nullptr, desc, __FILE__, __LINE__, 0 }; return &srcloc; }() };
153 #define TracySharedLockable( type, varname ) tracy::SharedLockable<type> varname { [] () -> const tracy::SourceLocationData* { static constexpr tracy::SourceLocationData srcloc { nullptr, #type " " #varname, __FILE__, __LINE__, 0 }; return &srcloc; }() };
154 #define TracySharedLockableN( type, varname, desc ) tracy::SharedLockable<type> varname { [] () -> const tracy::SourceLocationData* { static constexpr tracy::SourceLocationData srcloc { nullptr, desc, __FILE__, __LINE__, 0 }; return &srcloc; }() };
155 #define LockableBase( type ) tracy::Lockable<type>
156 #define SharedLockableBase( type ) tracy::SharedLockable<type>
157 #define LockMark( varname ) static constexpr tracy::SourceLocationData __tracy_lock_location_##varname { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; varname.Mark( &__tracy_lock_location_##varname );
158 #define LockableName( varname, txt, size ) varname.CustomName( txt, size );
159 
160 #define TracyPlot( name, val ) tracy::Profiler::PlotData( name, val );
161 #define TracyPlotConfig( name, type ) tracy::Profiler::ConfigurePlot( name, type );
162 
163 #define TracyAppInfo( txt, size ) tracy::Profiler::MessageAppInfo( txt, size );
164 
165 #if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK
166 # define TracyMessage( txt, size ) tracy::Profiler::Message( txt, size, TRACY_CALLSTACK );
167 # define TracyMessageL( txt ) tracy::Profiler::Message( txt, TRACY_CALLSTACK );
168 # define TracyMessageC( txt, size, color ) tracy::Profiler::MessageColor( txt, size, color, TRACY_CALLSTACK );
169 # define TracyMessageLC( txt, color ) tracy::Profiler::MessageColor( txt, color, TRACY_CALLSTACK );
170 
171 # define TracyAlloc( ptr, size ) tracy::Profiler::MemAllocCallstack( ptr, size, TRACY_CALLSTACK, false );
172 # define TracyFree( ptr ) tracy::Profiler::MemFreeCallstack( ptr, TRACY_CALLSTACK, false );
173 # define TracySecureAlloc( ptr, size ) tracy::Profiler::MemAllocCallstack( ptr, size, TRACY_CALLSTACK, true );
174 # define TracySecureFree( ptr ) tracy::Profiler::MemFreeCallstack( ptr, TRACY_CALLSTACK, true );
175 #else
176 # define TracyMessage( txt, size ) tracy::Profiler::Message( txt, size, 0 );
177 # define TracyMessageL( txt ) tracy::Profiler::Message( txt, 0 );
178 # define TracyMessageC( txt, size, color ) tracy::Profiler::MessageColor( txt, size, color, 0 );
179 # define TracyMessageLC( txt, color ) tracy::Profiler::MessageColor( txt, color, 0 );
180 
181 # define TracyAlloc( ptr, size ) tracy::Profiler::MemAlloc( ptr, size, false );
182 # define TracyFree( ptr ) tracy::Profiler::MemFree( ptr, false );
183 # define TracySecureAlloc( ptr, size ) tracy::Profiler::MemAlloc( ptr, size, true );
184 # define TracySecureFree( ptr ) tracy::Profiler::MemFree( ptr, true );
185 #endif
186 
187 #ifdef TRACY_HAS_CALLSTACK
188 # define ZoneNamedS( varname, depth, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
189 # define ZoneNamedNS( varname, name, depth, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
190 # define ZoneNamedCS( varname, color, depth, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
191 # define ZoneNamedNCS( varname, name, color, depth, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
192 
193 # define ZoneTransientS( varname, depth, active ) tracy::ScopedZone varname( __LINE__, __FILE__, strlen( __FILE__ ), __FUNCTION__, strlen( __FUNCTION__ ), nullptr, 0, depth, active );
194 # define ZoneTransientNS( varname, name, depth, active ) tracy::ScopedZone varname( __LINE__, __FILE__, strlen( __FILE__ ), __FUNCTION__, strlen( __FUNCTION__ ), name, strlen( name ), depth, active );
195 
196 # define ZoneScopedS( depth ) ZoneNamedS( ___tracy_scoped_zone, depth, true )
197 # define ZoneScopedNS( name, depth ) ZoneNamedNS( ___tracy_scoped_zone, name, depth, true )
198 # define ZoneScopedCS( color, depth ) ZoneNamedCS( ___tracy_scoped_zone, color, depth, true )
199 # define ZoneScopedNCS( name, color, depth ) ZoneNamedNCS( ___tracy_scoped_zone, name, color, depth, true )
200 
201 # define TracyAllocS( ptr, size, depth ) tracy::Profiler::MemAllocCallstack( ptr, size, depth, false );
202 # define TracyFreeS( ptr, depth ) tracy::Profiler::MemFreeCallstack( ptr, depth, false );
203 # define TracySecureAllocS( ptr, size, depth ) tracy::Profiler::MemAllocCallstack( ptr, size, depth, true );
204 # define TracySecureFreeS( ptr, depth ) tracy::Profiler::MemFreeCallstack( ptr, depth, true );
205 
206 # define TracyMessageS( txt, size, depth ) tracy::Profiler::Message( txt, size, depth );
207 # define TracyMessageLS( txt, depth ) tracy::Profiler::Message( txt, depth );
208 # define TracyMessageCS( txt, size, color, depth ) tracy::Profiler::MessageColor( txt, size, color, depth );
209 # define TracyMessageLCS( txt, color, depth ) tracy::Profiler::MessageColor( txt, color, depth );
210 #else
211 # define ZoneNamedS( varname, depth, active ) ZoneNamed( varname, active )
212 # define ZoneNamedNS( varname, name, depth, active ) ZoneNamedN( varname, name, active )
213 # define ZoneNamedCS( varname, color, depth, active ) ZoneNamedC( varname, color, active )
214 # define ZoneNamedNCS( varname, name, color, depth, active ) ZoneNamedNC( varname, name, color, active )
215 
216 # define ZoneTransientS( varname, depth, active ) ZoneTransient( varname, active )
217 # define ZoneTransientNS( varname, name, depth, active ) ZoneTransientN( varname, name, active )
218 
219 # define ZoneScopedS( depth ) ZoneScoped
220 # define ZoneScopedNS( name, depth ) ZoneScopedN( name )
221 # define ZoneScopedCS( color, depth ) ZoneScopedC( color )
222 # define ZoneScopedNCS( name, color, depth ) ZoneScopedNC( name, color )
223 
224 # define TracyAllocS( ptr, size, depth ) TracyAlloc( ptr, size )
225 # define TracyFreeS( ptr, depth ) TracyFree( ptr )
226 # define TracySecureAllocS( ptr, size, depth ) TracySecureAlloc( ptr, size )
227 # define TracySecureFreeS( ptr, depth ) TracySecureFree( ptr )
228 
229 # define TracyMessageS( txt, size, depth ) TracyMessage( txt, size )
230 # define TracyMessageLS( txt, depth ) TracyMessageL( txt )
231 # define TracyMessageCS( txt, size, color, depth ) TracyMessageC( txt, size, color )
232 # define TracyMessageLCS( txt, color, depth ) TracyMessageLC( txt, color )
233 #endif
234 
235 #define TracyParameterRegister( cb ) tracy::Profiler::ParameterRegister( cb );
236 #define TracyParameterSetup( idx, name, isBool, val ) tracy::Profiler::ParameterSetup( idx, name, isBool, val );
237 #define TracyIsConnected tracy::GetProfiler().IsConnected()
238 
239 #endif
240 
241 #endif


Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)