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;
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;
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];
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)
}
if (info->num_results && info->last_time + gr->pane->period <= now) {
- uint64_t value;
+ double value;
switch (info->result_type) {
default:
break;
}
+ if (info->type == PIPE_DRIVER_QUERY_TYPE_FLOAT) {
+ value /= 1000.0;
+ }
+
hud_graph_add_value(gr, value);
info->last_time = now;
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,
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))