Kaynağa Gözat

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 <marek.olsak@amd.com>
tags/18.0-branchpoint
Brian Paul 7 yıl önce
ebeveyn
işleme
92840bd276

+ 5
- 0
src/gallium/auxiliary/hud/hud_context.c Dosyayı Görüntüle

@@ -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;

+ 24
- 3
src/gallium/auxiliary/hud/hud_driver_query.c Dosyayı Görüntüle

@@ -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))

Loading…
İptal
Kaydet