[Mesa-dev] [RFC 1/2] hud: Handle query values according to their type
Marek Olšák
maraeo at gmail.com
Tue Jun 13 15:11:30 UTC 2017
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Marek
On Sun, Jun 11, 2017 at 3:52 PM, Boyan Ding <boyan.j.ding at gmail.com> wrote:
> Signed-off-by: Boyan Ding <boyan.j.ding at gmail.com>
> ---
> src/gallium/auxiliary/hud/hud_driver_query.c | 22 +++++++++++++++++++---
> 1 file changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c b/src/gallium/auxiliary/hud/hud_driver_query.c
> index 76104b5b49..7a469bd1bd 100644
> --- a/src/gallium/auxiliary/hud/hud_driver_query.c
> +++ b/src/gallium/auxiliary/hud/hud_driver_query.c
> @@ -202,6 +202,7 @@ struct query_info {
> unsigned query_type;
> unsigned result_index; /* unit depends on query_type */
> 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];
> @@ -229,6 +230,19 @@ query_new_value_batch(struct query_info *info)
> }
> }
>
> +static uint64_t
> +query_result_to_u64(union pipe_query_result result,
> + enum pipe_driver_query_type type)
> +{
> + switch (type) {
> + case PIPE_DRIVER_QUERY_TYPE_PERCENTAGE:
> + case PIPE_DRIVER_QUERY_TYPE_FLOAT:
> + return result.f;
> + default:
> + return result.u64;
> + }
> +}
> +
> static void
> query_new_value_normal(struct query_info *info)
> {
> @@ -242,10 +256,11 @@ query_new_value_normal(struct query_info *info)
> while (1) {
> struct pipe_query *query = info->query[info->tail];
> union pipe_query_result result;
> - uint64_t *res64 = (uint64_t *)&result;
> + union pipe_query_result *presult = &result;
>
> - if (query && pipe->get_query_result(pipe, query, FALSE, &result)) {
> - info->results_cumulative += res64[info->result_index];
> + if (query && pipe->get_query_result(pipe, query, FALSE, presult)) {
> + info->results_cumulative +=
> + query_result_to_u64(presult[info->result_index], info->type);
> info->num_results++;
>
> if (info->tail == info->head)
> @@ -383,6 +398,7 @@ hud_pipe_query_install(struct hud_batch_query_context **pbq,
> info = gr->query_data;
> info->pipe = pipe;
> info->result_type = result_type;
> + info->type = type;
>
> if (flags & PIPE_DRIVER_QUERY_FLAG_BATCH) {
> if (!batch_query_add(pbq, pipe, query_type, &info->result_index))
> --
> 2.13.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list