diff options
author | Marek Olšák <[email protected]> | 2017-02-19 19:29:06 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-02-22 20:26:39 +0100 |
commit | 3b04566bba9d86523df8a5afa332610ed114478a (patch) | |
tree | 9299ea4ff314982c78956247cdce5b7ae6fb617e /src/gallium/auxiliary | |
parent | 31e7ba71249f3e493e65bd497d40eca3b15147be (diff) |
gallium/hud: handle a thread switch for API-thread-busy monitoring
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/hud/hud_cpu.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c index 1cba353603d..302445d19b7 100644 --- a/src/gallium/auxiliary/hud/hud_cpu.c +++ b/src/gallium/auxiliary/hud/hud_cpu.c @@ -244,10 +244,16 @@ query_api_thread_busy_status(struct hud_graph *gr) if (info->last_time) { if (info->last_time + gr->pane->period*1000 <= now) { int64_t thread_now = pipe_current_thread_get_time_nano(); - - hud_graph_add_value(gr, - (thread_now - info->last_thread_time) * 100 / - (now - info->last_time)); + unsigned percent = (thread_now - info->last_thread_time) * 100 / + (now - info->last_time); + + /* Check if the context changed a thread, so that we don't show + * a random value. When a thread is changed, the new thread clock + * is different, which can result in "percent" being very high. + */ + if (percent > 100) + percent = 0; + hud_graph_add_value(gr, percent); info->last_thread_time = thread_now; info->last_time = now; |