diff options
author | Brian Paul <[email protected]> | 2018-01-11 11:11:04 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2018-01-17 11:17:56 -0700 |
commit | 92840bd27683996d1de86fbc5b95be798f99796b (patch) | |
tree | 6cf1801677dc430639a5db9dff44e0a08fab7d16 /src/gallium/auxiliary | |
parent | 23a5fae317c40285956cee383b2ab774f84058d6 (diff) |
gallium/hud: Fix support for PIPE_DRIVER_QUERY_TYPE_FLOAT
Evidently, nobody has used PIPE_DRIVER_QUERY_TYPE_FLOAT up to this
point. Adding a driver query of this type which returns the query
value in pipe_query_result::f resulted in garbage output in the HUD.
The problem is the pipe_query_result::f field was being accessed as
through the u64 field and being added to the query_info::results_cumulative
field. This patch checks for PIPE_DRIVER_QUERY_TYPE_FLOAT in a few
places and scales the float by 1000 before converting to uint64_t.
Also, add some comments to explain the query_info::result_index field.
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/hud/hud_context.c | 5 | ||||
-rw-r--r-- | src/gallium/auxiliary/hud/hud_driver_query.c | 27 |
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)) |