From bdafd0c7b6e2c26cfb0fb957506de4aa18a4943e Mon Sep 17 00:00:00 2001 From: Nathan Day Date: Sat, 4 Dec 2021 16:55:41 +0000 Subject: [PATCH 1/3] Added IsConnected C API Equivalent --- TracyC.h | 6 ++++++ client/TracyProfiler.cpp | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/TracyC.h b/TracyC.h index bac66df3..24616068 100644 --- a/TracyC.h +++ b/TracyC.h @@ -73,6 +73,8 @@ typedef const void* TracyCZoneCtx; #define TracyCMessageCS(x,y,z,w) #define TracyCMessageLCS(x,y,z) +#define TracyCIsConnected 0 + #ifdef TRACY_FIBERS # define TracyCFiberEnter(fiber) # define TracyCFiberLeave @@ -169,6 +171,8 @@ TRACY_API void ___tracy_emit_gpu_time_serial( const struct ___tracy_gpu_time_dat TRACY_API void ___tracy_emit_gpu_new_context_serial( const struct ___tracy_gpu_new_context_data ); TRACY_API void ___tracy_emit_gpu_context_name_serial( const struct ___tracy_gpu_context_name_data ); +TRACY_API int ___tracy_connected(void); + #if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK # define TracyCZone( ctx, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { NULL, __func__, __FILE__, (uint32_t)__LINE__, 0 }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active ); # define TracyCZoneN( ctx, name, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { name, __func__, __FILE__, (uint32_t)__LINE__, 0 }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active ); @@ -297,6 +301,8 @@ TRACY_API void ___tracy_emit_message_appinfo( const char* txt, size_t size ); # define TracyCMessageLCS( txt, color, depth ) TracyCMessageLC( txt, color ) #endif +#define TracyCIsConnected ___tracy_connected() + TRACY_API void ___tracy_fiber_enter( const char* fiber ); TRACY_API void ___tracy_fiber_leave( void ); diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index c1d33d1c..93f8422e 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -4158,6 +4158,11 @@ TRACY_API void ___tracy_emit_gpu_context_name_serial( const struct ___tracy_gpu_ tracy::Profiler::QueueSerialFinish(); } +TRACY_API int ___tracy_connected( void ) +{ + return tracy::GetProfiler().IsConnected(); +} + #ifdef TRACY_FIBERS TRACY_API void ___tracy_fiber_enter( const char* fiber ){ tracy::Profiler::EnterFiber( fiber ); } TRACY_API void ___tracy_fiber_leave( void ){ tracy::Profiler::LeaveFiber(); } From 3bf1e7ec1c348176580d0898357bccb020c34337 Mon Sep 17 00:00:00 2001 From: Nathan Day Date: Sat, 4 Dec 2021 17:26:17 +0000 Subject: [PATCH 2/3] Updated documentation --- manual/tracy.tex | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/manual/tracy.tex b/manual/tracy.tex index dd17f49b..f15e0cec 100644 --- a/manual/tracy.tex +++ b/manual/tracy.tex @@ -1862,6 +1862,10 @@ To see how this API should be used you should look at the reference implementati Fibers are available in the C API through the \texttt{TracyCFiberEnter} and \texttt{TracyCFiberLeave} macros. To use them, you should observe the requirements listed in section~\ref{fibers}. +\subsubsection{Connection Status} + +To query the connection status (section~\ref{connectionstatus}) using the C API you should use the TracyCIsConnected macro. + \subsubsection{Call stacks} You can collect call stacks of zones and memory allocation events, as described in section~\ref{collectingcallstacks}, by using macros with \texttt{S} postfix, such as: \texttt{TracyCZoneS}, \texttt{TracyCZoneNS}, \texttt{TracyCZoneCS}, \texttt{TracyCZoneNCS}, \texttt{TracyCAllocS}, \texttt{TracyCFreeS}, and so on. @@ -2086,6 +2090,7 @@ Usage of trace parameters makes profiling runs dependent on user interaction wit \end{bclogo} \subsection{Connection status} +\label{connectionstatus} To determine if a connection is currently established between the client and the server, you may use the \texttt{TracyIsConnected} macro, which returns a boolean value. From 14825d8e5a6b4e12f3b6ffee32b17f52a938921a Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 4 Dec 2021 18:27:26 +0100 Subject: [PATCH 3/3] Proper formatting. --- manual/tracy.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manual/tracy.tex b/manual/tracy.tex index f15e0cec..f72c7ed9 100644 --- a/manual/tracy.tex +++ b/manual/tracy.tex @@ -1864,7 +1864,7 @@ Fibers are available in the C API through the \texttt{TracyCFiberEnter} and \tex \subsubsection{Connection Status} -To query the connection status (section~\ref{connectionstatus}) using the C API you should use the TracyCIsConnected macro. +To query the connection status (section~\ref{connectionstatus}) using the C API you should use the \texttt{TracyCIsConnected} macro. \subsubsection{Call stacks}