[Mesa-dev] [PATCH 04/12] gallium/hud: pass pipe_context explicitly to most functions

Marek Olšák maraeo at gmail.com
Tue Nov 21 17:46:04 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/auxiliary/hud/hud_context.c      | 38 ++++++++++-----------
 src/gallium/auxiliary/hud/hud_cpu.c          |  8 ++---
 src/gallium/auxiliary/hud/hud_driver_query.c | 51 +++++++++++-----------------
 src/gallium/auxiliary/hud/hud_fps.c          |  4 +--
 src/gallium/auxiliary/hud/hud_private.h      | 20 ++++++-----
 5 files changed, 57 insertions(+), 64 deletions(-)

diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index 83b3204..d54bd63 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -577,53 +577,53 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
          hud_pane_draw_colored_objects(hud, pane);
    }
 
    cso_restore_state(cso);
    cso_restore_constant_buffer_slot0(cso, PIPE_SHADER_VERTEX);
 
    pipe_surface_reference(&surf, NULL);
 }
 
 static void
-hud_start_queries(struct hud_context *hud)
+hud_start_queries(struct hud_context *hud, struct pipe_context *pipe)
 {
    struct hud_pane *pane;
    struct hud_graph *gr;
 
    /* Start queries. */
-   hud_batch_query_begin(hud->batch_query);
+   hud_batch_query_begin(hud->batch_query, pipe);
 
    LIST_FOR_EACH_ENTRY(pane, &hud->pane_list, head) {
       LIST_FOR_EACH_ENTRY(gr, &pane->graph_list, head) {
          if (gr->begin_query)
-            gr->begin_query(gr);
+            gr->begin_query(gr, pipe);
       }
    }
 }
 
 /* Stop queries, query results, and record vertices for charts. */
 static void
-hud_stop_queries(struct hud_context *hud)
+hud_stop_queries(struct hud_context *hud, struct pipe_context *pipe)
 {
    struct hud_pane *pane;
    struct hud_graph *gr, *next;
 
    /* prepare vertex buffers */
    hud_prepare_vertices(hud, &hud->bg, 16 * 256, 2 * sizeof(float));
    hud_prepare_vertices(hud, &hud->whitelines, 4 * 256, 2 * sizeof(float));
    hud_prepare_vertices(hud, &hud->text, 16 * 1024, 4 * sizeof(float));
    hud_prepare_vertices(hud, &hud->color_prims, 32 * 1024, 2 * sizeof(float));
 
    /* Allocate everything once and divide the storage into 3 portions
     * manually, because u_upload_alloc can unmap memory from previous calls.
     */
-   u_upload_alloc(hud->pipe->stream_uploader, 0,
+   u_upload_alloc(pipe->stream_uploader, 0,
                   hud->bg.buffer_size +
                   hud->whitelines.buffer_size +
                   hud->text.buffer_size +
                   hud->color_prims.buffer_size,
                   16, &hud->bg.vbuf.buffer_offset, &hud->bg.vbuf.buffer.resource,
                   (void**)&hud->bg.vertices);
    if (!hud->bg.vertices)
       return;
 
    pipe_resource_reference(&hud->whitelines.vbuf.buffer.resource, hud->bg.vbuf.buffer.resource);
@@ -639,25 +639,25 @@ hud_stop_queries(struct hud_context *hud)
                                   hud->whitelines.buffer_size;
    hud->text.vertices = hud->whitelines.vertices +
                         hud->whitelines.buffer_size / sizeof(float);
 
    hud->color_prims.vbuf.buffer_offset = hud->text.vbuf.buffer_offset +
                                          hud->text.buffer_size;
    hud->color_prims.vertices = hud->text.vertices +
                                hud->text.buffer_size / sizeof(float);
 
    /* prepare all graphs */
-   hud_batch_query_update(hud->batch_query);
+   hud_batch_query_update(hud->batch_query, pipe);
 
    LIST_FOR_EACH_ENTRY(pane, &hud->pane_list, head) {
       LIST_FOR_EACH_ENTRY(gr, &pane->graph_list, head) {
-         gr->query_new_value(gr);
+         gr->query_new_value(gr, pipe);
       }
 
       if (pane->sort_items) {
          LIST_FOR_EACH_ENTRY_SAFE(gr, next, &pane->graph_list, head) {
             /* ignore the last one */
             if (&gr->head == pane->graph_list.prev)
                continue;
 
             /* This is an incremental bubble sort, because we only do one pass
              * per frame. It will eventually reach an equilibrium.
@@ -667,29 +667,29 @@ hud_stop_queries(struct hud_context *hud)
                LIST_DEL(&gr->head);
                LIST_ADD(&gr->head, &next->head);
             }
          }
       }
 
       hud_pane_accumulate_vertices(hud, pane);
    }
 
    /* unmap the uploader's vertex buffer before drawing */
-   u_upload_unmap(hud->pipe->stream_uploader);
+   u_upload_unmap(pipe->stream_uploader);
 }
 
 void
 hud_run(struct hud_context *hud, struct pipe_resource *tex)
 {
-   hud_stop_queries(hud);
+   hud_stop_queries(hud, hud->pipe);
    hud_draw_results(hud, tex);
-   hud_start_queries(hud);
+   hud_start_queries(hud, hud->pipe);
 }
 
 static void
 fixup_bytes(enum pipe_driver_query_type type, int position, uint64_t *exp10)
 {
    if (type == PIPE_DRIVER_QUERY_TYPE_BYTES && position % 3 == 0)
       *exp10 = (*exp10 / 1000) * 1024;
 }
 
 /**
@@ -910,25 +910,25 @@ hud_graph_add_value(struct hud_graph *gr, double value)
 
    if (gr->pane->dyn_ceiling == true) {
       hud_pane_update_dyn_ceiling(gr, gr->pane);
    }
    if (value > gr->pane->max_value) {
       hud_pane_set_max_value(gr->pane, value);
    }
 }
 
 static void
-hud_graph_destroy(struct hud_graph *graph)
+hud_graph_destroy(struct hud_graph *graph, struct pipe_context *pipe)
 {
    FREE(graph->vertices);
    if (graph->free_query_data)
-      graph->free_query_data(graph->query_data);
+      graph->free_query_data(graph->query_data, pipe);
    if (graph->fd)
       fclose(graph->fd);
    FREE(graph);
 }
 
 static void strcat_without_spaces(char *dst, const char *src)
 {
    dst += strlen(dst);
    while (*src) {
       if (*src == ' ')
@@ -1245,30 +1245,30 @@ hud_parse_env_var(struct hud_context *hud, const char *env)
          pane->type = PIPE_DRIVER_QUERY_TYPE_AMPS;
       }
       else if (sscanf(name, "sensors_pow_cu-%s", arg_name) == 1) {
          hud_sensors_temp_graph_install(pane, arg_name,
                                         SENSORS_POWER_CURRENT);
          pane->type = PIPE_DRIVER_QUERY_TYPE_WATTS;
       }
 #endif
       else if (strcmp(name, "samples-passed") == 0 &&
                has_occlusion_query(hud->pipe->screen)) {
-         hud_pipe_query_install(&hud->batch_query, pane, hud->pipe,
+         hud_pipe_query_install(&hud->batch_query, pane,
                                 "samples-passed",
                                 PIPE_QUERY_OCCLUSION_COUNTER, 0, 0,
                                 PIPE_DRIVER_QUERY_TYPE_UINT64,
                                 PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE,
                                 0);
       }
       else if (strcmp(name, "primitives-generated") == 0 &&
                has_streamout(hud->pipe->screen)) {
-         hud_pipe_query_install(&hud->batch_query, pane, hud->pipe,
+         hud_pipe_query_install(&hud->batch_query, pane,
                                 "primitives-generated",
                                 PIPE_QUERY_PRIMITIVES_GENERATED, 0, 0,
                                 PIPE_DRIVER_QUERY_TYPE_UINT64,
                                 PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE,
                                 0);
       }
       else {
          boolean processed = FALSE;
 
          /* pipeline statistics queries */
@@ -1284,33 +1284,33 @@ hud_parse_env_var(struct hud_context *hud, const char *env)
                "clipper-primitives-generated",
                "ps-invocations",
                "hs-invocations",
                "ds-invocations",
                "cs-invocations"
             };
             for (i = 0; i < ARRAY_SIZE(pipeline_statistics_names); ++i)
                if (strcmp(name, pipeline_statistics_names[i]) == 0)
                   break;
             if (i < ARRAY_SIZE(pipeline_statistics_names)) {
-               hud_pipe_query_install(&hud->batch_query, pane, hud->pipe, name,
+               hud_pipe_query_install(&hud->batch_query, pane, name,
                                       PIPE_QUERY_PIPELINE_STATISTICS, i,
                                       0, PIPE_DRIVER_QUERY_TYPE_UINT64,
                                       PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE,
                                       0);
                processed = TRUE;
             }
          }
 
          /* driver queries */
          if (!processed) {
-            if (!hud_driver_query_install(&hud->batch_query, pane, hud->pipe,
-                                          name)) {
+            if (!hud_driver_query_install(&hud->batch_query, pane,
+                                          hud->pipe->screen, name)) {
                fprintf(stderr, "gallium_hud: unknown driver query '%s'\n", name);
                fflush(stderr);
             }
          }
       }
 
       if (*env == ':') {
          env++;
 
          if (!pane) {
@@ -1713,27 +1713,27 @@ hud_create(struct pipe_context *pipe, struct cso_context *cso)
 void
 hud_destroy(struct hud_context *hud)
 {
    struct pipe_context *pipe = hud->pipe;
    struct hud_pane *pane, *pane_tmp;
    struct hud_graph *graph, *graph_tmp;
 
    LIST_FOR_EACH_ENTRY_SAFE(pane, pane_tmp, &hud->pane_list, head) {
       LIST_FOR_EACH_ENTRY_SAFE(graph, graph_tmp, &pane->graph_list, head) {
          LIST_DEL(&graph->head);
-         hud_graph_destroy(graph);
+         hud_graph_destroy(graph, pipe);
       }
       LIST_DEL(&pane->head);
       FREE(pane);
    }
 
-   hud_batch_query_cleanup(&hud->batch_query);
+   hud_batch_query_cleanup(&hud->batch_query, pipe);
    pipe->delete_fs_state(pipe, hud->fs_color);
    pipe->delete_fs_state(pipe, hud->fs_text);
    pipe->delete_vs_state(pipe, hud->vs);
    pipe_sampler_view_reference(&hud->font_sampler_view, NULL);
    pipe_resource_reference(&hud->font.texture, NULL);
    FREE(hud);
 }
 
 void
 hud_add_queue_for_monitoring(struct hud_context *hud,
diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c
index 581dad6..259bb83 100644
--- a/src/gallium/auxiliary/hud/hud_cpu.c
+++ b/src/gallium/auxiliary/hud/hud_cpu.c
@@ -137,21 +137,21 @@ get_cpu_stats(unsigned cpu_index, uint64_t *busy_time, uint64_t *total_time)
 }
 #endif
 
 
 struct cpu_info {
    unsigned cpu_index;
    uint64_t last_cpu_busy, last_cpu_total, last_time;
 };
 
 static void
-query_cpu_load(struct hud_graph *gr)
+query_cpu_load(struct hud_graph *gr, struct pipe_context *pipe)
 {
    struct cpu_info *info = gr->query_data;
    uint64_t now = os_time_get();
 
    if (info->last_time) {
       if (info->last_time + gr->pane->period <= now) {
          uint64_t cpu_busy, cpu_total, cpu_load;
 
          get_cpu_stats(info->cpu_index, &cpu_busy, &cpu_total);
 
@@ -166,21 +166,21 @@ query_cpu_load(struct hud_graph *gr)
    }
    else {
       /* initialize */
       info->last_time = now;
       get_cpu_stats(info->cpu_index, &info->last_cpu_busy,
                     &info->last_cpu_total);
    }
 }
 
 static void
-free_query_data(void *p)
+free_query_data(void *p, struct pipe_context *pipe)
 {
    FREE(p);
 }
 
 void
 hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index)
 {
    struct hud_graph *gr;
    struct cpu_info *info;
    uint64_t busy, total;
@@ -231,21 +231,21 @@ hud_get_num_cpus(void)
    return i;
 }
 
 struct thread_info {
    bool main_thread;
    int64_t last_time;
    int64_t last_thread_time;
 };
 
 static void
-query_api_thread_busy_status(struct hud_graph *gr)
+query_api_thread_busy_status(struct hud_graph *gr, struct pipe_context *pipe)
 {
    struct thread_info *info = gr->query_data;
    int64_t now = os_time_get_nano();
 
    if (info->last_time) {
       if (info->last_time + gr->pane->period*1000 <= now) {
          int64_t thread_now;
 
          if (info->main_thread) {
             thread_now = pipe_current_thread_get_time_nano();
@@ -328,21 +328,21 @@ static unsigned get_counter(struct hud_graph *gr, enum hud_counter counter)
       return mon->num_direct_items;
    case HUD_COUNTER_SYNCS:
       return mon->num_syncs;
    default:
       assert(0);
       return 0;
    }
 }
 
 static void
-query_thread_counter(struct hud_graph *gr)
+query_thread_counter(struct hud_graph *gr, struct pipe_context *pipe)
 {
    struct counter_info *info = gr->query_data;
    int64_t now = os_time_get_nano();
 
    if (info->last_time) {
       if (info->last_time + gr->pane->period*1000 <= now) {
          unsigned current_value = get_counter(gr, info->counter);
 
          hud_graph_add_value(gr, current_value - info->last_value);
          info->last_value = current_value;
diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c b/src/gallium/auxiliary/hud/hud_driver_query.c
index 8b1e4e1..085bc62 100644
--- a/src/gallium/auxiliary/hud/hud_driver_query.c
+++ b/src/gallium/auxiliary/hud/hud_driver_query.c
@@ -35,41 +35,37 @@
 #include "pipe/p_screen.h"
 #include "util/os_time.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include <stdio.h>
 
 // Must be a power of two
 #define NUM_QUERIES 8
 
 struct hud_batch_query_context {
-   struct pipe_context *pipe;
    unsigned num_query_types;
    unsigned allocated_query_types;
    unsigned *query_types;
 
    boolean failed;
    struct pipe_query *query[NUM_QUERIES];
    union pipe_query_result *result[NUM_QUERIES];
    unsigned head, pending, results;
 };
 
 void
-hud_batch_query_update(struct hud_batch_query_context *bq)
+hud_batch_query_update(struct hud_batch_query_context *bq,
+                       struct pipe_context *pipe)
 {
-   struct pipe_context *pipe;
-
    if (!bq || bq->failed)
       return;
 
-   pipe = bq->pipe;
-
    if (bq->query[bq->head])
       pipe->end_query(pipe, bq->query[bq->head]);
 
    bq->results = 0;
 
    while (bq->pending) {
       unsigned idx = (bq->head - bq->pending + 1) % NUM_QUERIES;
       struct pipe_query *query = bq->query[idx];
 
       if (!bq->result[idx])
@@ -90,21 +86,21 @@ hud_batch_query_update(struct hud_batch_query_context *bq)
 
    bq->head = (bq->head + 1) % NUM_QUERIES;
 
    if (bq->pending == NUM_QUERIES) {
       fprintf(stderr,
               "gallium_hud: all queries busy after %i frames, dropping data.\n",
               NUM_QUERIES);
 
       assert(bq->query[bq->head]);
 
-      pipe->destroy_query(bq->pipe, bq->query[bq->head]);
+      pipe->destroy_query(pipe, bq->query[bq->head]);
       bq->query[bq->head] = NULL;
    }
 
    ++bq->pending;
 
    if (!bq->query[bq->head]) {
       bq->query[bq->head] = pipe->create_batch_query(pipe,
                                                      bq->num_query_types,
                                                      bq->query_types);
 
@@ -112,46 +108,45 @@ hud_batch_query_update(struct hud_batch_query_context *bq)
          fprintf(stderr,
                  "gallium_hud: create_batch_query failed. You may have "
                  "selected too many or incompatible queries.\n");
          bq->failed = TRUE;
          return;
       }
    }
 }
 
 void
-hud_batch_query_begin(struct hud_batch_query_context *bq)
+hud_batch_query_begin(struct hud_batch_query_context *bq,
+                      struct pipe_context *pipe)
 {
    if (!bq || bq->failed || !bq->query[bq->head])
       return;
 
-   if (!bq->pipe->begin_query(bq->pipe, bq->query[bq->head])) {
+   if (!pipe->begin_query(pipe, bq->query[bq->head])) {
       fprintf(stderr,
               "gallium_hud: could not begin batch query. You may have "
               "selected too many or incompatible queries.\n");
       bq->failed = TRUE;
    }
 }
 
 static boolean
 batch_query_add(struct hud_batch_query_context **pbq,
-                struct pipe_context *pipe, unsigned query_type,
-                unsigned *result_index)
+                unsigned query_type, unsigned *result_index)
 {
    struct hud_batch_query_context *bq = *pbq;
    unsigned i;
 
    if (!bq) {
       bq = CALLOC_STRUCT(hud_batch_query_context);
       if (!bq)
          return false;
-      bq->pipe = pipe;
       *pbq = bq;
    }
 
    for (i = 0; i < bq->num_query_types; ++i) {
       if (bq->query_types[i] == query_type) {
          *result_index = i;
          return true;
       }
    }
 
@@ -166,45 +161,45 @@ batch_query_add(struct hud_batch_query_context **pbq,
       bq->query_types = new_query_types;
       bq->allocated_query_types = new_alloc;
    }
 
    bq->query_types[bq->num_query_types] = query_type;
    *result_index = bq->num_query_types++;
    return true;
 }
 
 void
-hud_batch_query_cleanup(struct hud_batch_query_context **pbq)
+hud_batch_query_cleanup(struct hud_batch_query_context **pbq,
+                        struct pipe_context *pipe)
 {
    struct hud_batch_query_context *bq = *pbq;
    unsigned idx;
 
    if (!bq)
       return;
 
    *pbq = NULL;
 
    if (bq->query[bq->head] && !bq->failed)
-      bq->pipe->end_query(bq->pipe, bq->query[bq->head]);
+      pipe->end_query(pipe, bq->query[bq->head]);
 
    for (idx = 0; idx < NUM_QUERIES; ++idx) {
       if (bq->query[idx])
-         bq->pipe->destroy_query(bq->pipe, bq->query[idx]);
+         pipe->destroy_query(pipe, bq->query[idx]);
       FREE(bq->result[idx]);
    }
 
    FREE(bq->query_types);
    FREE(bq);
 }
 
 struct query_info {
-   struct pipe_context *pipe;
    struct hud_batch_query_context *batch;
    unsigned query_type;
    unsigned result_index; /* unit depends on query_type */
    enum pipe_driver_query_result_type result_type;
 
    /* Ring of queries. If a query is busy, we use another slot. */
    struct pipe_query *query[NUM_QUERIES];
    unsigned head, tail;
 
    uint64_t last_time;
@@ -223,24 +218,22 @@ query_new_value_batch(struct query_info *info)
    while (results) {
       info->results_cumulative += bq->result[idx]->batch[result_index].u64;
       ++info->num_results;
 
       --results;
       idx = (idx - 1) % NUM_QUERIES;
    }
 }
 
 static void
-query_new_value_normal(struct query_info *info)
+query_new_value_normal(struct query_info *info, struct pipe_context *pipe)
 {
-   struct pipe_context *pipe = info->pipe;
-
    if (info->last_time) {
       if (info->query[info->head])
          pipe->end_query(pipe, info->query[info->head]);
 
       /* read query results */
       while (1) {
          struct pipe_query *query = info->query[info->tail];
          union pipe_query_result result;
          uint64_t *res64 = (uint64_t *)&result;
 
@@ -280,40 +273,39 @@ query_new_value_normal(struct query_info *info)
          }
       }
    }
    else {
       /* initialize */
       info->query[info->head] = pipe->create_query(pipe, info->query_type, 0);
    }
 }
 
 static void
-begin_query(struct hud_graph *gr)
+begin_query(struct hud_graph *gr, struct pipe_context *pipe)
 {
    struct query_info *info = gr->query_data;
-   struct pipe_context *pipe = info->pipe;
 
    assert(!info->batch);
    if (info->query[info->head])
       pipe->begin_query(pipe, info->query[info->head]);
 }
 
 static void
-query_new_value(struct hud_graph *gr)
+query_new_value(struct hud_graph *gr, struct pipe_context *pipe)
 {
    struct query_info *info = gr->query_data;
    uint64_t now = os_time_get();
 
    if (info->batch) {
       query_new_value_batch(info);
    } else {
-      query_new_value_normal(info);
+      query_new_value_normal(info, pipe);
    }
 
    if (!info->last_time) {
       info->last_time = now;
       return;
    }
 
    if (info->num_results && info->last_time + gr->pane->period <= now) {
       uint64_t value;
 
@@ -329,42 +321,41 @@ query_new_value(struct hud_graph *gr)
 
       hud_graph_add_value(gr, value);
 
       info->last_time = now;
       info->results_cumulative = 0;
       info->num_results = 0;
    }
 }
 
 static void
-free_query_info(void *ptr)
+free_query_info(void *ptr, struct pipe_context *pipe)
 {
    struct query_info *info = ptr;
 
    if (!info->batch && info->last_time) {
-      struct pipe_context *pipe = info->pipe;
       int i;
 
       pipe->end_query(pipe, info->query[info->head]);
 
       for (i = 0; i < ARRAY_SIZE(info->query); i++) {
          if (info->query[i]) {
             pipe->destroy_query(pipe, info->query[i]);
          }
       }
    }
    FREE(info);
 }
 
 void
 hud_pipe_query_install(struct hud_batch_query_context **pbq,
-                       struct hud_pane *pane, struct pipe_context *pipe,
+                       struct hud_pane *pane,
                        const char *name, unsigned query_type,
                        unsigned result_index,
                        uint64_t max_value, enum pipe_driver_query_type type,
                        enum pipe_driver_query_result_type result_type,
                        unsigned flags)
 {
    struct hud_graph *gr;
    struct query_info *info;
 
    gr = CALLOC_STRUCT(hud_graph);
@@ -374,25 +365,24 @@ hud_pipe_query_install(struct hud_batch_query_context **pbq,
    strncpy(gr->name, name, sizeof(gr->name));
    gr->name[sizeof(gr->name) - 1] = '\0';
    gr->query_data = CALLOC_STRUCT(query_info);
    if (!gr->query_data)
       goto fail_gr;
 
    gr->query_new_value = query_new_value;
    gr->free_query_data = free_query_info;
 
    info = gr->query_data;
-   info->pipe = pipe;
    info->result_type = result_type;
 
    if (flags & PIPE_DRIVER_QUERY_FLAG_BATCH) {
-      if (!batch_query_add(pbq, pipe, query_type, &info->result_index))
+      if (!batch_query_add(pbq, query_type, &info->result_index))
          goto fail_info;
       info->batch = *pbq;
    } else {
       gr->begin_query = begin_query;
       info->query_type = query_type;
       info->result_index = result_index;
    }
 
    hud_pane_add_graph(pane, gr);
    pane->type = type; /* must be set before updating the max_value */
@@ -402,40 +392,39 @@ hud_pipe_query_install(struct hud_batch_query_context **pbq,
    return;
 
 fail_info:
    FREE(info);
 fail_gr:
    FREE(gr);
 }
 
 boolean
 hud_driver_query_install(struct hud_batch_query_context **pbq,
-                         struct hud_pane *pane, struct pipe_context *pipe,
+                         struct hud_pane *pane, struct pipe_screen *screen,
                          const char *name)
 {
-   struct pipe_screen *screen = pipe->screen;
    struct pipe_driver_query_info query;
    unsigned num_queries, i;
    boolean found = FALSE;
 
    if (!screen->get_driver_query_info)
       return FALSE;
 
    num_queries = screen->get_driver_query_info(screen, 0, NULL);
 
    for (i = 0; i < num_queries; i++) {
       if (screen->get_driver_query_info(screen, i, &query) &&
           strcmp(query.name, name) == 0) {
          found = TRUE;
          break;
       }
    }
 
    if (!found)
       return FALSE;
 
-   hud_pipe_query_install(pbq, pane, pipe, query.name, query.query_type, 0,
+   hud_pipe_query_install(pbq, pane, query.name, query.query_type, 0,
                           query.max_value.u64, query.type, query.result_type,
                           query.flags);
 
    return TRUE;
 }
diff --git a/src/gallium/auxiliary/hud/hud_fps.c b/src/gallium/auxiliary/hud/hud_fps.c
index aecbaf0..c8438d0 100644
--- a/src/gallium/auxiliary/hud/hud_fps.c
+++ b/src/gallium/auxiliary/hud/hud_fps.c
@@ -31,21 +31,21 @@
 #include "hud/hud_private.h"
 #include "util/os_time.h"
 #include "util/u_memory.h"
 
 struct fps_info {
    int frames;
    uint64_t last_time;
 };
 
 static void
-query_fps(struct hud_graph *gr)
+query_fps(struct hud_graph *gr, struct pipe_context *pipe)
 {
    struct fps_info *info = gr->query_data;
    uint64_t now = os_time_get();
 
    info->frames++;
 
    if (info->last_time) {
       if (info->last_time + gr->pane->period <= now) {
          double fps = ((uint64_t)info->frames) * 1000000 /
                       (double)(now - info->last_time);
@@ -54,21 +54,21 @@ query_fps(struct hud_graph *gr)
 
          hud_graph_add_value(gr, fps);
       }
    }
    else {
       info->last_time = now;
    }
 }
 
 static void
-free_query_data(void *p)
+free_query_data(void *p, struct pipe_context *pipe)
 {
    FREE(p);
 }
 
 void
 hud_fps_graph_install(struct hud_pane *pane)
 {
    struct hud_graph *gr = CALLOC_STRUCT(hud_graph);
 
    if (!gr)
diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h
index 65baa8a..265ecbe 100644
--- a/src/gallium/auxiliary/hud/hud_private.h
+++ b/src/gallium/auxiliary/hud/hud_private.h
@@ -90,23 +90,24 @@ struct hud_context {
 struct hud_graph {
    /* initialized by common code */
    struct list_head head;
    struct hud_pane *pane;
    float color[3];
    float *vertices; /* ring buffer of vertices */
 
    /* name and query */
    char name[128];
    void *query_data;
-   void (*begin_query)(struct hud_graph *gr);
-   void (*query_new_value)(struct hud_graph *gr);
-   void (*free_query_data)(void *ptr); /**< do not use ordinary free() */
+   void (*begin_query)(struct hud_graph *gr, struct pipe_context *pipe);
+   void (*query_new_value)(struct hud_graph *gr, struct pipe_context *pipe);
+   /* use this instead of ordinary free() */
+   void (*free_query_data)(void *ptr, struct pipe_context *pipe);
 
    /* mutable variables */
    unsigned num_vertices;
    unsigned index; /* vertex index being updated */
    double current_value;
    FILE *fd;
 };
 
 struct hud_pane {
    struct list_head head;
@@ -147,33 +148,36 @@ struct hud_batch_query_context;
 #define ALL_CPUS ~0 /* optionally set as cpu_index */
 
 int hud_get_num_cpus(void);
 
 void hud_fps_graph_install(struct hud_pane *pane);
 void hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index);
 void hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main);
 void hud_thread_counter_install(struct hud_pane *pane, const char *name,
                                 enum hud_counter counter);
 void hud_pipe_query_install(struct hud_batch_query_context **pbq,
-                            struct hud_pane *pane, struct pipe_context *pipe,
+                            struct hud_pane *pane,
                             const char *name, unsigned query_type,
                             unsigned result_index,
                             uint64_t max_value,
                             enum pipe_driver_query_type type,
                             enum pipe_driver_query_result_type result_type,
                             unsigned flags);
 boolean hud_driver_query_install(struct hud_batch_query_context **pbq,
                                  struct hud_pane *pane,
-                                 struct pipe_context *pipe, const char *name);
-void hud_batch_query_begin(struct hud_batch_query_context *bq);
-void hud_batch_query_update(struct hud_batch_query_context *bq);
-void hud_batch_query_cleanup(struct hud_batch_query_context **pbq);
+                                 struct pipe_screen *screen, const char *name);
+void hud_batch_query_begin(struct hud_batch_query_context *bq,
+                           struct pipe_context *pipe);
+void hud_batch_query_update(struct hud_batch_query_context *bq,
+                            struct pipe_context *pipe);
+void hud_batch_query_cleanup(struct hud_batch_query_context **pbq,
+                             struct pipe_context *pipe);
 
 #if HAVE_GALLIUM_EXTRA_HUD
 int hud_get_num_nics(bool displayhelp);
 #define NIC_DIRECTION_RX 1
 #define NIC_DIRECTION_TX 2
 #define NIC_RSSI_DBM     3
 void hud_nic_graph_install(struct hud_pane *pane, const char *nic_index,
                            unsigned int mode);
 
 int hud_get_num_disks(bool displayhelp);
-- 
2.7.4



More information about the mesa-dev mailing list