zink: break out tc/trace context unwrapping

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17527>
This commit is contained in:
Mike Blumenkrantz 2022-07-15 08:26:04 -04:00 committed by Marge Bot
parent a211d74096
commit 81d83e81db
3 changed files with 17 additions and 8 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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);