diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index b76981fdc54..ea0a294a320 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -1276,6 +1276,9 @@ hud_parse_env_var(struct hud_context *hud, struct pipe_screen *screen, else if (strcmp(name, "API-thread-num-syncs") == 0) { hud_thread_counter_install(pane, name, HUD_COUNTER_SYNCS); } + else if (strcmp(name, "API-thread-num-batches") == 0) { + hud_thread_counter_install(pane, name, HUD_COUNTER_BATCHES); + } 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 767bff48841..820e7d71007 100644 --- a/src/gallium/auxiliary/hud/hud_cpu.c +++ b/src/gallium/auxiliary/hud/hud_cpu.c @@ -395,24 +395,35 @@ hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main) 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; + unsigned value; if (!mon || !mon->queue) return 0; + /* Reset the counters to 0 to only display values for 1 frame. */ switch (counter) { case HUD_COUNTER_OFFLOADED: - return mon->num_offloaded_items; + value = mon->num_offloaded_items; + mon->num_offloaded_items = 0; + return value; case HUD_COUNTER_DIRECT: - return mon->num_direct_items; + value = mon->num_direct_items; + mon->num_direct_items = 0; + return value; case HUD_COUNTER_SYNCS: - return mon->num_syncs; + value = mon->num_syncs; + mon->num_syncs = 0; + return value; + case HUD_COUNTER_BATCHES: + value = mon->num_batches; + mon->num_batches = 0; + return value; default: assert(0); return 0; @@ -424,18 +435,15 @@ query_thread_counter(struct hud_graph *gr, struct pipe_context *pipe) { struct counter_info *info = gr->query_data; int64_t now = os_time_get_nano(); + unsigned value = get_counter(gr, info->counter); 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; + hud_graph_add_value(gr, value); info->last_time = now; } } else { /* initialize */ - info->last_value = get_counter(gr, info->counter); info->last_time = now; } } diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h index b8ee49532e2..3604760c74f 100644 --- a/src/gallium/auxiliary/hud/hud_private.h +++ b/src/gallium/auxiliary/hud/hud_private.h @@ -38,6 +38,7 @@ enum hud_counter { HUD_COUNTER_OFFLOADED, HUD_COUNTER_DIRECT, HUD_COUNTER_SYNCS, + HUD_COUNTER_BATCHES, }; struct hud_context { diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c index 66436fa0c58..b44ff9b1d8d 100644 --- a/src/mesa/main/glthread.c +++ b/src/mesa/main/glthread.c @@ -78,6 +78,8 @@ glthread_unmarshal_batch(void *job, void *gdata, int thread_index) /* Atomically set this to -1 if it's equal to batch_index. */ p_atomic_cmpxchg(&ctx->GLThread.LastProgramChangeBatch, batch_index, -1); p_atomic_cmpxchg(&ctx->GLThread.LastDListChangeBatchIndex, batch_index, -1); + + p_atomic_inc(&ctx->GLThread.stats.num_batches); } static void diff --git a/src/util/u_queue.h b/src/util/u_queue.h index 2da74c5b19b..b46b179b846 100644 --- a/src/util/u_queue.h +++ b/src/util/u_queue.h @@ -273,6 +273,7 @@ struct util_queue_monitoring unsigned num_offloaded_items; unsigned num_direct_items; unsigned num_syncs; + unsigned num_batches; }; #ifdef __cplusplus