From 37ded08321b81f8a9a145abd6e457e8ad2c088e1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 18 Nov 2017 18:07:40 +0100 Subject: [PATCH] gallium/hud: separate code for record context init/release MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Nicolai Hähnle --- src/gallium/auxiliary/hud/hud_context.c | 49 +++++++++++++++++-------- src/gallium/auxiliary/hud/hud_private.h | 4 ++ 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index 6689006a436..e3fcad22f79 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -680,9 +680,9 @@ hud_stop_queries(struct hud_context *hud, struct pipe_context *pipe) void hud_run(struct hud_context *hud, struct pipe_resource *tex) { - hud_stop_queries(hud, hud->pipe); + hud_stop_queries(hud, hud->record_pipe); hud_draw_results(hud, tex); - hud_start_queries(hud, hud->pipe); + hud_start_queries(hud, hud->record_pipe); } static void @@ -1651,6 +1651,35 @@ fail: return false; } +static void +hud_unset_record_context(struct hud_context *hud) +{ + struct pipe_context *pipe = hud->record_pipe; + struct hud_pane *pane, *pane_tmp; + struct hud_graph *graph, *graph_tmp; + + if (!pipe) + return; + + 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, pipe); + } + LIST_DEL(&pane->head); + FREE(pane); + } + + hud_batch_query_cleanup(&hud->batch_query, pipe); + hud->record_pipe = NULL; +} + +static void +hud_set_record_context(struct hud_context *hud, struct pipe_context *pipe) +{ + hud->record_pipe = pipe; +} + struct hud_context * hud_create(struct cso_context *cso) { @@ -1752,6 +1781,7 @@ hud_create(struct cso_context *cso) } #endif + hud_set_record_context(hud, cso_get_pipe_context(cso)); hud_parse_env_var(hud, screen, env); return hud; } @@ -1759,20 +1789,7 @@ hud_create(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, pipe); - } - LIST_DEL(&pane->head); - FREE(pane); - } - - hud_batch_query_cleanup(&hud->batch_query, pipe); + hud_unset_record_context(hud); hud_unset_draw_context(hud); pipe_resource_reference(&hud->font.texture, NULL); FREE(hud); diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h index 265ecbe3933..c55d64f5eb6 100644 --- a/src/gallium/auxiliary/hud/hud_private.h +++ b/src/gallium/auxiliary/hud/hud_private.h @@ -40,6 +40,10 @@ enum hud_counter { }; struct hud_context { + /* Context where queries are executed. */ + struct pipe_context *record_pipe; + + /* Context where the HUD is drawn: */ struct pipe_context *pipe; struct cso_context *cso; -- 2.30.2