summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/hud/hud_context.c5
-rw-r--r--src/gallium/auxiliary/hud/hud_driver_query.c27
2 files changed, 29 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index 64e5579b4e2..4d2458eb2e4 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -224,6 +224,7 @@ number_to_human_readable(double num, enum pipe_driver_query_type type,
static const char *volt_units[] = {" mV", " V"};
static const char *amp_units[] = {" mA", " A"};
static const char *watt_units[] = {" mW", " W"};
+ static const char *float_units[] = {""};
const char **units;
unsigned max_unit;
@@ -252,6 +253,10 @@ number_to_human_readable(double num, enum pipe_driver_query_type type,
max_unit = ARRAY_SIZE(temperature_units)-1;
units = temperature_units;
break;
+ case PIPE_DRIVER_QUERY_TYPE_FLOAT:
+ max_unit = ARRAY_SIZE(float_units)-1;
+ units = float_units;
+ break;
case PIPE_DRIVER_QUERY_TYPE_PERCENTAGE:
max_unit = ARRAY_SIZE(percent_units)-1;
units = percent_units;
diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c b/src/gallium/auxiliary/hud/hud_driver_query.c
index 630aae0118f..382de1af028 100644
--- a/src/gallium/auxiliary/hud/hud_driver_query.c
+++ b/src/gallium/auxiliary/hud/hud_driver_query.c
@@ -195,8 +195,13 @@ hud_batch_query_cleanup(struct hud_batch_query_context **pbq,
struct query_info {
struct hud_batch_query_context *batch;
enum pipe_query_type query_type;
- unsigned result_index; /* unit depends on query_type */
+
+ /** index to choose fields in pipe_query_data_pipeline_statistics,
+ * for example.
+ */
+ unsigned result_index;
enum pipe_driver_query_result_type result_type;
+ enum pipe_driver_query_type type;
/* Ring of queries. If a query is busy, we use another slot. */
struct pipe_query *query[NUM_QUERIES];
@@ -238,7 +243,13 @@ query_new_value_normal(struct query_info *info, struct pipe_context *pipe)
uint64_t *res64 = (uint64_t *)&result;
if (query && pipe->get_query_result(pipe, query, FALSE, &result)) {
- info->results_cumulative += res64[info->result_index];
+ if (info->type == PIPE_DRIVER_QUERY_TYPE_FLOAT) {
+ assert(info->result_index == 0);
+ info->results_cumulative += (uint64_t) (result.f * 1000.0f);
+ }
+ else {
+ info->results_cumulative += res64[info->result_index];
+ }
info->num_results++;
if (info->tail == info->head)
@@ -307,7 +318,7 @@ query_new_value(struct hud_graph *gr, struct pipe_context *pipe)
}
if (info->num_results && info->last_time + gr->pane->period <= now) {
- uint64_t value;
+ double value;
switch (info->result_type) {
default:
@@ -319,6 +330,10 @@ query_new_value(struct hud_graph *gr, struct pipe_context *pipe)
break;
}
+ if (info->type == PIPE_DRIVER_QUERY_TYPE_FLOAT) {
+ value /= 1000.0;
+ }
+
hud_graph_add_value(gr, value);
info->last_time = now;
@@ -346,6 +361,11 @@ free_query_info(void *ptr, struct pipe_context *pipe)
FREE(info);
}
+
+/**
+ * \param result_index to select fields of pipe_query_data_pipeline_statistics,
+ * for example.
+ */
void
hud_pipe_query_install(struct hud_batch_query_context **pbq,
struct hud_pane *pane,
@@ -374,6 +394,7 @@ hud_pipe_query_install(struct hud_batch_query_context **pbq,
info = gr->query_data;
info->result_type = result_type;
+ info->type = type;
if (flags & PIPE_DRIVER_QUERY_FLAG_BATCH) {
if (!batch_query_add(pbq, query_type, &info->result_index))