diff --git a/src/a12/CMakeLists.txt b/src/a12/CMakeLists.txt index 2ede22667..f9b0777f8 100644 --- a/src/a12/CMakeLists.txt +++ b/src/a12/CMakeLists.txt @@ -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 diff --git a/src/a12/a12.h b/src/a12/a12.h index 4fe8af484..3806fd1bb 100644 --- a/src/a12/a12.h +++ b/src/a12/a12.h @@ -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