Mesa (main): zink: break out tc/trace context unwrapping

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 18 20:13:43 UTC 2022


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Fri Jul 15 08:26:04 2022 -0400

zink: break out tc/trace context unwrapping

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

---

 src/gallium/drivers/zink/zink_context.c | 14 ++++++++++++++
 src/gallium/drivers/zink/zink_context.h |  3 ++-
 src/gallium/drivers/zink/zink_screen.c  |  8 +-------
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 145c0d93a43..4b904e89843 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -51,6 +51,8 @@
 #include "util/strndup.h"
 #include "nir.h"
 
+#include "driver_trace/tr_context.h"
+
 #include "util/u_memory.h"
 #include "util/u_upload_mgr.h"
 
@@ -4516,3 +4518,15 @@ fail:
       zink_context_destroy(&ctx->base);
    return NULL;
 }
+
+struct zink_context *
+zink_tc_context_unwrap(struct pipe_context *pctx)
+{
+   struct zink_context *ctx = zink_context(pctx);
+   struct zink_screen *screen = zink_screen(ctx->base.screen);
+   /* need to get the actual zink_context, not the threaded context */
+   if (screen->threaded)
+      pctx = threaded_context_unwrap_sync(pctx);
+   pctx = trace_get_possibly_threaded_context(pctx);
+   return zink_context(pctx);
+}
diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h
index c4e62cd9efc..3a409439607 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -486,7 +486,8 @@ void
 zink_init_draw_functions(struct zink_context *ctx, struct zink_screen *screen);
 void
 zink_init_grid_functions(struct zink_context *ctx);
-
+struct zink_context *
+zink_tc_context_unwrap(struct pipe_context *pctx);
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index 6fa8f50c7bd..9d4b6d36330 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -53,8 +53,6 @@
 
 #include "util/u_cpu_detect.h"
 
-#include "driver_trace/tr_context.h"
-
 #if DETECT_OS_WINDOWS
 #include <io.h>
 #define VK_LIBNAME "vulkan-1.dll"
@@ -1428,11 +1426,7 @@ zink_flush_frontbuffer(struct pipe_screen *pscreen,
    if (!zink_is_swapchain(res) || (!zink_kopper_acquired(res->obj->dt, res->obj->dt_idx) && res->obj->last_dt_idx == UINT32_MAX))
       return;
 
-   /* need to get the actual zink_context, not the threaded context */
-   if (screen->threaded)
-      pctx = threaded_context_unwrap_sync(pctx);
-   pctx = trace_get_possibly_threaded_context(pctx);
-   ctx = zink_context(pctx);
+   ctx = zink_tc_context_unwrap(pctx);
    if (ctx->batch.swapchain || ctx->needs_present) {
       ctx->batch.has_work = true;
       pctx->flush(pctx, NULL, PIPE_FLUSH_END_OF_FRAME);



More information about the mesa-commit mailing list