30#define MAX_TIMER_NAME 32
31#define MAX_NESTED_TIMER 8
32#define MIM_RANGE_LEN 8
33#define GPU_TIMER_FALLOFF 0.1
55 if (
DTP.timers !=
nullptr) {
67 if (
G.debug_value > 20 &&
G.debug_value < 30) {
68 DTP.is_recording =
true;
71 if (
DTP.is_recording &&
DTP.timers ==
nullptr) {
77 else if (!
DTP.is_recording &&
DTP.timers !=
nullptr) {
81 DTP.is_querying =
false;
82 DTP.timer_increment = 0;
83 DTP.end_increment = 0;
96 return &
DTP.timers[
DTP.timer_increment++];
101 if (
DTP.is_recording) {
104 timer->lvl =
DTP.timer_increment -
DTP.end_increment - 1;
105 timer->is_query = is_query;
109 if (
timer->is_query) {
110 if (
timer->query[0] == 0) {
117 DTP.is_querying =
true;
132 if (
DTP.is_recording) {
147 if (
DTP.is_recording) {
151 DTP.is_querying =
false;
158 "You forgot a DRW_stats_group/query_end somewhere!");
160 "You forgot a DRW_stats_group/query_start somewhere!");
162 if (
DTP.is_recording) {
166 for (
int i =
DTP.timer_increment - 1; i >= 0; i--) {
172 if (
timer->is_query) {
174 if (
timer->query[0] != 0) {
186 timer->time_average = lvl_time[
timer->lvl + 1];
187 lvl_time[
timer->lvl + 1] = 0;
193 DTP.is_recording =
false;
200 rect->
ymax - (3 +
v) *
U.widget_unit,
209 rect->
xmin + (1 + u) *
U.widget_unit, rect->
ymax - (3 +
v) *
U.widget_unit, 0.0f, txt,
size);
214 char stat_string[64];
218 double init_tot_time = 0.0, background_tot_time = 0.0, render_tot_time = 0.0, tot_time = 0.0;
233 STRNCPY(col_label,
"Background");
237 STRNCPY(col_label,
"Total (w/o cache)");
242 char time_to_txt[16];
248 init_tot_time +=
data->init_time;
252 background_tot_time +=
data->background_time;
256 render_tot_time +=
data->render_time;
260 tot_time +=
data->init_time +
data->background_time +
data->render_time;
268 STRNCPY(col_label,
"Sub Total");
270 SNPRINTF(time_to_txt,
"%.2fms", init_tot_time);
272 SNPRINTF(time_to_txt,
"%.2fms", background_tot_time);
274 SNPRINTF(time_to_txt,
"%.2fms", render_tot_time);
276 SNPRINTF(time_to_txt,
"%.2fms", tot_time);
282 STRNCPY(col_label,
"Cache Time");
284 SNPRINTF(time_to_txt,
"%.2fms", *cache_time);
296 STRNCPY(stat_string,
"GPU Memory");
297 draw_stat(rect, 0,
v, stat_string,
sizeof(stat_string));
298 SNPRINTF(stat_string,
"%.2fMB",
double(tex_mem + vbo_mem) / 1000000.0);
300 STRNCPY(stat_string,
"Textures");
301 draw_stat(rect, 1,
v, stat_string,
sizeof(stat_string));
302 SNPRINTF(stat_string,
"%.2fMB",
double(tex_mem) / 1000000.0);
304 STRNCPY(stat_string,
"Meshes");
305 draw_stat(rect, 1,
v, stat_string,
sizeof(stat_string));
306 SNPRINTF(stat_string,
"%.2fMB",
double(vbo_mem) / 1000000.0);
311 STRNCPY(stat_string,
"GPU Render Timings");
312 draw_stat(rect, 0,
v++, stat_string,
sizeof(stat_string));
314 for (
int i = 0; i <
DTP.timer_increment; i++) {
315 double time_ms, time_percent;
320 if ((
G.debug_value - 21) <
timer->lvl) {
325 lvl_index[
timer->lvl] = i;
327 time_ms =
timer->time_average / 1000000.0;
329 if (timer_parent !=
nullptr) {
333 time_percent = 100.0;
337 time_ms = std::min(time_ms, 999.0);
338 time_percent = std::min(time_percent, 100.0);
342 SNPRINTF(stat_string,
"%.2fms", time_ms);
344 SNPRINTF(stat_string,
"%.0f", time_percent);
void BLF_batch_draw_begin()
void BLF_batch_draw_end()
void BLF_draw_default(float x, float y, float z, const char *str, size_t str_len) ATTR_NONNULL()
#define BLI_assert_msg(a, msg)
#define STRNCPY(dst, src)
#define SNPRINTF(dst, format,...)
typedef double(DMatrix)[4][4]
void GPU_debug_group_end()
void GPU_debug_group_begin(const char *name)
unsigned int GPU_texture_memory_usage_get()
uint GPU_vertbuf_get_memory_usage()
Read Guarded memory(de)allocation.
#define MEM_recallocN(vmemh, len)
void UI_FontThemeColor(int fontid, int colorid)
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void DRW_stats_group_start(const char *name)
void DRW_stats_query_start(const char *name)
static struct DRWTimerPool DTP
void DRW_stats_group_end()
void DRW_stats_draw(const rcti *rect)
static DRWTimer * drw_stats_timer_get()
static void drw_stats_timer_start_ex(const char *name, const bool is_query)
void DRW_stats_query_end()
#define GPU_TIMER_FALLOFF
static void draw_stat_5row(const rcti *rect, int u, int v, const char *txt, const int size)
static void draw_stat(const rcti *rect, int u, int v, const char *txt, const int size)
double * DRW_view_data_cache_time_get(DRWViewData *view_data)
#define DRW_ENABLED_ENGINE_ITER(view_data_, engine_, data_)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
unsigned __int64 uint64_t
char name[MAX_TIMER_NAME]