Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1143 lines
48 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Real-Time Hierarchical Telemetry Profiling
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef VPROF_TELEMETRY_H
  8. #define VPROF_TELEMETRY_H
  9. #if !defined( MAKE_VPC )
  10. #if !defined( RAD_TELEMETRY_DISABLED ) && ( defined( IS_WINDOWS_PC ) || defined( _LINUX ) )
  11. // Rad Telemetry profiling is enabled on Win32 and Win64.
  12. //#define RAD_TELEMETRY_ENABLED
  13. #endif
  14. #ifdef WIN32
  15. #define __PRETTY_FUNCTION__ __FUNCSIG__
  16. #endif
  17. #endif // !defined( MAKE_VPC )
  18. // Slot used by TM_ZONE_PLOT
  19. enum TelemetryZonePlotSlot_t
  20. {
  21. TELEMETRY_ZONE_PLOT_SLOT_1,
  22. TELEMETRY_ZONE_PLOT_SLOT_2,
  23. TELEMETRY_ZONE_PLOT_SLOT_3,
  24. TELEMETRY_ZONE_PLOT_SLOT_4,
  25. TELEMETRY_ZONE_PLOT_SLOT_5,
  26. TELEMETRY_ZONE_PLOT_SLOT_6,
  27. TELEMETRY_ZONE_PLOT_SLOT_7,
  28. TELEMETRY_ZONE_PLOT_SLOT_8,
  29. TELEMETRY_ZONE_PLOT_SLOT_9,
  30. TELEMETRY_ZONE_PLOT_SLOT_10,
  31. TELEMETRY_ZONE_PLOT_SLOT_11,
  32. TELEMETRY_ZONE_PLOT_SLOT_12,
  33. TELEMETRY_ZONE_PLOT_SLOT_13,
  34. TELEMETRY_ZONE_PLOT_SLOT_14,
  35. TELEMETRY_ZONE_PLOT_SLOT_15,
  36. TELEMETRY_ZONE_PLOT_SLOT_16,
  37. TELEMETRY_ZONE_PLOT_SLOT_MAX
  38. };
  39. #if !defined( RAD_TELEMETRY_ENABLED )
  40. //
  41. // If Telemetry isn't enabled, then kill all the tmZone() macros, etc.
  42. //
  43. #define NTELEMETRY 1
  44. #include "../../thirdparty/telemetry/include/telemetry.h"
  45. // Different versions of radbase.h define RADCOPYRIGHT to different values. So undef that here.
  46. #undef RADCOPYRIGHT
  47. inline void TelemetryTick() {}
  48. inline void TelemetrySetLevel( unsigned int Level ) {}
  49. #define TELEMETRY_REQUIRED( tmRequiredCode ) //a basic wrapper to only enable code if telemetry is present
  50. #define TELEMETRY_REQUIRED_REPLACE( tmRequiredCode, replacementCode ) replacementCode //in case you need to replace the code with something specific if telemetry isn't present
  51. // need some of the types even if we aren't using Telemetry
  52. #include "../../thirdparty/telemetry/include/tmtypes.h"
  53. #else
  54. //
  55. // Telemetry is enabled. Include the telemetry header.
  56. //
  57. #include "../../thirdparty/telemetry/include/telemetry.h"
  58. // Different versions of radbase.h define RADCOPYRIGHT to different values. So undef that here.
  59. #undef RADCOPYRIGHT
  60. PLATFORM_INTERFACE void TelemetryTick();
  61. PLATFORM_INTERFACE void TelemetrySetLevel( unsigned int Level );
  62. struct TelemetryZonePlotData
  63. {
  64. const char* m_Name;
  65. TmU64 m_CurrFrameTime;
  66. };
  67. struct TelemetryData
  68. {
  69. HTELEMETRY tmContext[32];
  70. float flRDTSCToMilliSeconds; // Conversion from tmFastTime() (rdtsc) to milliseconds.
  71. uint32 FrameCount; // Count of frames to capture before turning off.
  72. char ServerAddress[128]; // Server name to connect to.
  73. uint32 ZoneFilterVal; // tmZoneFiltered default filtered value (in MicroSeconds)
  74. int playbacktick; // GetPlaybackTick() value from demo file (or 0 if not playing a demo).
  75. float dotatime; // CDOTAGamerules::GetDOTATime()
  76. uint32 DemoTickStart; // Start telemetry on demo tick #
  77. uint32 DemoTickEnd; // End telemetry on demo tick #
  78. uint32 Level; // Current Telemetry level (Use TelemetrySetLevel to modify)
  79. TelemetryZonePlotData m_ZonePlot[TELEMETRY_ZONE_PLOT_SLOT_MAX]; // Data used to plot a zone's duration when using TM_ZONE_PLOT
  80. };
  81. PLATFORM_INTERFACE TelemetryData g_Telemetry;
  82. #define TELEMETRY_REQUIRED( tmRequiredCode ) tmRequiredCode //a basic wrapper to only enable code if telemetry is present
  83. #define TELEMETRY_REQUIRED_REPLACE( tmRequiredCode, replacementCode ) tmRequiredCode //in case you need to replace the code with something specific if telemetry isn't present
  84. #endif // RAD_TELEMETRY_ENABLED
  85. #define TELEMETRY_ERROR_BUILD_DISABLED TELEMETRY_REQUIRED_REPLACE( TMERR_DISABLED, 0x0001 )
  86. #define TELEMETRY_ERROR_DISCONNECTED TELEMETRY_REQUIRED_REPLACE( TMCS_DISCONNECTED, 0 )
  87. #define TELEMETRY_LEVEL0 TELEMETRY_REQUIRED_REPLACE( g_Telemetry.tmContext[0], 0 ) // high level tmZone()
  88. #define TELEMETRY_LEVEL1 TELEMETRY_REQUIRED_REPLACE( g_Telemetry.tmContext[1], 0 ) // lower level tmZone(), tmZoneFiltered()
  89. #define TELEMETRY_LEVEL2 TELEMETRY_REQUIRED_REPLACE( g_Telemetry.tmContext[2], 0 ) // VPROF_0
  90. #define TELEMETRY_LEVEL3 TELEMETRY_REQUIRED_REPLACE( g_Telemetry.tmContext[3], 0 ) // VPROF_1
  91. #define TELEMETRY_LEVEL4 TELEMETRY_REQUIRED_REPLACE( g_Telemetry.tmContext[4], 0 ) // VPROF_2
  92. #define TELEMETRY_LEVEL5 TELEMETRY_REQUIRED_REPLACE( g_Telemetry.tmContext[5], 0 ) // VPROF_3
  93. #define TELEMETRY_LEVEL6 TELEMETRY_REQUIRED_REPLACE( g_Telemetry.tmContext[6], 0 ) // VPROF_4
  94. //__rdtsc()
  95. #define TM_FAST_TIME() TELEMETRY_REQUIRED_REPLACE( tmFastTime(), 0 )
  96. //int RADEXPLINK tmLoadTelemetry( int const kUseCheckedDLL );
  97. //
  98. //Description
  99. // On dynamic library platforms, this function loads the Telemetry DLL (or shared library) and then hooks up all of the dynamic function pointers.
  100. //Parameters
  101. // kUseCheckedDLL [in] set to 0 if you want to use the release mode DLL or 1 if you want to use the checked DLL. The checked DLL is compiled with optimizations but does extra run time checks and reporting.
  102. #define TM_LOAD_TELEMETRY(kUseCheckedDll) TELEMETRY_REQUIRED_REPLACE( tmLoadTelemetry(kUseCheckedDll), 0 )
  103. //TmErrorCode tmStartup( );
  104. //
  105. //Description
  106. // Starts up all of Telemetry.
  107. #define TM_STARTUP() TELEMETRY_REQUIRED_REPLACE( tmStartup(), TELEMETRY_ERROR_BUILD_DISABLED )
  108. //void tmShutdown( );
  109. //
  110. //Description
  111. // Shuts down all of Telemetry.
  112. #define TM_SHUTDOWN() TELEMETRY_REQUIRED( tmShutdown() )
  113. //TmErrorCode tmInitializeContext( HTELEMETRY * pcx,void * pArena,TmU32 const kArenaSize );
  114. //
  115. //Description
  116. // Initializes a context.
  117. //
  118. //Parameters
  119. // pcx [out] pointer to a TmHandle in which to store a handle to the initialized context
  120. // pArena [in] pointer to a memory buffer for use by Telemetry to create the context. Applications should never free or modify this memory unless tmShutdownContext has been called!
  121. // kArenaSize [in] size of the memory buffer pointed to by pArena. You want this large enough so that Telemetry never stalls trying to send over the network, but not so large that it takes up too much memory from your app. A good initial value is 1MB.
  122. #define TM_INITIALIZE_CONTEXT( pContext, pArena, kArenaSize ) TELEMETRY_REQUIRED_REPLACE( tmInitializeContext( pContext, pArena, kArenaSize ), TELEMETRY_ERROR_BUILD_DISABLED )
  123. //void tmZoneFiltered( HTELEMETRY cx,TmU64 const kThreshold,TmU32 const kFlags,char const * kpFormat,... );
  124. //
  125. //Description
  126. // Identical to tmZone however also allows specification of threshold duration.
  127. //
  128. //Parameters
  129. // cx [in] handle to a valid Telemetry context
  130. // kThreshold [in] microseconds that the zone must span before being sent to server.
  131. // kFlags [in] flags for the zone (same as those passed to tmEnter.
  132. // kpFormat [in] name of the zone (same as those passed to tmEnter. This may contain printf-style format specifiers.
  133. #define TM_ZONE_FILTERED( context, kThreshold, kFlags, kpFormat, ... ) TELEMETRY_REQUIRED( tmZoneFiltered( context, kThreshold, kFlags, kpFormat, ##__VA_ARGS__ ) )
  134. //void tmZone( HTELEMETRY cx,TmU32 const kFlags,char const * kpFormat,... );
  135. //
  136. //Description
  137. // Helper macro in C++ that creates an anonymous local object that automatically calls tmEnter and then tmLeave when exiting scope.
  138. //
  139. //Parameters
  140. // cx [in] handle to a valid Telemetry context
  141. // kFlags [in] flags for the zone (same as those passed to tmEnter
  142. // kpFormat [in] name of the zone (same as those passed to tmEnter. This may contain printf-style format specifiers.
  143. #define TM_ZONE( context, kFlags, kpFormat, ... ) TELEMETRY_REQUIRED( tmZone( context, kFlags, kpFormat, ##__VA_ARGS__ ) )
  144. //Standardized zones
  145. #define TM_ZONE_DEFAULT( context ) TM_ZONE( context, TMZF_NONE, __FUNCTION__ )
  146. #define TM_ZONE_IDLE( context ) TM_ZONE( context, TMZF_IDLE, __FUNCTION__ )
  147. #define TM_ZONE_STALL( context ) TM_ZONE( context, TMZF_STALL, __FUNCTION__ )
  148. //TmErrorCode tmCheckVersion( HTELEMETRY cx, TmU32 const major, TmU32 const minor, TmU32 const build, TmU32 const cust );
  149. //
  150. //could not find documentation
  151. #define TM_CHECK_VERSION( context, major, minor, build, cust ) TELEMETRY_REQUIRED_REPLACE( tmCheckVersion( context, major, minor, build, cust ), TELEMETRY_ERROR_BUILD_DISABLED )
  152. //TmErrorCode tmListenIPC( HTELEMETRY cx, char const *name );
  153. //
  154. //could not find documentation
  155. #define TM_LISTEN_IPC( context, name ) TELEMETRY_REQUIRED_REPLACE( tmListenIPC( context, name ), TELEMETRY_ERROR_BUILD_DISABLED )
  156. //void tmUpdateSymbolData( HTELEMETRY cx );
  157. //
  158. //Description
  159. // Tells Telemetry to rescan loaded modules for symbol database information.
  160. //
  161. //Parameters
  162. // cx [in] a valid context
  163. #define TM_UPDATE_SYMBOL_DATA( context ) TELEMETRY_REQUIRED( tmUpdateSymbolData( context ) )
  164. //TmErrorCode tmGetSessionName( HTELEMETRY cx,char * dst,int const kDstSize );
  165. //
  166. //Description
  167. // Gets the name of the current session as determined by the server.
  168. //
  169. //Parameters
  170. // cx [in] a valid context
  171. // dst [in] pointer to buffer in which to copy the name
  172. // kDstSize [in] size of dst
  173. #define TM_GET_SESSION_NAME( context, dst, kDstSize ) TELEMETRY_REQUIRED_REPLACE( tmGetSessionName( context, dst, kDstSize ), TELEMETRY_ERROR_BUILD_DISABLED )
  174. //void tmUnwindToDebugZoneLevel( HTELEMETRY cx,int const kLevel );
  175. //
  176. //Description
  177. // Unwinds the current thread's zone stack back to the given level.
  178. //
  179. //Parameters
  180. // cx [in] a valid context
  181. // kLevel [in] an arbitrary constant that was previously set using tmSetDebugZoneLevel
  182. #define TM_UNWIND_TO_DEBUG_ZONE_LEVEL( context, kLevel ) TELEMETRY_REQUIRED( tmUnwindToDebugZoneLevel( context, kLevel ) )
  183. //void tmSetDebugZoneLevel( HTELEMETRY cx,int const kLevel );
  184. //
  185. //Description
  186. // Set the Telemetry debug zone level.
  187. //
  188. //Parameters
  189. // cx [in] a valid context
  190. // kLevel [in] an arbitrary constant used to differentiate this zone level from another
  191. #define TM_SET_DEBUG_ZONE_LEVEL( context, kLevel ) TELEMETRY_REQUIRED( tmSetDebugZoneLevel( context, kLevel ) )
  192. //void tmCheckDebugZoneLevel( HTELEMETRY cx,int const kLevel );
  193. //
  194. //Description
  195. // Check the current Telemetry debug zone level.
  196. //
  197. //Parameters
  198. // cx [in] a valid context
  199. // kLevel [in] an arbitrary constant that was previously set using tmSetDebugZoneLevel
  200. #define TM_CHECK_DEBUG_ZONE_LEVEL( context, kLevel ) TELEMETRY_REQUIRED( tmCheckDebugZoneLevel( context, kLevel ) )
  201. //int tmGetCallStack( HTELEMETRY cx,TmCallStack * dst );
  202. //
  203. //Description
  204. // Retrieves the callstack for the current thread.
  205. //
  206. //Parameters
  207. // cx [in] a valid context
  208. // dst [in] TmCallStack structure in which to store the callstack information
  209. #define TM_GET_CALL_STACK( context, TmCallStack_Ptr ) TELEMETRY_REQUIRED_REPLACE( tmGetCallStack( context, TmCallStack_Ptr ), 0 )
  210. //int tmSendCallStack( HTELEMETRY cx,TmCallStack const * kpCallStack );
  211. //
  212. //Description
  213. // Sends the current callstack to the server so that later references with string format specifiers are up to date.
  214. //
  215. //Parameters
  216. // cx [in] a valid context
  217. // kpCallStack [in] pointer to a pre-existing callstack or 0 if it should use the current callstack
  218. #define TM_SEND_CALL_STACK( context, TmCallStack_Ptr ) TELEMETRY_REQUIRED_REPLACE( tmSendCallStack( context, TmCallStack_Ptr ), 0 )
  219. //TmErrorCode tmGetLastError( HTELEMETRY cx );
  220. //
  221. //Description
  222. // Returns and clears the current error condition for the given context.
  223. //
  224. //Parameters
  225. // cx [in] handle to a valid Telemetry context
  226. #define TM_GET_LAST_ERROR( context ) TELEMETRY_REQUIRED_REPLACE( tmGetLastError( context ), TELEMETRY_ERROR_BUILD_DISABLED )
  227. //void tmShutdownContext( HTELEMETRY cx );
  228. //
  229. //Description
  230. // Shuts down the given context.
  231. //
  232. //Parameters
  233. // cx [in] handle to a valid context
  234. #define TM_SHUTDOWN_CONTEXT( context ) TELEMETRY_REQUIRED( tmShutdownContext( context ) )
  235. //TmU64 tmGetAccumulationStart( HTELEMETRY cx );
  236. //
  237. //Description
  238. // Gets the start time for a set of accumulation zones.
  239. //
  240. //Parameters
  241. // cx [in] handle to a telemetry context
  242. //
  243. //Return value
  244. // return [out] start time for use with tmEmitAccumulationZone.
  245. #define TM_GET_ACCUMULATION_START( context ) TELEMETRY_REQUIRED_REPLACE( tmGetAccumulationStart( context ), 0 )
  246. //TmU64 tmGetLastContextSwitchTime( HTELEMETRY cx );
  247. //
  248. //Description
  249. // Returns the time of the last received context switch event.
  250. //
  251. //Parameters
  252. // cx [in] handle to a valid Telemetry context
  253. //
  254. //Return value
  255. // return [out] the time of the last received context switch event, or 0 on failure (e.g. invalid context, context switches disabled, etc.)
  256. #define TM_GET_LAST_CONTEXT_SWITCH_TIME( context ) TELEMETRY_REQUIRED_REPLACE( tmGetLastContextSwitchTime( context ), 0 )
  257. //void tmEnterAccumulationZone( HTELEMETRY cx,TmI64 * zone_variable );
  258. //
  259. //Description
  260. // Updates a zone variable passed to tmEmitAccumulationZone later.
  261. //
  262. //Parameters
  263. // cx [in] handle to a telemetry context
  264. // zone_variable [in] zone_variable to update
  265. #define TM_ENTER_ACCUMULATION_ZONE( context, zone_variable ) TELEMETRY_REQUIRED( tmEnterAccumulationZone( context, zone_variable ) )
  266. //void tmLeaveAccumulationZone( HTELEMETRY cx,TmI64 * zone_variable );
  267. //
  268. //Description
  269. // Updates a zone variable passed to tmEmitAccumulationZone later.
  270. //
  271. //Parameters
  272. // cx [in] handle to a telemetry context
  273. // zone_variable [in] zone_variable to update
  274. #define TM_LEAVE_ACCUMULATION_ZONE( context, zone_variable ) TELEMETRY_REQUIRED( tmLeaveAccumulationZone( context, zone_variable ) )
  275. //void tmGetFormatCode( TmU32* pCode, char const * kpFmt );
  276. //
  277. //could not find documentation
  278. #define TM_GET_FORMAT_CODE( context, pCode, kpFmt ) TELEMETRY_REQUIRED( tmGetFormatCode( context, pCode, kpFmt ) )
  279. //char const * tmDynamicString( HTELEMETRY cx,char const * kpString );
  280. //
  281. //Description
  282. // Returns an opaque string identifier usable by Telemetry that is a copy of the kpString parameter.
  283. //
  284. //Parameters
  285. // cx [in] handle to a valid Telemetry context
  286. // kpString [in] string to copy
  287. #define TM_DYNAMIC_STRING( context, kpString ) TELEMETRY_REQUIRED_REPLACE( tmDynamicString( context, kpString ), NULL )
  288. //void tmClearStaticString( HTELEMETRY cx,char const * kpString );
  289. //
  290. //Description
  291. // Marks the given string pointer as 'changed', forcing Telemetry to resend its contents.
  292. //
  293. //Parameters
  294. // cx [in] handle to a valid Telemetry context
  295. // kpString [in] string to reset
  296. #define TM_CLEAR_STATIC_STRING( context, kpString ) TELEMETRY_REQUIRED( tmClearStaticString( context, kpString ) )
  297. //void tmEnable( HTELEMETRY cx,TmOption const kOption,int const kValue );
  298. //
  299. //Description
  300. // Enables or disables a specific Telemetry option.
  301. //
  302. //Parameters
  303. // cx [in] handle to a valid Telemetry context
  304. // kOption [in] the option to modify. One of the TmOption constants.
  305. // kValue [in] the new value for the option. Must be 0 (disable) or 1 (enable).
  306. #define TM_ENABLE( context, kOption, kValue ) TELEMETRY_REQUIRED( tmEnable( context, kOption, kValue ) )
  307. //int tmIsEnabled( HTELEMETRY cx,TmOption const kOption );
  308. //
  309. //Description
  310. // Inspects the state of a Telemetry option.
  311. //
  312. //Parameters
  313. // cx [in] handle to a valid Telemetry context
  314. // kOption [in] the option to inspect. Must be one of the TmOption constants.
  315. //
  316. //Return value
  317. // return [out] 1 if the option is enabled, 0 if not enabled. In case of error, 0 is enabled and last error is set.
  318. #define TM_IS_ENABLED( context, kOption ) TELEMETRY_REQUIRED_REPLACE( tmIsEnabled( context, kOption ), 0 )
  319. //void tmSetParameter( HTELEMETRY cx,TmParameter const kParameter,void const * kpValue );
  320. //
  321. //Description
  322. // Sets a Telemetry parameter.
  323. //
  324. //Parameters
  325. // cx [in] a valid context
  326. // kParameter [in] TmParameter constant
  327. // kpValue [in] pointer to value of the parameter. This varies depending on the value.
  328. #define TM_SET_PARAMETER( context, kParameter, kpValue ) TELEMETRY_REQUIRED( tmSetParameter( context, kParameter, kpValue ) )
  329. //TmErrorCode tmOpen( HTELEMETRY cx,char const * kpAppName,char const * kpBuildInfo,char const * kpServerAddress,TmConnectionType const kConnection,TmU16 const kServerPort,TmU32 const kFlags,int const kTimeoutMS );
  330. //
  331. //Description
  332. // Starts a Telemetry context and attempts to connect to a Telemetry server.
  333. //
  334. //Parameters
  335. // cx [in] handle to a valid Telemetry context
  336. // kpAppName [in] name of the application. NOTE: This MUST be alphanumeric only, e.g. "Game234", no spaces, special characters, etc. are allowed.
  337. // kpBuildInfo [in] information about the application. Used to annotate this Telemetry session. This information will show up when connecting to the server later to examine this particular run. Common uses include build numbers, compiled options, etc.
  338. // kpServerAddress [in] name or IP address of the Telemetry server to connect to
  339. // kConnection [in] type of connection to establish. Currently only TMCT_TCP is supported.
  340. // kServerPort [in] port to connect to. Specify 0 or TELEMETRY_DEFAULT_PORT for the default port.
  341. // kFlags [in] bitwise OR of TmOpenFlag flags
  342. // kTimeoutMS [in] duration, in milliseconds, to wait for a connection to the Telemetry server. Specify -1 to wait indefinitely.
  343. //
  344. //Return value
  345. // return [out] TM_OK on success, or on error one of the following: TMERR_INVALID_PARAM, TMERR_INVALID_CONTEXT, TMERR_UNKNOWN_NETWORK.
  346. #define TM_OPEN( context, kpAppName, kpBuildInfo, kpServerAddress, kConnection, kServerPort, kFlags, kTimeoutMS ) TELEMETRY_REQUIRED_REPLACE( tmOpen( context, kpAppName, kpBuildInfo, kpServerAddress, kConnection, kServerPort, kFlags, kTimeoutMS ), TELEMETRY_ERROR_BUILD_DISABLED )
  347. //void tmClose( HTELEMETRY cx );
  348. //
  349. //Description
  350. // Closes a context previously opened with tmOpen.
  351. //
  352. //Parameters
  353. // cx [in] handle to a valid and open Telemetry context
  354. #define TM_CLOSE( context ) TELEMETRY_REQUIRED( tmClose( context ) )
  355. //void tmTick( HTELEMETRY cx );
  356. //
  357. //Description
  358. // "Ticks" the Telemetry context, i.e. signifies the end of a frame of execution so that Telemetry can perform internal processing and send data to the Telemetry server.
  359. //
  360. //Parameters
  361. // cx [in] handle to a valid and open Telemetry context
  362. #define TM_TICK( context ) TELEMETRY_REQUIRED( tmTick( context ) )
  363. //void tmFlush( HTELEMETRY cx );
  364. //
  365. //cannot find documentation
  366. #define TM_FLUSH( context ) TELEMETRY_REQUIRED( tmFlush( context ) )
  367. //void tmPause( HTELEMETRY cx,int const kPause );
  368. //
  369. //Description
  370. // Pauses/unpauses Telemetry capture.
  371. //
  372. //Parameters
  373. // cx [in] handle to a valid Telemetry context
  374. // kPause [in] 1 to pause, 0 to unpause
  375. #define TM_PAUSE( context, kPause ) TELEMETRY_REQUIRED( tmPause( context, kPause ) )
  376. //int tmIsPaused( HTELEMETRY cx );
  377. //
  378. //cannot find documentation. Presumably returns 1 if paused, 0 if not
  379. #define TM_IS_PAUSED( context ) TELEMETRY_REQUIRED_REPLACE( tmIsPaused( context ), 0 )
  380. //TmConnectionStatus tmGetConnectionStatus( HTELEMETRY cx );
  381. //
  382. //Description
  383. // Get the current connection status.
  384. //
  385. //Parameters
  386. // cx [in] handle to a valid Telemetry context
  387. //
  388. //Return value
  389. // return [out] a TmConnectionStatus constant. On error returns TMCS_DISCONNECTED and sets the context's last error.
  390. #define TM_GET_CONNECTION_STATUS( context ) TELEMETRY_REQUIRED_REPLACE( tmGetConnectionStatus( context ), TELEMETRY_ERROR_DISCONNECTED )
  391. //void tmFree( HTELEMETRY cx,void const * kpPtr );
  392. //
  393. //Description
  394. // Notify Telemetry that memory has been freed.
  395. //
  396. //Parameters
  397. // cx [in] handle to a valid Telemetry context
  398. // kpPtr [in] address of the old memory block previously passed to a tmAlloc call
  399. #define TM_FREE( context, kpPtr ) TELEMETRY_REQUIRED( tmFree( context, kpPtr ) )
  400. //TmI32 tmGetStati( HTELEMETRY cx,TmStat const kStat );
  401. //
  402. //Description
  403. // Retrieves internal Telemetry statistics.
  404. //
  405. //Parameters
  406. // cx [in] handle to a valid Telemetry context
  407. // kStat [in] the TmStat to retrieve
  408. //
  409. //Return value
  410. // return [out] the value of the indicated internal statistic. On error returns 0 and sets last error.
  411. #define TM_GET_STAT_I( context, kStat ) TELEMETRY_REQUIRED_REPLACE( tmGetStati( context, kStat ), 0 )
  412. //void tmLeave( HTELEMETRY cx );
  413. //
  414. //Description
  415. // Notify Telemetry that a zone is being left.
  416. //
  417. //Parameters
  418. // cx [in] handle to a valid Telemetry context
  419. #define TM_LEAVE( context ) TELEMETRY_REQUIRED( tmLeave( context ) )
  420. //void tmLeaveEx( HTELEMETRY cx,TmU64 const kMatchId,TmU32 const kThreadId,char const * kpFilename,int const kLine );
  421. //
  422. //Description
  423. // Notify Telemetry that a zone is being left.
  424. //
  425. //Parameters
  426. // cx [in] handle to a valid Telemetry context
  427. // kMatchId [in] match id returned by tmEnterEx, used for Zones: Runtime Zone Filtering by Duration . Pass 0 if you're not filtering.
  428. // kThreadId [in] thread id for this zone. Pass 0 for 'current thread'.
  429. // kpFilename [in] name of the file
  430. // kLine [in] line number for the leave
  431. #define TM_LEAVE_EX( context, kMatchId, kThreadId, kpFilename, kLine ) TELEMETRY_REQUIRED( tmLeaveEx( context, kMatchId, kThreadId, kpFilename, kLine ) )
  432. //void tmTryLock( HTELEMETRY cx,void const * kPtr,char const * kpLockName,... );
  433. //
  434. //Description
  435. // Notify Telemetry that an attempt to grab a lock is beginning.
  436. //
  437. //Parameters
  438. // cx [in] handle to a valid Telemetry context
  439. // kPtr [in] pointer to the item being locked
  440. // kpLockName [in] description of this lock attempt. This may contain printf-style format specifiers.
  441. #define TM_TRY_LOCK( context, kPtr, kpLockName, ... ) TELEMETRY_REQUIRED( tmTryLock( context, kPtr, kpLockName, ##__VA_ARGS__ ) )
  442. //void tmTryLockEx( HTELEMETRY cx,TmU64 * matcher,TmU64 const kThreshold,char const * kpFileName,int const kLine,void const * kPtr,char const * kpLockName,... );
  443. //
  444. //Description
  445. // Same as tmTryLock, but also specifying file and line information.
  446. //
  447. //Parameters
  448. // cx [in] handle to a valid Telemetry context
  449. // matcher [in] reference in which to store a match ID used for later filtering by duration
  450. // kpFileName [in] pointer to filename
  451. // kLine [in] line number
  452. // kPtr [in] pointer to the item being locked
  453. // kpLockName [in] description of this lock attempt. This may contain printf-style format specifiers.
  454. #define TM_TRY_LOCK_EX( context, matcher, kThreshold, kpFileName, kLine, kPtr, kpLockName, ... ) TELEMETRY_REQUIRED( tmTryLockEx( context, matcher, kThreshold, kpFileName, kLine, kPtr, kpLockName, ##__VA_ARGS__ ) )
  455. //void tmEndTryLock( HTELEMETRY cx,void const * kPtr,TmLockResult const kResult );
  456. //
  457. //Description
  458. // Specify the result of a lock attempt previously started with tmTryLock.
  459. //
  460. //Parameters
  461. // cx [in] handle to a valid Telemetry context
  462. // kPtr [in] pointer for the object (mutex, etc.) being locked
  463. // kResult [in] the result of the lock attempt, one of TmLockResult.
  464. #define TM_END_TRY_LOCK( context, kPtr, kResult ) TELEMETRY_REQUIRED( tmEndTryLock( context, kPtr, kResult ) )
  465. //void tmEndTryLockEx( HTELEMETRY cx,TmU64 const kMatchId,char const * kpFileName,int const kLine,void const * kPtr,TmLockResult const kResult );
  466. //
  467. //Description
  468. // Specify the result of a lock attempt previously started with tmTryLock, but also with file and line information.
  469. //
  470. //Parameters
  471. // cx [in] handle to a valid Telemetry context
  472. // kMatchId [in] match id returned from tmTryLockEx
  473. // kpFileName [in] pointer to filename
  474. // kLine [in] line number
  475. // kPtr [in] pointer for the object (mutex, etc.) being locked
  476. // kResult [in] the result of the lock attempt, one of TmLockResult.
  477. #define TM_END_TRY_LOCK_EX( context, kMatchId, kpFileName, kLine, kPtr, kResult ) TELEMETRY_REQUIRED( tmEndTryLockEx( context, kMatchId, kpFileName, kLine, kPtr, kResult ) )
  478. //void tmBeginTimeSpan( HTELEMETRY cx,TmU64 const kId,TmU32 const kFlags,char const * kpNameFormat,... );
  479. //
  480. //Description
  481. // Start the beginning of a timespan.
  482. //
  483. //Parameters
  484. // cx [in] handle to a valid Telemetry context
  485. // kId [in] a user defined identifier for the timespan. Should be > 0.
  486. // kFlags [in] flags for the timespan. Reserved, must be 0.
  487. // kpNameFormat [in] information about this timespan. This may contain printf-style format specifiers.
  488. #define TM_BEGIN_TIME_SPAN( context, kId, kFlags, kpNameFormat, ... ) TELEMETRY_REQUIRED( tmBeginTimeSpan( context, kId, kFlags, kpNameFormat, ##__VA_ARGS__ ) )
  489. //void tmEndTimeSpan( HTELEMETRY cx,TmU64 const kId,TmU32 const kFlags,char const * kpNameFormat,... );
  490. //
  491. //Description
  492. // Mark the end a timespan.
  493. //
  494. //Parameters
  495. // cx [in] handle to a valid Telemetry context
  496. // kId [in] a user defined identifier for the timespan. Should be the same as the identifier passed to tmBeginTimeSpan.
  497. // kFlags [in] flags for the timespan. Reserved, must be 0.
  498. // kpNameFormat [in] information about this timespan. This may contain printf-style format specifiers.
  499. #define TM_END_TIME_SPAN( context, kId, kFlags, kpNameFormat, ... ) TELEMETRY_REQUIRED( tmEndTimeSpan( context, kId, kFlags, kpNameFormat, ##__VA_ARGS__ ) )
  500. //void tmBeginTimeSpanAt( HTELEMETRY cx,TmU64 const kId,TmU32 const kFlags,TmU64 const kTimeStamp,char const * kpNameFormat,... );
  501. //
  502. //Description
  503. // Start the beginning of a timespan but at an explicit time.
  504. //
  505. //Parameters
  506. // cx [in] handle to a valid Telemetry context
  507. // kId [in] a user defined identifier for the timespan. Should be > 0.
  508. // kFlags [in] flags for the timespan. Reserved, must be 0.
  509. // kTimeStamp [in] explicit timestamp (e.g. from tmFastTime)
  510. // kpNameFormat [in] information about this timespan. This may contain printf-style format specifiers.
  511. #define TM_BEGIN_TIME_SPAN_AT( context, kId, kFlags, kTimeStamp, kpNameFormat, ... ) TELEMETRY_REQUIRED( tmBeginTimeSpanAt( context, kId, kFlags, kTimeStamp, kpNameFormat, ##__VA_ARGS__ ) )
  512. //void tmEndTimeSpanAt( HTELEMETRY cx,TmU64 const kId,TmU32 const kFlags,TmU64 const kTimeStamp,char const * kpNameFormat,... );
  513. //
  514. //Description
  515. // Mark the end a timespan, but with an explicit timestamp.
  516. //
  517. //Parameters
  518. // cx [in] handle to a valid Telemetry context
  519. // kId [in] a user defined identifier for the timespan. Should be the same as the identifier passed to tmBeginTimeSpan.
  520. // kFlags [in] flags for the timespan. Reserved, must be 0.
  521. // kTimeStamp [in] a user specified timestamp (e.g. from tmFastTime.
  522. // kpNameFormat [in] information about this timespan. This may contain printf-style format specifiers.
  523. #define TM_END_TIME_SPAN_AT( context, kId, kFlags, kTimeStamp, kpNameFormat, ... ) TELEMETRY_REQUIRED( tmEndTimeSpanAt( context, kId, kFlags, kTimeStamp, kpNameFormat, ##__VA_ARGS__ ) )
  524. //void tmSignalLockCount( HTELEMETRY cx,void const * kPtr,TmU32 const kCount,char const * kpDescription,... );
  525. //
  526. //Description
  527. // Signal that a semaphore's lock count has been incremented.
  528. //
  529. //Parameters
  530. // cx [in] handle to a valid Telemetry context
  531. // kPtr [in] pointer to the being whose count is being incremented (e.g. HANDLE)
  532. // kCount [in] count value
  533. // kpDescription [in] description of the event. This may contain printf-style format specifiers.
  534. #define TM_SIGNAL_LOCK_COUNT( context, kPtr, kCount, kpDescription, ... ) TELEMETRY_REQUIRED( tmSignalLockCount( context, kPtr, kCount, kpDescription, ##__VA_ARGS__ ) )
  535. //void tmSetLockState( HTELEMETRY cx,void const * kPtr,TmLockState const kState,char const * kpDescription,... );
  536. //
  537. //Description
  538. // Sets the state of a lock (mutex, critical section, semaphore, etc.)
  539. //
  540. //Parameters
  541. // cx [in] handle to a valid Telemetry context
  542. // kPtr [in] identifier for the lock, typically its address or HANDLE
  543. // kState [in] new state of the lock
  544. // kpDescription [in] description of the event. This may contain printf-style format specifiers.
  545. #define TM_SET_LOCK_STATE( context, kPtr, kState, kpDescription, ... ) TELEMETRY_REQUIRED( tmSetLockState( context, kPtr, kState, kpDescription, ##__VA_ARGS__ ) )
  546. //void tmSetLockStateEx( HTELEMETRY cx,char const * kpFilename,int const kLine,void const * kPtr,TmLockState const kState );
  547. //
  548. //Description
  549. // Set the state of a lock but with explicit file and line information.
  550. //
  551. //Parameters
  552. // cx [in] handle to a valid Telemetry context
  553. // kpFilename [in] filename where the state change occurs
  554. // kLine [in] line number of the state change
  555. // kPtr [in] identifier for the lock, typically its address or HANDLE
  556. // kState [in] new state of the lock
  557. // kpDescription [in] description of the event. This may contain printf-style format specifiers.
  558. #define TM_SET_LOCK_STATE_EX( context, kpFileName, kLine, kPtr, kState, kpDescription, ... ) TELEMETRY_REQUIRED( tmSetLockStateEx( context, kpFileName, kLine, kPtr, kState, kpDescription, ##__VA_ARGS__ ) )
  559. //void tmSetLockStateMinTime( HTELEMETRY cx,void * buf,void const * kPtr,TmLockState const kState,char const * fmt,... );
  560. //
  561. //Description
  562. // Set the state of a lock but with a minimum time threshold.
  563. //
  564. //Parameters
  565. // cx [in] handle to a valid Telemetry context
  566. // buf [in] a user buffer used to store the lock event. Must be at least TM_LOCK_MIN_TIME_BUFSIZE in size.
  567. // kPtr [in] identifier for the lock, typically its address or HANDLE
  568. // kState [in] new state of the lock
  569. // kpDescription [in] description of the event. This may contain printf-style format specifiers.
  570. #define TM_SET_LOCK_STATE_MIN_TIME( context, buf, kPtr, kState, kpDescription, ... ) TELEMETRY_REQUIRED( tmSetLockStateMinTime( context, buf, kPtr, kState, kpDescription, ##__VA_ARGS__ ) )
  571. //void tmSetLockStateMinTimeEx( HTELEMETRY cx,void * buf,char const * kpFilename,int const kLine,void const * kPtr,TmLockState const kState );
  572. //
  573. //Description
  574. // This is the 'Ex' version of tmSetLockStateMinTimeEx. Please refer to tmSetLockStateEx and tmSetLockStateMinTime for more information.
  575. //
  576. //Parameters
  577. // cx [in] handle to a valid Telemetry context
  578. // buf [in] a user buffer used to store the lock event. Must be at least TM_LOCK_MIN_TIME_BUFSIZE in size.
  579. // kpFilename [in] filename where the state change occurs
  580. // kLine [in] line number of the state change
  581. // kPtr [in] identifier for the lock, typically its address or HANDLE
  582. // kState [in] new state of the lock
  583. // kpDescription [in] description of the event. This may contain printf-style format specifiers.
  584. #define TM_SET_LOCK_STATE_MIN_TIME_EX( context, buf, kpFilename, kLine, kPtr, kState, kpDescription, ... ) TELEMETRY_REQUIRED( tmSetLockStateMinTimeEx( context, buf, kpFilename, kLine, kPtr, kState, kpDescription, ##__VA_ARGS__ ) )
  585. //void tmThreadName( HTELEMETRY cx,TmU32 const kThreadID,char const * kpNameFormat,... );
  586. //
  587. //Description
  588. // Sets the name of the specified thread.
  589. //
  590. //Parameters
  591. // cx [in] handle to a valid Telemetry context
  592. // kThreadID [in] thread identifier of the thread to name. Use 0 to specify the current thread.
  593. // kpNameFormat [in] name of the thread. This may contain printf-style format specifiers.
  594. #define TM_THREAD_NAME( context, kThreadID, kpNameFormat, ... ) TELEMETRY_REQUIRED( tmThreadName( context, kThreadID, kpNameFormat, ##__VA_ARGS__ ) )
  595. //void tmLockName( HTELEMETRY cx,void const* kPtr,char const * kpNameFormat,... );
  596. //
  597. //Description
  598. // Sets the name of the specified locking object.
  599. //
  600. //Parameters
  601. // cx [in] handle to a valid Telemetry context
  602. // kPtr [in] identifier for the lock. Usually you can supply a pointer/HANDLE.
  603. // kpNameFormat [in] name of the lock. This may contain printf-style format specifiers.
  604. #define TM_LOCK_NAME( context, kPtr, kpNameFormat, ... ) TELEMETRY_REQUIRED( tmLockName( context, kPtr, kpNameFormat, ##__VA_ARGS__ ) )
  605. //void tmEmitAccumulationZone( HTELEMETRY cx,TmU32 const kZoneFlags,TmU64 * pStart,int const kCount,TmU64 const kTotal,char const * kpZoneFormat,... );
  606. //
  607. //Description
  608. // Emits an accumulation zone.
  609. //
  610. //Parameters
  611. // cx [in] handle to a valid telemetry context
  612. // kZoneFlags [in] reserved, must be 0
  613. // pStart [out] pointer to start time variable retrieved with a prior call to tmGetAccumulationStart. This value is modified.
  614. // kCount [in] number of times the accumulation zone was called
  615. // kTotal [in] total amount of time spent in the accumulation zone
  616. // kpZoneFormat [in] name of the accumulation zone. This may contain printf-style format specifiers.
  617. #define TM_EMIT_ACCUMULATION_ZONE( context, kZoneFlags, pStart, kCount, kTotal, kpZoneFormat, ... ) TELEMETRY_REQUIRED( tmEmitAccumulationZone( context, kZoneFlags, pStart, kCount, kTotal, kpZoneFormat, ##__VA_ARGS__ ) )
  618. //void tmSetVariable( HTELEMETRY cx,char const * kpKey,char const * kpValueFormat,... );
  619. //
  620. //Description
  621. // Binds a string to a key name and sends to the server.
  622. //
  623. //Parameters
  624. // cx [in] handle to a valid Telemetry context
  625. // kpKey [in] pointer to string identify the key being set
  626. // kpValueFormat [in] pointer to string to bind to the associated key. This may contain printf-style format specifiers.
  627. #define TM_SET_VARIABLE( context, kpKey, kpValueFormat, ... ) TELEMETRY_REQUIRED( tmSetVariable( context, kpKey, kpValueFormat, ##__VA_ARGS__ ) )
  628. //void tmSetTimelineSectionName( HTELEMETRY cx,char const * kpNameFormat,... );
  629. //
  630. //Description
  631. // Changes the name of the global state.
  632. //
  633. //Parameters
  634. // cx [in] handle to a valid Telemetry context
  635. // kpNameFormat [in] name of the current state. This may contain printf-style format specifiers.
  636. #define TM_SET_TIMELINE_SECTION_NAME( context, kpNameFormat, ... ) TELEMETRY_REQUIRED( tmSetTimelineSectionName( context, kpNameFormat, ##__VA_ARGS__ ) )
  637. //void tmEnter( HTELEMETRY cx,TmU32 const kFlags,char const * kpZoneName,... );
  638. //
  639. //Description
  640. // Notify Telemetry that a zone is being entered.
  641. //
  642. //Parameters
  643. // cx [in] handle to a valid Telemetry context
  644. // kFlags [in] Bitwise OR of TmZoneFlag
  645. // kpZoneName [in] name of the zone. This may contain printf-style format specifiers.
  646. #define TM_ENTER( context, kFlags, kpZoneName, ... ) TELEMETRY_REQUIRED( tmEnter( context, kFlags, kpZoneName, ##__VA_ARGS__ ) )
  647. //void tmEnterEx( HTELEMETRY cx,TmU64 * pMatchId,TmU32 const kThreadId,TmU64 const kThreshold,char const * kpFilename,int const kLine,TmU32 const kFlags,char const * kpZoneName,... );
  648. //
  649. //Description
  650. // Notify Telemetry that a zone is being entered, but with explicit file and line information.
  651. //
  652. //Parameters
  653. // cx [in] handle to a valid Telemetry context
  654. // pMatchId [in] pointer variable to assign a match ID, pass NULL if you are not Zones: Runtime Zone Filtering by Duration.
  655. // kThreadId [in] thread ID for this zone, pass 0 for current thread
  656. // kThreshold [in] microseconds that the zone must span before being sent to server.
  657. // kpFilename [in] filename
  658. // kLine [in] line number
  659. // kFlags [in] Bitwise OR of TmZoneFlag
  660. // kpZoneName [in] name of the zone. This may contain printf-style format specifiers.
  661. #define TM_ENTER_EX( context, pMatchId, kThreadId, kThreshold, kpFilename, kLine, kFlags, kpZoneName, ... ) TELEMETRY_REQUIRED( tmEnterEx( context, pMatchId, kThreadId, kThreshold, kpFilename, kLine, kFlags, kpZoneName, ##__VA_ARGS__ ) )
  662. //void tmAlloc( HTELEMETRY cx,void const * kPtr,TmU64 const kSize,char const * kpDescription,... );
  663. //
  664. //Description
  665. // Notify Telemetry that memory has been allocated.
  666. //
  667. //Parameters
  668. // cx [in] handle to a valid Telemetry context
  669. // kPtr [in] address of the memory that has been allocated
  670. // kSize [in] size of memory that has been allocated
  671. // kpDescription [in] textual description of the allocation, e.g. "vertex array" or "texture data". This may contain printf-style format specifiers.
  672. #define TM_ALLOC( context, kPtr, kSize, kpDescription, ... ) TELEMETRY_REQUIRED( tmAlloc( context, kPtr, kSize, kpDescription, ##__VA_ARGS__ ) )
  673. //void tmAllocEx( HTELEMETRY cx,char const * kpFilename,int const kLineNumber,void const * kPtr,TmU64 const kSize,char const * kpDescription,... );
  674. //
  675. //Description
  676. // Notify Telemetry that memory has been allocated, but with explicit file and line information.
  677. //
  678. //Parameters
  679. // cx [in] handle to a valid Telemetry context
  680. // kpFilename [in] name of the file
  681. // kLineNumber [in] line number of the allocation
  682. // kPtr [in] address of the memory that has been allocated
  683. // kSize [in] size of memory that has been allocated
  684. // kpDescription [in] textual description of the allocation, e.g. "vertex array" or "texture data". This may contain printf-style format specifiers.
  685. #define TM_ALLOC_EX( context, kpFilename, kLineNumber, kPtr, kSize, kpDescription, ... ) TELEMETRY_REQUIRED( tmAllocEx( context, kpFilename, kLineNumber, kPtr, kSize, kpDescription, ##__VA_ARGS__ ) )
  686. //void tmMessage( HTELEMETRY cx,TmU32 const kFlags,char const * kpFormatString,... );
  687. //
  688. //Description
  689. // Send a message to the server for later viewing in the Visualizer.
  690. //
  691. //Parameters
  692. // cx [in] handle to a valid Telemetry context
  693. // kFlags [in] Bitwise OR of TmMessageFlag
  694. // kpFormatString [in] message string (not to exceed TM_MAX_STRING in length). This may contain printf-style format specifiers. Note that the message may have a Telemetry object path in it so that it can be hierarchically displayed with other messages.
  695. #define TM_MESSAGE( context, kFlags, kpFormatString, ... ) TELEMETRY_REQUIRED( tmMessage( context, kFlags, kpFormatString, ##__VA_ARGS__ ) )
  696. #define TM_LOG( context, kpFormatString, ... ) TM_MESSAGE( context, TMMF_SEVERITY_LOG, kpFormatString, ##__VA_ARGS__ )
  697. #define TM_WARNING( context, kpFormatString, ... ) TM_MESSAGE( context, TMMF_SEVERITY_WARNING, kpFormatString, ##__VA_ARGS__ )
  698. #define TM_ERROR( context, kpFormatString, ... ) TM_MESSAGE( context, TMMF_SEVERITY_ERROR, kpFormatString, ##__VA_ARGS__ )
  699. //void tmPlot( HTELEMETRY cx,TmPlotType const kType,float const kValue,char const * kpNameFormat,... );
  700. //
  701. //Description
  702. // Sends a floating point plot value to the server.
  703. //
  704. //Parameters
  705. // cx [in] handle to a valid Telemetry context
  706. // kType [in] type of the plot (used to specify how the Visualizer will format the plot's value).
  707. // kValue [in] the value of the plot at this moment in time
  708. // kpNameFormat [in] name of the plot. You can use Telemetry object paths to create plot hierarchies on the Visualizer's plot filter tree. You can also specify plot scaling groups by appending group names in parenthesis to your plot's name, e.g. "renderer/memory/meshes(rendermem)" and "renderer/memory/textures(rendermem)" would be scaled using the same min/max values. This may contain printf-style format specifiers.
  709. #define TM_PLOT( context, kType, kFlags, kValue, kpNameFormat, ... ) TELEMETRY_REQUIRED( tmPlot( context, kType, kFlags, kValue, kpNameFormat, ##__VA_ARGS__ ) )
  710. //Identical to tmPlot()
  711. //void tmPlotF32( HTELEMETRY cx,TmPlotType const kType,float const kValue,char const * kpNameFormat,... );
  712. //
  713. //Description
  714. // Sends a floating point plot value to the server.
  715. //
  716. //Parameters
  717. // cx [in] handle to a valid Telemetry context
  718. // kType [in] type of the plot (used to specify how the Visualizer will format the plot's value).
  719. // kValue [in] the value of the plot at this moment in time
  720. // kpNameFormat [in] name of the plot. You can use Telemetry object paths to create plot hierarchies on the Visualizer's plot filter tree. You can also specify plot scaling groups by appending group names in parenthesis to your plot's name, e.g. "renderer/memory/meshes(rendermem)" and "renderer/memory/textures(rendermem)" would be scaled using the same min/max values. This may contain printf-style format specifiers.
  721. #define TM_PLOT_F32( context, kType, kFlags, kValue, kpNameFormat, ... ) TELEMETRY_REQUIRED( tmPlotF32( context, kType, kFlags, kValue, kpNameFormat, ##__VA_ARGS__ ) )
  722. //void tmPlotF64( HTELEMETRY cx,TmPlotType const kType,double const kValue,char const * kpNameFormat,... );
  723. //
  724. //Description
  725. // Sends a double precision floating point plot value to the server.
  726. //
  727. //Parameters
  728. // cx [in] handle to a valid Telemetry context
  729. // kType [in] type of the plot (used to specify how the Visualizer will format the plot's value).
  730. // kValue [in] the value of the plot at this moment in time
  731. // kpNameFormat [in] name of the plot. You can use Telemetry object paths to create plot hierarchies on the Visualizer's plot filter tree. You can also specify plot scaling groups by appending group names in parenthesis to your plot's name, e.g. "renderer/memory/meshes(rendermem)" and "renderer/memory/textures(rendermem)" would be scaled using the same min/max values. This may contain printf-style format specifiers.
  732. #define TM_PLOT_F64( context, kType, kFlags, kValue, kpNameFormat, ... ) TELEMETRY_REQUIRED( tmPlotF64( context, kType, kFlags, kValue, kpNameFormat, ##__VA_ARGS__ ) )
  733. //void tmPlotI32( HTELEMETRY cx,TmPlotType const kType,TmI32 const kValue,char const * kpNameFormat,... );
  734. //
  735. //Description
  736. // Sends an signed 32-bit value to the server.
  737. //
  738. //Parameters
  739. // cx [in] handle to a valid Telemetry context
  740. // kType [in] type of the plot (used to specify how the Visualizer will format the plot's value).
  741. // kValue [in] the value of the plot at this moment in time
  742. // kpNameFormat [in] name of the plot. You can use Telemetry object paths to create plot hierarchies on the Visualizer's plot filter tree. You can also specify plot scaling groups by appending group names in parenthesis to your plot's name, e.g. "renderer/memory/meshes(rendermem)" and "renderer/memory/textures(rendermem)" would be scaled using the same min/max values. This may contain printf-style format specifiers.
  743. #define TM_PLOT_I32( context, kType, kFlags, kValue, kpNameFormat, ... ) TELEMETRY_REQUIRED( tmPlotI32( context, kType, kFlags, kValue, kpNameFormat, ##__VA_ARGS__ ) )
  744. //void tmPlotU32( HTELEMETRY cx,TmPlotType const kType,TmU32 const kValue,char const * kpNameFormat,... );
  745. //
  746. //Description
  747. // Sends an unsigned 32-bit value to the server.
  748. //
  749. //Parameters
  750. // cx [in] handle to a valid Telemetry context
  751. // kType [in] type of the plot (used to specify how the Visualizer will format the plot's value).
  752. // kValue [in] the value of the plot at this moment in time
  753. // kpNameFormat [in] name of the plot. You can use Telemetry object paths to create plot hierarchies on the Visualizer's plot filter tree. You can also specify plot scaling groups by appending group names in parenthesis to your plot's name, e.g. "renderer/memory/meshes(rendermem)" and "renderer/memory/textures(rendermem)" would be scaled using the same min/max values. This may contain printf-style format specifiers.
  754. #define TM_PLOT_U32( context, kType, kFlags, kValue, kpNameFormat, ... ) TELEMETRY_REQUIRED( tmPlotU32( context, kType, kFlags, kValue, kpNameFormat, ##__VA_ARGS__ ) )
  755. //void tmPlotI64( HTELEMETRY cx,TmPlotType const kType,TmI64 const kValue,char const * kpNameFormat,... );
  756. //
  757. //Description
  758. // Sends an signed 64-bit value to the server.
  759. //
  760. //Parameters
  761. // cx [in] handle to a valid Telemetry context
  762. // kType [in] type of the plot (used to specify how the Visualizer will format the plot's value).
  763. // kValue [in] the value of the plot at this moment in time
  764. // kpNameFormat [in] name of the plot. You can use Telemetry object paths to create plot hierarchies on the Visualizer's plot filter tree. You can also specify plot scaling groups by appending group names in parenthesis to your plot's name, e.g. "renderer/memory/meshes(rendermem)" and "renderer/memory/textures(rendermem)" would be scaled using the same min/max values. This may contain printf-style format specifiers.
  765. #define TM_PLOT_I64( context, kType, kFlags, kValue, kpNameFormat, ... ) TELEMETRY_REQUIRED( tmPlotI64( context, kType, kFlags, kValue, kpNameFormat, ##__VA_ARGS__ ) )
  766. //void tmPlotU64( HTELEMETRY cx,TmPlotType const kType,TmU64 const kValue,char const * kpNameFormat,... );
  767. //
  768. //Description
  769. // Sends an unsigned 64-bit value to the server.
  770. //
  771. //Parameters
  772. // cx [in] handle to a valid Telemetry context
  773. // kType [in] type of the plot (used to specify how the Visualizer will format the plot's value).
  774. // kValue [in] the value of the plot at this moment in time
  775. // kpNameFormat [in] name of the plot. You can use Telemetry object paths to create plot hierarchies on the Visualizer's plot filter tree. You can also specify plot scaling groups by appending group names in parenthesis to your plot's name, e.g. "renderer/memory/meshes(rendermem)" and "renderer/memory/textures(rendermem)" would be scaled using the same min/max values. This may contain printf-style format specifiers.
  776. #define TM_PLOT_U64( context, kType, kFlags, kValue, kpNameFormat, ... ) TELEMETRY_REQUIRED( tmPlotU64( context, kType, kFlags, kValue, kpNameFormat, ##__VA_ARGS__ ) )
  777. //void tmBlob( HTELEMETRY cx,void const * kpData,int const kDataSize,char const * kpPluginIdentifier,char const * kpBlobName,... );
  778. //
  779. //Description
  780. // Sends an arbitrary application specified blob of binary data for storage on the server.
  781. //
  782. //Parameters
  783. // cx [in] handle to a valid Telemetry context
  784. // kpData [in] the actual blob data
  785. // kDataSize [in] size of kpData in bytes
  786. // kpPluginIdentifier [in] identifier of the plugin used to visualize this data (must match the plugin's internal identifier).
  787. // kpBlobName [in] the name of the blob. This may contain printf-style format specifiers.
  788. #define TM_BLOB( context, kpData, kDataSize, kpPluginIdentifier, kpBlobName, ...) TELEMETRY_REQUIRED( tmBlob( context, kpData, kDataSize, kpPluginIdentifier, kpBlobName, ##__VA_ARGS__ ) )
  789. //void tmDisjointBlob( HTELEMETRY cx,int const kNumPieces,void const ** kpData,int const * kDataSizes,char const* kpPluginIdentifier,char const * kpBlobName,... );
  790. //
  791. //Description
  792. // Sends an arbitrary application specified blob of binary data for storage on the server.
  793. //
  794. //Parameters
  795. // cx [in] handle to a valid Telemetry context
  796. // kNumPieces [in] number of elements in kpData and kDataSizes
  797. // kpData [in] array of actual data blobs
  798. // kDataSizes [in] array of data blob sizes in bytes
  799. // kpPluginIdentifier [in] identifier of the plugin used to visualize this data (must match the plugin's internal identifier).
  800. // kpBlobName [in] the name of the blob. This may contain printf-style format specifiers.
  801. #define TM_DISJOINT_BLOB( context, kNumPieces, kpData, kDataSizes, kpPluginIdentifier, kpBlobName, ... ) TELEMETRY_REQUIRED( tmDisjointBlob( context, kNumPieces, kpData, kDataSizes, kpPluginIdentifier, kpBlobName, ##__VA_ARGS__ ) )
  802. #if !defined( RAD_TELEMETRY_ENABLED )
  803. //
  804. // Telemetry is disabled.
  805. //
  806. class CTelemetryLock
  807. {
  808. public:
  809. CTelemetryLock(void *plocation, const char *description) {}
  810. ~CTelemetryLock() {}
  811. void Locked() {}
  812. void Unlocked() {}
  813. };
  814. class CTelemetrySpikeDetector
  815. {
  816. public:
  817. CTelemetrySpikeDetector( const char *msg, unsigned int threshold = 50 ) {}
  818. ~CTelemetrySpikeDetector() { }
  819. };
  820. class CTelemetryZonePlotScope
  821. {
  822. public:
  823. CTelemetryZonePlotScope(const char* pName, TelemetryZonePlotSlot_t slot) {}
  824. ~CTelemetryZonePlotScope() {}
  825. };
  826. #define TelemetrySetLockName( _ctx, _location, _description )
  827. #define TM_ZONE_PLOT( context, name, slot )
  828. #else
  829. //
  830. // Telemetry is enabled.
  831. //
  832. #define TelemetrySetLockName( _ctx, _location, _description ) \
  833. do \
  834. { \
  835. static bool s_bNameSet = false; \
  836. if( _ctx && !s_bNameSet ) \
  837. { \
  838. tmLockName( _ctx, _location, _description ); \
  839. s_bNameSet = true; \
  840. } \
  841. } while( 0 )
  842. class CTelemetryLock
  843. {
  844. public:
  845. CTelemetryLock(void *plocation, const char *description)
  846. {
  847. m_plocation = (const char *)plocation;
  848. m_description = description;
  849. TelemetrySetLockName( TELEMETRY_LEVEL1, m_plocation, m_description );
  850. TM_TRY_LOCK( TELEMETRY_LEVEL1, m_plocation, "%s", m_description );
  851. }
  852. ~CTelemetryLock()
  853. {
  854. Unlocked();
  855. }
  856. void Locked()
  857. {
  858. TM_END_TRY_LOCK( TELEMETRY_LEVEL1, m_plocation, TMLR_SUCCESS );
  859. TM_SET_LOCK_STATE( TELEMETRY_LEVEL1, m_plocation, TMLS_LOCKED, "%s Locked", m_description );
  860. }
  861. void Unlocked()
  862. {
  863. if( m_plocation )
  864. {
  865. TM_SET_LOCK_STATE( TELEMETRY_LEVEL1, m_plocation, TMLS_RELEASED, "%s Released", m_description );
  866. m_plocation = NULL;
  867. }
  868. }
  869. public:
  870. const char *m_plocation;
  871. const char *m_description;
  872. };
  873. class CTelemetrySpikeDetector
  874. {
  875. public:
  876. // Spews Telemetry message when threshold hit (in milliseconds.)
  877. CTelemetrySpikeDetector( const char *msg, float threshold = 5 ) :
  878. m_message( msg ), m_threshold( threshold ), time0( tmFastTime() ) {}
  879. ~CTelemetrySpikeDetector()
  880. {
  881. float time = ( tmFastTime() - time0 ) * g_Telemetry.flRDTSCToMilliSeconds;
  882. if( time >= m_threshold )
  883. {
  884. TM_MESSAGE( TELEMETRY_LEVEL0, TMMF_ICON_NOTE | TMMF_SEVERITY_WARNING, "(dota/spike)%s %.2fms %t", m_message, time, tmSendCallStack( TELEMETRY_LEVEL0, 0 ) );
  885. }
  886. }
  887. private:
  888. TmU64 time0;
  889. float m_threshold;
  890. const char *m_message;
  891. };
  892. //Description
  893. // Helper macro in C++ that creates an anonymous local object that automatically calls tmEnter
  894. // and then tmLeave when exiting scope. It will also accumulate the time over a frame to plot
  895. // the zone duration
  896. // Note the function are not thread safe!
  897. //
  898. //Parameters
  899. // cx [in] handle to a valid Telemetry context
  900. // name [in] name of the zone
  901. // slot [in] slot use to plot the graph (of type TelemetryZonePlotSlot_t)
  902. #define TM_ZONE_PLOT( context, name, slot ) CTelemetryZonePlotScope _telemetryZonePlot##__LINE__(context, name, slot);
  903. class CTelemetryZonePlotScope
  904. {
  905. public:
  906. CTelemetryZonePlotScope(HTELEMETRY context, const char* pName, TelemetryZonePlotSlot_t slot)
  907. :
  908. m_Context(context),
  909. m_SlotData(NULL),
  910. m_StartTime(0)
  911. {
  912. if ( slot < TELEMETRY_ZONE_PLOT_SLOT_MAX )
  913. {
  914. m_SlotData = &g_Telemetry.m_ZonePlot[slot];
  915. m_SlotData->m_Name = pName;
  916. m_StartTime = TM_FAST_TIME();
  917. }
  918. TM_ENTER( m_Context, TMZF_NONE, "%s", pName );
  919. }
  920. ~CTelemetryZonePlotScope()
  921. {
  922. TM_LEAVE( m_Context );
  923. if ( m_SlotData )
  924. {
  925. m_SlotData->m_CurrFrameTime += ( TM_FAST_TIME() - m_StartTime );
  926. }
  927. }
  928. private:
  929. HTELEMETRY m_Context;
  930. TelemetryZonePlotData* m_SlotData;
  931. TmU64 m_StartTime;
  932. };
  933. #endif // RAD_TELEMETRY_ENABLED
  934. #endif // VPROF_TELEMETRY_H