gallium/hud: add glthread counters
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
parent
8f4bc8a324
commit
09f6915bf8
|
@ -1153,6 +1153,15 @@ hud_parse_env_var(struct hud_context *hud, const char *env)
|
||||||
else if (strcmp(name, "API-thread-busy") == 0) {
|
else if (strcmp(name, "API-thread-busy") == 0) {
|
||||||
hud_thread_busy_install(pane, name, false);
|
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) {
|
else if (strcmp(name, "main-thread-busy") == 0) {
|
||||||
hud_thread_busy_install(pane, name, true);
|
hud_thread_busy_install(pane, name, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_add_graph(pane, gr);
|
||||||
hud_pane_set_max_value(pane, 100);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,12 @@
|
||||||
#include "util/list.h"
|
#include "util/list.h"
|
||||||
#include "hud/font.h"
|
#include "hud/font.h"
|
||||||
|
|
||||||
|
enum hud_counter {
|
||||||
|
HUD_COUNTER_OFFLOADED,
|
||||||
|
HUD_COUNTER_DIRECT,
|
||||||
|
HUD_COUNTER_SYNCS,
|
||||||
|
};
|
||||||
|
|
||||||
struct hud_context {
|
struct hud_context {
|
||||||
struct pipe_context *pipe;
|
struct pipe_context *pipe;
|
||||||
struct cso_context *cso;
|
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_fps_graph_install(struct hud_pane *pane);
|
||||||
void hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index);
|
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_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,
|
void hud_pipe_query_install(struct hud_batch_query_context **pbq,
|
||||||
struct hud_pane *pane, struct pipe_context *pipe,
|
struct hud_pane *pane, struct pipe_context *pipe,
|
||||||
const char *name, unsigned query_type,
|
const char *name, unsigned query_type,
|
||||||
|
|
Loading…
Reference in New Issue