Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
profile.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) Meta Platforms, Inc. and affiliates.
3
*
4
* This source code is licensed under the MIT license found in the
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
#pragma once
9
22
23
#if defined(MOMENTUM_WITH_XR_PROFILER)
24
25
#include <arvr/libraries/profile_redirect/annotate.hpp>
26
29
#define MT_PROFILE_FUNCTION() XR_PROFILE_FUNCTION()
32
#define MT_PROFILE_FUNCTION_CATEGORY(CATEGORY) XR_PROFILE_FUNCTION_CATEGORY(CATEGORY)
34
#define MT_PROFILE_EVENT(NAME) XR_PROFILE_EVENT(NAME)
37
#define MT_PROFILE_EVENT_DYNAMIC(NAME) XR_PROFILE_EVENT_DYNAMIC(NAME)
39
#define MT_PROFILE_CATEGORY(NAME, CATEGORY) XR_PROFILE_CATEGORY(NAME, CATEGORY)
42
#define MT_PROFILE_PREPARE_PUSH_POP() XR_PROFILE_PREPARE_PUSH_POP()
45
#define MT_PROFILE_PUSH(NAME) XR_PROFILE_PUSH(NAME)
48
#define MT_PROFILE_POP() XR_PROFILE_POP()
53
#define MT_PROFILE_THREAD(THREAD_NAME) XR_PROFILE_THREAD(THREAD_NAME)
55
#define MT_PROFILE_UPDATE() XR_PROFILE_UPDATE()
59
#define MT_PROFILE_BEGIN_FRAME() XR_PROFILE_BEGIN_FRAME()
61
#define MT_PROFILE_END_FRAME() XR_PROFILE_END_FRAME()
64
#define MT_PROFILE_METADATA(NAME, DATA) XR_PROFILE_METADATA(NAME, DATA)
65
66
#elif defined(MOMENTUM_WITH_TRACY_PROFILER)
67
68
#include <tracy/Tracy.hpp>
69
#include <tracy/TracyC.h>
70
#include <stack>
71
72
#define _MT_PROFILE_CONCATENATE_DETAIL(x, y) x##y
73
#define _MT_PROFILE_CONCATENATE(x, y) _MT_PROFILE_CONCATENATE_DETAIL(x, y)
74
#define _MT_PROFILE_MAKE_UNIQUE(x) _MT_PROFILE_CONCATENATE(x, __LINE__)
75
76
#define MT_PROFILE_FUNCTION() ZoneScoped
77
#define MT_PROFILE_FUNCTION_CATEGORY(CATEGORY)
78
#define MT_PROFILE_EVENT(NAME) ZoneNamedN(_MT_PROFILE_MAKE_UNIQUE(__tracy), NAME, true)
79
#define MT_PROFILE_EVENT_DYNAMIC(NAME) ZoneTransientN(_MT_PROFILE_MAKE_UNIQUE(__tracy), NAME, true)
80
#define MT_PROFILE_CATEGORY(NAME, CATEGORY)
81
// TODO: Rename `___tracy_xr_stack` — the `xr_` prefix is a leftover from the XR
82
// backend and is misleading inside the Tracy block. The variable is a per-scope
83
// stack of open zones; thread-safety is not required because each scope's
84
// push/pop pairs are local to one thread.
85
#define MT_PROFILE_PREPARE_PUSH_POP() std::stack<TracyCZoneCtx> ___tracy_xr_stack
86
#define MT_PROFILE_PUSH(NAME) \
87
static const struct ___tracy_source_location_data TracyConcat( \
88
__tracy_source_location, TracyLine) = {NAME, __func__, TracyFile, (uint32_t)TracyLine, 0}; \
89
___tracy_xr_stack.push( \
90
___tracy_emit_zone_begin(&TracyConcat(__tracy_source_location, TracyLine), true));
91
#define MT_PROFILE_POP() \
92
TracyCZoneEnd(___tracy_xr_stack.top()); \
93
___tracy_xr_stack.pop()
94
// Wrap THREAD_NAME in a std::string so the macro accepts both std::string and
95
// C-string arguments; TracyCSetThreadName requires a C string.
96
#define MT_PROFILE_THREAD(THREAD_NAME) \
97
{ \
98
std::string threadNameStr(THREAD_NAME); \
99
TracyCSetThreadName(threadNameStr.c_str()); \
100
}
101
#define MT_PROFILE_UPDATE()
102
#define MT_PROFILE_BEGIN_FRAME() FrameMark
103
#define MT_PROFILE_END_FRAME()
104
#define MT_PROFILE_METADATA(NAME, DATA)
105
106
#else
107
108
// No profiler backend selected: every macro expands to nothing, so
109
// instrumentation has zero runtime cost in production builds.
110
#define MT_PROFILE_FUNCTION()
111
#define MT_PROFILE_FUNCTION_CATEGORY(CATEGORY)
112
#define MT_PROFILE_EVENT(NAME)
113
#define MT_PROFILE_EVENT_DYNAMIC(NAME)
114
#define MT_PROFILE_CATEGORY(NAME, CATEGORY)
115
#define MT_PROFILE_PREPARE_PUSH_POP()
116
#define MT_PROFILE_PUSH(NAME)
117
#define MT_PROFILE_POP()
118
#define MT_PROFILE_THREAD(THREAD_NAME)
119
#define MT_PROFILE_UPDATE()
120
#define MT_PROFILE_BEGIN_FRAME()
121
#define MT_PROFILE_END_FRAME()
122
#define MT_PROFILE_METADATA(NAME, DATA)
123
124
#endif
common
profile.h
Generated on
for Momentum by
1.15.0