The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

u/trace_marker: Tracy support

+96 -2
+5
src/xrt/auxiliary/util/CMakeLists.txt
··· 113 113 target_link_libraries(aux_util PUBLIC percetto::percetto) 114 114 endif() 115 115 116 + # Is basically used everywhere, only used in debugging. 117 + if(XRT_FEATURE_TRACING AND XRT_HAVE_TRACY) 118 + target_link_libraries(aux_util PUBLIC xrt-external-tracy) 119 + endif() 120 + 116 121 # Is basically used everywhere, so link with here. 117 122 if(ANDROID) 118 123 target_link_libraries(aux_util PUBLIC ${ANDROID_LOG_LIBRARY})
+91 -2
src/xrt/auxiliary/util/u_trace_marker.h
··· 30 30 #include <percetto.h> 31 31 #endif 32 32 33 + #if defined(XRT_FEATURE_TRACING) && defined(XRT_HAVE_TRACY) 34 + #define U_TRACE_TRACY 35 + #include "tracy/TracyC.h" 36 + #ifdef __cplusplus 37 + #include "tracy/Tracy.hpp" 38 + #endif 39 + #endif 40 + 33 41 34 42 #ifdef __cplusplus 35 43 extern "C" { ··· 130 138 131 139 /* 132 140 * 141 + * Tracy support. 142 + * 143 + */ 144 + 145 + #elif defined(XRT_HAVE_TRACY) // && XRT_FEATURE_TRACING 146 + 147 + // Different wrappers for different cases. 148 + #ifdef __cplusplus 149 + 150 + #define U_TRACE_FUNC(CATEGORY) ZoneScoped 151 + 152 + #define U_TRACE_IDENT(CATEGORY, IDENT) ZoneScopedN(#IDENT) 153 + 154 + #elif !defined(XRT_OS_WINDOWS) // !__cplusplus 155 + 156 + static inline void 157 + u_trace_scope_cleanup(TracyCZoneCtx *ctx_ptr) 158 + { 159 + TracyCZoneEnd(*ctx_ptr); 160 + } 161 + 162 + #define U_TRACE_FUNC(CATEGORY) \ 163 + static const struct ___tracy_source_location_data __func_loc = { \ 164 + NULL, __func__, __FILE__, (uint32_t)__LINE__, 0, \ 165 + }; \ 166 + TracyCZoneCtx __attribute__((cleanup(u_trace_scope_cleanup))) ctx = \ 167 + ___tracy_emit_zone_begin(&__func_loc, true); \ 168 + (void)ctx 169 + 170 + #define U_TRACE_IDENT(CATEGORY, IDENT) \ 171 + static const struct ___tracy_source_location_data __##IDENT##_loc = { \ 172 + #IDENT, __func__, __FILE__, (uint32_t)__LINE__, 0, \ 173 + }; \ 174 + TracyCZoneCtx __attribute__((cleanup(u_trace_scope_cleanup))) ctx##IDENT = \ 175 + ___tracy_emit_zone_begin(&__##IDENT##_loc, true); \ 176 + (void)ctx##IDENT 177 + 178 + #else // !XRT_OS_WINDOWS && !__cplusplus 179 + 180 + #define U_TRACE_FUNC(CATEGORY) \ 181 + do { \ 182 + } while (false) 183 + 184 + #define U_TRACE_IDENT(CATEGORY, IDENT) \ 185 + do { \ 186 + } while (false) 187 + 188 + #endif // !XRT_OS_WINDOWS && !__cplusplus 189 + 190 + 191 + #define U_TRACE_EVENT_BEGIN_ON_TRACK(CATEGORY, TRACK, TIME, NAME) \ 192 + do { \ 193 + } while (false) 194 + 195 + #define U_TRACE_EVENT_BEGIN_ON_TRACK_DATA(CATEGORY, TRACK, TIME, NAME, ...) \ 196 + do { \ 197 + } while (false) 198 + 199 + #define U_TRACE_EVENT_END_ON_TRACK(CATEGORY, TRACK, TIME) \ 200 + do { \ 201 + } while (false) 202 + 203 + #define U_TRACE_INSTANT_ON_TRACK(CATEGORY, TRACK, TIME, NAME) \ 204 + do { \ 205 + } while (false) 206 + 207 + #define U_TRACE_CATEGORY_IS_ENABLED(_) (true) // All categories are always enabled with Tracy. 208 + 209 + #define U_TRACE_SET_THREAD_NAME(STRING) \ 210 + do { \ 211 + /* To help with thread ordering and seeing when a thread is created. */ \ 212 + TracyCZoneN(created, "created", true); \ 213 + TracyCSetThreadName(STRING); \ 214 + TracyCZoneEnd(created); \ 215 + } while (false) 216 + 217 + #define U_TRACE_TARGET_SETUP(WHICH) 218 + 219 + 220 + /* 221 + * 133 222 * Percetto support. 134 223 * 135 224 */ 136 225 137 - #elif defined(XRT_HAVE_PERCETTO) // && XRT_FEATURE_TRACKING 226 + #elif defined(XRT_HAVE_PERCETTO) // && XRT_FEATURE_TRACKING && !XRT_HAVE_TRACY 138 227 139 228 #ifndef XRT_OS_LINUX 140 229 #error "Tracing only supported on Linux" ··· 190 279 u_trace_marker_setup(WHICH); \ 191 280 } 192 281 193 - #else // !XRT_FEATURE_TRACING && !XRT_HAVE_PERCETTO 282 + #else // !XRT_FEATURE_TRACING && !XRT_HAVE_PERCETTO && !XRT_HAVE_TRACY 194 283 195 284 #error "Need to have Percetto/Perfetto" 196 285