diff options
author | Marek Olšák <[email protected]> | 2017-11-18 16:25:52 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-11-25 17:16:56 +0100 |
commit | 3132afdf4c12abcb32a2cbe7eb262b9907e60594 (patch) | |
tree | f7ee2e97e461629ddd7b173fb56f5d11997502ce /src/gallium/auxiliary | |
parent | 0e319ed835e6ba6fdff6f5d0bb3728e950aec74f (diff) |
gallium/hud: pass pipe_context explicitly to most functions
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/hud/hud_context.c | 38 | ||||
-rw-r--r-- | src/gallium/auxiliary/hud/hud_cpu.c | 8 | ||||
-rw-r--r-- | src/gallium/auxiliary/hud/hud_driver_query.c | 51 | ||||
-rw-r--r-- | src/gallium/auxiliary/hud/hud_fps.c | 4 | ||||
-rw-r--r-- | 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 83b32041d7b..d54bd639579 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -584,25 +584,25 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex) } 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; @@ -616,7 +616,7 @@ hud_stop_queries(struct hud_context *hud) /* 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 + @@ -646,11 +646,11 @@ hud_stop_queries(struct hud_context *hud) 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) { @@ -674,15 +674,15 @@ hud_stop_queries(struct hud_context *hud) } /* 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 @@ -917,11 +917,11 @@ hud_graph_add_value(struct hud_graph *gr, double 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); @@ -1252,7 +1252,7 @@ hud_parse_env_var(struct hud_context *hud, const char *env) #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, @@ -1261,7 +1261,7 @@ hud_parse_env_var(struct hud_context *hud, const char *env) } 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, @@ -1291,7 +1291,7 @@ hud_parse_env_var(struct hud_context *hud, const char *env) 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, @@ -1302,8 +1302,8 @@ hud_parse_env_var(struct hud_context *hud, const char *env) /* 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); } @@ -1720,13 +1720,13 @@ hud_destroy(struct hud_context *hud) 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); diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c index 581dad6df04..259bb837639 100644 --- a/src/gallium/auxiliary/hud/hud_cpu.c +++ b/src/gallium/auxiliary/hud/hud_cpu.c @@ -144,7 +144,7 @@ struct cpu_info { }; 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(); @@ -173,7 +173,7 @@ query_cpu_load(struct hud_graph *gr) } static void -free_query_data(void *p) +free_query_data(void *p, struct pipe_context *pipe) { FREE(p); } @@ -238,7 +238,7 @@ struct thread_info { }; 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(); @@ -335,7 +335,7 @@ static unsigned get_counter(struct hud_graph *gr, enum hud_counter counter) } 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(); diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c b/src/gallium/auxiliary/hud/hud_driver_query.c index 8b1e4e104a7..085bc627ec3 100644 --- a/src/gallium/auxiliary/hud/hud_driver_query.c +++ b/src/gallium/auxiliary/hud/hud_driver_query.c @@ -42,7 +42,6 @@ #define NUM_QUERIES 8 struct hud_batch_query_context { - struct pipe_context *pipe; unsigned num_query_types; unsigned allocated_query_types; unsigned *query_types; @@ -54,15 +53,12 @@ struct hud_batch_query_context { }; 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]); @@ -97,7 +93,7 @@ hud_batch_query_update(struct hud_batch_query_context *bq) 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; } @@ -119,12 +115,13 @@ hud_batch_query_update(struct hud_batch_query_context *bq) } 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"); @@ -134,8 +131,7 @@ hud_batch_query_begin(struct hud_batch_query_context *bq) 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; @@ -144,7 +140,6 @@ batch_query_add(struct hud_batch_query_context **pbq, bq = CALLOC_STRUCT(hud_batch_query_context); if (!bq) return false; - bq->pipe = pipe; *pbq = bq; } @@ -173,7 +168,8 @@ batch_query_add(struct hud_batch_query_context **pbq, } 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; @@ -184,11 +180,11 @@ hud_batch_query_cleanup(struct hud_batch_query_context **pbq) *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]); } @@ -197,7 +193,6 @@ hud_batch_query_cleanup(struct hud_batch_query_context **pbq) } struct query_info { - struct pipe_context *pipe; struct hud_batch_query_context *batch; unsigned query_type; unsigned result_index; /* unit depends on query_type */ @@ -230,10 +225,8 @@ query_new_value_batch(struct query_info *info) } 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]); @@ -287,10 +280,9 @@ query_new_value_normal(struct query_info *info) } 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]) @@ -298,7 +290,7 @@ begin_query(struct hud_graph *gr) } 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(); @@ -306,7 +298,7 @@ query_new_value(struct hud_graph *gr) if (info->batch) { query_new_value_batch(info); } else { - query_new_value_normal(info); + query_new_value_normal(info, pipe); } if (!info->last_time) { @@ -336,12 +328,11 @@ query_new_value(struct hud_graph *gr) } 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]); @@ -357,7 +348,7 @@ free_query_info(void *ptr) 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, @@ -381,11 +372,10 @@ hud_pipe_query_install(struct hud_batch_query_context **pbq, 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 { @@ -409,10 +399,9 @@ fail_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; @@ -433,7 +422,7 @@ hud_driver_query_install(struct hud_batch_query_context **pbq, 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); diff --git a/src/gallium/auxiliary/hud/hud_fps.c b/src/gallium/auxiliary/hud/hud_fps.c index aecbaf0f6b4..c8438d0f5e3 100644 --- a/src/gallium/auxiliary/hud/hud_fps.c +++ b/src/gallium/auxiliary/hud/hud_fps.c @@ -38,7 +38,7 @@ struct fps_info { }; 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(); @@ -61,7 +61,7 @@ query_fps(struct hud_graph *gr) } static void -free_query_data(void *p) +free_query_data(void *p, struct pipe_context *pipe) { FREE(p); } diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h index 65baa8aa7e7..265ecbe3933 100644 --- a/src/gallium/auxiliary/hud/hud_private.h +++ b/src/gallium/auxiliary/hud/hud_private.h @@ -97,9 +97,10 @@ struct hud_graph { /* 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; @@ -154,7 +155,7 @@ 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, @@ -163,10 +164,13 @@ void hud_pipe_query_install(struct hud_batch_query_context **pbq, 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); |