Repository navigation
Expand file tree
/
Copy pathProfiling.hpp
More file actions
185 lines (169 loc) · 6.27 KB
/
Copy pathProfiling.hpp
File metadata and controls
185 lines (169 loc) · 6.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#pragma once
#if defined(PROJECTV_ENABLE_TRACY) && defined(TRACY_ENABLE) // TRACY_ENABLE: target links TracyClient
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <tracy/Tracy.hpp>
#pragma clang diagnostic pop
#endif
enum class ProfilingPlotFormat : uint8_t {
Number = 0,
Memory = 1,
Percentage = 2,
};
// NOLINTBEGIN(cppcoreguidelines-macro-usage): a zone declares a scoped variable in the caller; no function can
#if defined(PROJECTV_ENABLE_TRACY) && defined(TRACY_ENABLE)
#define PV_PROFILE_ZONE() ZoneNamed(TracyConcat(pvProfileZone, TracyLine), true) // no trailing ;
#define PV_PROFILE_ZONE_N(name) ZoneNamedN(TracyConcat(pvProfileZone, TracyLine), name, true) // no trailing ;
#define PV_PROFILE_FRAME_MARK() FrameMark
#else
#define PV_PROFILE_ZONE() static_cast<void>(0) // adds no control flow (cognitive complexity)
#define PV_PROFILE_ZONE_N(name) static_cast<void>(name) // name stays referenced, adds no control flow
#define PV_PROFILE_FRAME_MARK() \
do { \
} while (false)
#endif
// NOLINTEND(cppcoreguidelines-macro-usage)
namespace profiling {
inline void SetThreadName(const char *name)
{
#if defined(PROJECTV_ENABLE_TRACY) && defined(TRACY_ENABLE)
tracy::SetThreadName(name);
#else
(void)name;
#endif
}
inline void ConfigurePlot(
const char *name,
const ProfilingPlotFormat format,
const bool step = false,
const bool fill = false,
const uint32_t color = 0)
{
#if defined(PROJECTV_ENABLE_TRACY) && defined(TRACY_ENABLE)
TracyPlotConfig(name, static_cast<tracy::PlotFormatType>(format), step, fill, color);
#else
(void)name;
(void)format;
(void)step;
(void)fill;
(void)color;
#endif
}
inline void ConfigureDefaultPlots()
{
#if defined(PROJECTV_ENABLE_TRACY) && defined(TRACY_ENABLE)
static bool configured = false;
if (configured) {
return;
}
configured = true;
ConfigurePlot("Frame Delta (ms)", ProfilingPlotFormat::Number);
ConfigurePlot("Simulation Accumulator (ms)", ProfilingPlotFormat::Number);
ConfigurePlot("Simulation Steps", ProfilingPlotFormat::Number, true);
ConfigurePlot("Dirty Chunks", ProfilingPlotFormat::Number, true);
ConfigurePlot("Active Chunks", ProfilingPlotFormat::Number, true);
ConfigurePlot("Rebuilt Chunks", ProfilingPlotFormat::Number, true);
ConfigurePlot("Repacked Chunk Voxels", ProfilingPlotFormat::Number, true);
ConfigurePlot("Scene Triangles", ProfilingPlotFormat::Number, true);
ConfigurePlot("Generated Opaque Faces", ProfilingPlotFormat::Number, true);
ConfigurePlot("Generated Transparent Faces", ProfilingPlotFormat::Number, true);
ConfigurePlot("Meshing Dirty Chunks", ProfilingPlotFormat::Number, true);
ConfigurePlot("Visible Chunks", ProfilingPlotFormat::Number, true);
ConfigurePlot("Culled Chunks", ProfilingPlotFormat::Number, true);
ConfigurePlot("Chunk Voxel Words", ProfilingPlotFormat::Number, true);
ConfigurePlot("Uploaded Chunk Descriptors", ProfilingPlotFormat::Number, true);
ConfigurePlot("Uploaded Voxel Payload Chunks", ProfilingPlotFormat::Number, true);
ConfigurePlot("Uploaded Chunk Voxel Words", ProfilingPlotFormat::Number, true);
ConfigurePlot("Upload Descriptor Bytes", ProfilingPlotFormat::Memory, true);
ConfigurePlot("Upload Chunk Voxel Bytes", ProfilingPlotFormat::Memory, true);
ConfigurePlot("Walk Support State", ProfilingPlotFormat::Number, true);
ConfigurePlot("Walk Support Score", ProfilingPlotFormat::Number);
ConfigurePlot("Walk Feet Y", ProfilingPlotFormat::Number);
ConfigurePlot("Walk Velocity Y", ProfilingPlotFormat::Number);
ConfigurePlot("Walk Sneak Active", ProfilingPlotFormat::Number, true);
ConfigurePlot("Walk Jump Lock", ProfilingPlotFormat::Number, true);
ConfigurePlot("Walk Cached Sneak Support", ProfilingPlotFormat::Number, true);
ConfigurePlot("Walk Feet Inside Sneak Cache", ProfilingPlotFormat::Number, true);
ConfigurePlot("Walk Edge Grace", ProfilingPlotFormat::Number, true);
ConfigurePlot("Walk Ground Takeoff Grace", ProfilingPlotFormat::Number, true);
ConfigurePlot("Walk Sneak Support Grace", ProfilingPlotFormat::Number, true);
ConfigurePlot("Walk Ledge Release Grace", ProfilingPlotFormat::Number, true);
ConfigurePlot("Walk Ground Return Anchor", ProfilingPlotFormat::Number, true);
ConfigurePlot("VCT Voxelize Chunks", ProfilingPlotFormat::Number, true);
ConfigurePlot("VCT Mip Chain Mips", ProfilingPlotFormat::Number, true);
ConfigurePlot("VCT Active Mip", ProfilingPlotFormat::Number, true);
ConfigurePlot("Sky Atmosphere Pass", ProfilingPlotFormat::Number, true);
ConfigurePlot("Volumetric Fog Pass", ProfilingPlotFormat::Number, true);
ConfigurePlot("Cloudscape Pass", ProfilingPlotFormat::Number, true);
ConfigurePlot("Sky LUT Precompute (ms)", ProfilingPlotFormat::Number);
ConfigurePlot("Physics Sync Full Rebuild", ProfilingPlotFormat::Number, true);
ConfigurePlot("Physics Sync Incremental", ProfilingPlotFormat::Number, true);
ConfigurePlot("Physics Sync Skipped", ProfilingPlotFormat::Number, true);
#endif
}
inline void PlotValue(const char *name, const int64_t value)
{
#if defined(PROJECTV_ENABLE_TRACY) && defined(TRACY_ENABLE)
TracyPlot(name, value);
#else
(void)name;
(void)value;
#endif
}
inline void PlotValue(const char *name, const float value)
{
#if defined(PROJECTV_ENABLE_TRACY) && defined(TRACY_ENABLE)
TracyPlot(name, value);
#else
(void)name;
(void)value;
#endif
}
inline void PlotValue(const char *name, const double value)
{
#if defined(PROJECTV_ENABLE_TRACY) && defined(TRACY_ENABLE)
TracyPlot(name, value);
#else
(void)name;
(void)value;
#endif
}
inline void RecordAllocation(
const void *pointer,
const size_t size,
const char *name = nullptr)
{
#if defined(PROJECTV_ENABLE_TRACY) && defined(TRACY_ENABLE)
if (pointer == nullptr) {
return;
}
if (name != nullptr) { // NOLINT(bugprone-branch-clone): named vs default Tracy macros are different
TracyAllocN(pointer, size, name);
} else {
TracyAlloc(pointer, size);
}
#else
(void)pointer;
(void)size;
(void)name;
#endif
}
inline void RecordFree(
const void *pointer,
const char *name = nullptr)
{
#if defined(PROJECTV_ENABLE_TRACY) && defined(TRACY_ENABLE)
if (pointer == nullptr) {
return;
}
if (name != nullptr) { // NOLINT(bugprone-branch-clone): named vs default Tracy macros are different
TracyFreeN(pointer, name);
} else {
TracyFree(pointer);
}
#else
(void)pointer;
(void)name;
#endif
}
} // namespace profiling