gallium/hud: separate code for record context init/release
authorMarek Olšák <marek.olsak@amd.com>
Sat, 18 Nov 2017 17:07:40 +0000 (18:07 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 25 Nov 2017 16:16:56 +0000 (17:16 +0100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/auxiliary/hud/hud_context.c
src/gallium/auxiliary/hud/hud_private.h

index 6689006a436c87c1c05debb437fd9263c4834dd2..e3fcad22f792179fddab9af7ef92160af9b0e546 100644 (file)
@@ -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);
index 265ecbe39330aab613b7ebdc2a36588af1a80221..c55d64f5eb6c788e80351007d395013bdc4c884b 100644 (file)
@@ -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;