diff options
-rw-r--r-- | src/gallium/auxiliary/hud/hud_context.c | 9 | ||||
-rw-r--r-- | src/gallium/auxiliary/hud/hud_cpu.c | 74 | ||||
-rw-r--r-- | src/gallium/auxiliary/hud/hud_private.h | 8 |
3 files changed, 91 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index 9ab78223662..8172313605d 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -1153,6 +1153,15 @@ hud_parse_env_var(struct hud_context *hud, const char *env) else if (strcmp(name, "API-thread-busy") == 0) { hud_thread_busy_install(pane, name, false); } + else if (strcmp(name, "API-thread-offloaded-slots") == 0) { + hud_thread_counter_install(pane, name, HUD_COUNTER_OFFLOADED); + } + else if (strcmp(name, "API-thread-direct-slots") == 0) { + hud_thread_counter_install(pane, name, HUD_COUNTER_DIRECT); + } + else if (strcmp(name, "API-thread-num-syncs") == 0) { + hud_thread_counter_install(pane, name, HUD_COUNTER_SYNCS); + } else if (strcmp(name, "main-thread-busy") == 0) { hud_thread_busy_install(pane, name, true); } diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c index 38403f9f78a..4caaab6977e 100644 --- a/src/gallium/auxiliary/hud/hud_cpu.c +++ b/src/gallium/auxiliary/hud/hud_cpu.c @@ -307,3 +307,77 @@ hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main) hud_pane_add_graph(pane, gr); hud_pane_set_max_value(pane, 100); } + +struct counter_info { + enum hud_counter counter; + unsigned last_value; + int64_t last_time; +}; + +static unsigned get_counter(struct hud_graph *gr, enum hud_counter counter) +{ + struct util_queue_monitoring *mon = gr->pane->hud->monitored_queue; + + if (!mon || !mon->queue) + return 0; + + switch (counter) { + case HUD_COUNTER_OFFLOADED: + return mon->num_offloaded_items; + case HUD_COUNTER_DIRECT: + return mon->num_direct_items; + case HUD_COUNTER_SYNCS: + return mon->num_syncs; + default: + assert(0); + return 0; + } +} + +static void +query_thread_counter(struct hud_graph *gr) +{ + struct counter_info *info = gr->query_data; + int64_t now = os_time_get_nano(); + + if (info->last_time) { + if (info->last_time + gr->pane->period*1000 <= now) { + unsigned current_value = get_counter(gr, info->counter); + + hud_graph_add_value(gr, current_value - info->last_value); + info->last_value = current_value; + info->last_time = now; + } + } else { + /* initialize */ + info->last_value = get_counter(gr, info->counter); + info->last_time = now; + } +} + +void hud_thread_counter_install(struct hud_pane *pane, const char *name, + enum hud_counter counter) +{ + struct hud_graph *gr = CALLOC_STRUCT(hud_graph); + if (!gr) + return; + + strcpy(gr->name, name); + + gr->query_data = CALLOC_STRUCT(counter_info); + if (!gr->query_data) { + FREE(gr); + return; + } + + ((struct counter_info*)gr->query_data)->counter = counter; + gr->query_new_value = query_thread_counter; + + /* Don't use free() as our callback as that messes up Gallium's + * memory debugger. Use simple free_query_data() wrapper. + */ + gr->free_query_data = free_query_data; + + hud_pane_add_graph(pane, gr); + hud_pane_set_max_value(pane, 100); +} diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h index b8726da7342..2b1717d2c4a 100644 --- a/src/gallium/auxiliary/hud/hud_private.h +++ b/src/gallium/auxiliary/hud/hud_private.h @@ -33,6 +33,12 @@ #include "util/list.h" #include "hud/font.h" +enum hud_counter { + HUD_COUNTER_OFFLOADED, + HUD_COUNTER_DIRECT, + HUD_COUNTER_SYNCS, +}; + struct hud_context { struct pipe_context *pipe; struct cso_context *cso; @@ -145,6 +151,8 @@ int hud_get_num_cpus(void); void hud_fps_graph_install(struct hud_pane *pane); void hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index); void hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main); +void hud_thread_counter_install(struct hud_pane *pane, const char *name, + enum hud_counter counter); void hud_pipe_query_install(struct hud_batch_query_context **pbq, struct hud_pane *pane, struct pipe_context *pipe, const char *name, unsigned query_type, |