Mesa (main): aux/trace: more effectively unwrap pipe_context params from screen functions

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat May 22 14:02:41 UTC 2021


Module: Mesa
Branch: main
Commit: a1c7279a7f151fc8df621889f5f32641933eca50
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a1c7279a7f151fc8df621889f5f32641933eca50

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu May  6 17:06:09 2021 -0400

aux/trace: more effectively unwrap pipe_context params from screen functions

when using tc, these are the threaded context, not the trace context

Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10899>

---

 src/gallium/auxiliary/driver_trace/tr_context.c |  9 +++++++++
 src/gallium/auxiliary/driver_trace/tr_context.h |  3 ++-
 src/gallium/auxiliary/driver_trace/tr_screen.c  | 12 ++++++------
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/gallium/auxiliary/driver_trace/tr_context.c b/src/gallium/auxiliary/driver_trace/tr_context.c
index 2bdf9a2e1a3..8a04d4c8a28 100644
--- a/src/gallium/auxiliary/driver_trace/tr_context.c
+++ b/src/gallium/auxiliary/driver_trace/tr_context.c
@@ -2211,3 +2211,12 @@ trace_context_check(const struct pipe_context *pipe)
    ASSERTED struct trace_context *tr_ctx = (struct trace_context *) pipe;
    assert(tr_ctx->base.destroy == trace_context_destroy);
 }
+
+/**
+ * Threaded context is not wrapped, and so it may call fence functions directly
+ */
+struct pipe_context *
+trace_get_possibly_threaded_context(struct pipe_context *pipe)
+{
+   return pipe->destroy == trace_context_destroy ? ((struct trace_context*)pipe)->pipe : pipe;
+}
diff --git a/src/gallium/auxiliary/driver_trace/tr_context.h b/src/gallium/auxiliary/driver_trace/tr_context.h
index a9d75ce921c..fcd7bac8b57 100644
--- a/src/gallium/auxiliary/driver_trace/tr_context.h
+++ b/src/gallium/auxiliary/driver_trace/tr_context.h
@@ -62,7 +62,8 @@ struct trace_context
 
 void
 trace_context_check(const struct pipe_context *pipe);
-
+struct pipe_context *
+trace_get_possibly_threaded_context(struct pipe_context *pipe);
 
 static inline struct trace_context *
 trace_context(struct pipe_context *pipe)
diff --git a/src/gallium/auxiliary/driver_trace/tr_screen.c b/src/gallium/auxiliary/driver_trace/tr_screen.c
index 37a6682056a..2a0df1a3de5 100644
--- a/src/gallium/auxiliary/driver_trace/tr_screen.c
+++ b/src/gallium/auxiliary/driver_trace/tr_screen.c
@@ -325,7 +325,7 @@ trace_screen_flush_frontbuffer(struct pipe_screen *_screen,
 {
    struct trace_screen *tr_scr = trace_screen(_screen);
    struct pipe_screen *screen = tr_scr->screen;
-   struct pipe_context *pipe = _pipe ? trace_context(_pipe)->pipe : NULL;
+   struct pipe_context *pipe = _pipe ? trace_get_possibly_threaded_context(_pipe) : NULL;
 
    trace_dump_call_begin("pipe_screen", "flush_frontbuffer");
 
@@ -596,12 +596,12 @@ trace_screen_resource_get_handle(struct pipe_screen *_screen,
                                  unsigned usage)
 {
    struct trace_screen *tr_screen = trace_screen(_screen);
-   struct trace_context *tr_pipe = _pipe ? trace_context(_pipe) : NULL;
+   struct pipe_context *pipe = _pipe ? trace_get_possibly_threaded_context(_pipe) : NULL;
    struct pipe_screen *screen = tr_screen->screen;
 
    /* TODO trace call */
 
-   return screen->resource_get_handle(screen, tr_pipe ? tr_pipe->pipe : NULL,
+   return screen->resource_get_handle(screen, pipe,
                                       resource, handle, usage);
 }
 
@@ -617,12 +617,12 @@ trace_screen_resource_get_param(struct pipe_screen *_screen,
                                 uint64_t *value)
 {
    struct trace_screen *tr_screen = trace_screen(_screen);
-   struct trace_context *tr_pipe = _pipe ? trace_context(_pipe) : NULL;
+   struct pipe_context *pipe = _pipe ? trace_get_possibly_threaded_context(_pipe) : NULL;
    struct pipe_screen *screen = tr_screen->screen;
 
    /* TODO trace call */
 
-   return screen->resource_get_param(screen, tr_pipe ? tr_pipe->pipe : NULL,
+   return screen->resource_get_param(screen, pipe,
                                      resource, plane, layer, level, param,
                                      handle_usage, value);
 }
@@ -760,7 +760,7 @@ trace_screen_fence_finish(struct pipe_screen *_screen,
 {
    struct trace_screen *tr_scr = trace_screen(_screen);
    struct pipe_screen *screen = tr_scr->screen;
-   struct pipe_context *ctx = _ctx ? trace_context(_ctx)->pipe : NULL;
+   struct pipe_context *ctx = _ctx ? trace_get_possibly_threaded_context(_ctx) : NULL;
    int result;
 
    result = screen->fence_finish(screen, ctx, fence, timeout);



More information about the mesa-commit mailing list