Skip to content

Commit

Permalink
(net) Tracy integration
Browse files Browse the repository at this point in the history
  • Loading branch information
cipharius committed May 19, 2023
1 parent 7bf64a1 commit 60be6f0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
18 changes: 18 additions & 0 deletions src/a12/CMakeLists.txt
Expand Up @@ -30,6 +30,24 @@ else()
amsg("(a12) ${CL_YEL} ffmpeg support NOT found, video enc/dec DISABLED ${CL_RST}")
endif()

if (ENABLE_TRACY)
option(TRACY_ENABLE "" ON)
option(TRACY_ON_DEMAND "" ON)
if (NOT TARGET TracyClient)
add_subdirectory(
${EXTERNAL_SRC_DIR}/git/tracy
${CMAKE_CURRENT_BINARY_DIR}/tracy
)
endif()
set_target_properties(TracyClient PROPERTIES
COMPILE_FLAGS -fPIC)
list(APPEND DEFS WITH_TRACY)
list(APPEND LIBRARIES TracyClient)
amsg("(a12) ${CL_YEL}tracy support\t${CL_GRN}enabled${CL_RST}")
else()
amsg("(a12) ${CL_YEL}tracy support\t${CL_RED}disabled${CL_RST}")
endif()

set(A12_SOURCES
a12.c
a12_decode.c
Expand Down
32 changes: 26 additions & 6 deletions src/a12/a12.h
Expand Up @@ -592,10 +592,30 @@ extern FILE* a12_trace_dst;
const char* a12int_group_tostr(int group);

#ifndef a12int_trace
#define a12int_trace(group, fmt, ...) \
do { if (a12_trace_dst && (a12_trace_targets & group)) fprintf(a12_trace_dst, \
"group=%s:function=%s:" fmt "\n", \
a12int_group_tostr(group), __func__,##__VA_ARGS__); } while (0)
#endif

#endif
#ifdef WITH_TRACY
#include "tracy/TracyC.h"
#define a12int_trace(group, fmt, ...) \
do { \
TracyCZone(___trace_ctx, true); \
const char *___trace_name = a12int_group_tostr(group); \
TracyCZoneName(___trace_ctx, ___trace_name, strlen(___trace_name)); \
char ___trace_buf[512]; \
int ___trace_strlen = snprintf(___trace_buf, 512, \
"group=%s:function=%s:" fmt "\n", \
___trace_name, __func__,##__VA_ARGS__); \
TracyCZoneText(___trace_ctx, ___trace_buf, MIN(511, ___trace_strlen)); \
TracyCZoneEnd(___trace_ctx); \
} while (0)
#else
#define a12int_trace(group, fmt, ...) \
do { \
if (a12_trace_dst && (a12_trace_targets & group)) \
fprintf(a12_trace_dst, \
"group=%s:function=%s:" fmt "\n", \
a12int_group_tostr(group), __func__,##__VA_ARGS__); \
} while (0)
#endif // WITH_TRACY

#endif // a12int_trace
#endif // HAVE_A12

0 comments on commit 60be6f0

Please sign in to comment.