[Mesa-dev] [PATCH 09/12] gallium/hud: separate code for record context init/release
Marek Olšák
maraeo at gmail.com
Tue Nov 21 17:46:09 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
---
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 6689006..e3fcad2 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -673,23 +673,23 @@ hud_stop_queries(struct hud_context *hud, struct pipe_context *pipe)
hud_pane_accumulate_vertices(hud, pane);
}
/* unmap the uploader's vertex buffer before drawing */
u_upload_unmap(pipe->stream_uploader);
}
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
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;
}
/**
@@ -1644,20 +1644,49 @@ hud_set_draw_context(struct hud_context *hud, struct cso_context *cso)
}
return true;
fail:
hud_unset_draw_context(hud);
fprintf(stderr, "hud: failed to set a draw context");
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)
{
struct pipe_screen *screen = cso_get_pipe_context(cso)->screen;
struct hud_context *hud;
unsigned i;
const char *env = debug_get_option("GALLIUM_HUD", NULL);
#ifdef PIPE_OS_UNIX
unsigned signo = debug_get_num_option("GALLIUM_HUD_TOGGLE_SIGNAL", 0);
static boolean sig_handled = FALSE;
@@ -1745,41 +1774,29 @@ hud_create(struct cso_context *cso)
if (signo >= NSIG)
fprintf(stderr, "gallium_hud: invalid signal %u\n", signo);
else if (sigaction(signo, &action, NULL) < 0)
fprintf(stderr, "gallium_hud: unable to set handler for signal %u\n", signo);
fflush(stderr);
sig_handled = TRUE;
}
#endif
+ hud_set_record_context(hud, cso_get_pipe_context(cso));
hud_parse_env_var(hud, screen, env);
return hud;
}
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);
}
void
hud_add_queue_for_monitoring(struct hud_context *hud,
struct util_queue_monitoring *queue_info)
{
assert(!hud->monitored_queue);
diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h
index 265ecbe..c55d64f 100644
--- a/src/gallium/auxiliary/hud/hud_private.h
+++ b/src/gallium/auxiliary/hud/hud_private.h
@@ -33,20 +33,24 @@
#include "util/list.h"
#include "hud/font.h"
enum hud_counter {
HUD_COUNTER_OFFLOADED,
HUD_COUNTER_DIRECT,
HUD_COUNTER_SYNCS,
};
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;
struct hud_batch_query_context *batch_query;
struct list_head pane_list;
struct util_queue_monitoring *monitored_queue;
/* states */
struct pipe_blend_state no_blend, alpha_blend;
--
2.7.4
More information about the mesa-dev
mailing list