From 42658ab70cc1f3f680b53a6d3648d41ee2685885 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 13 Apr 2021 09:14:34 -0400 Subject: [PATCH] zink: init timeline semaphore on screen creation, not first batch creation this is less racy Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_batch.c | 11 ++++------- src/gallium/drivers/zink/zink_context.c | 1 + src/gallium/drivers/zink/zink_screen.c | 2 ++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index 3e452b6..747dbc7 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -254,14 +254,11 @@ void zink_reset_batch(struct zink_context *ctx, struct zink_batch *batch) { struct zink_screen *screen = zink_screen(ctx->base.screen); - bool fresh = !batch->state; - if (ctx->have_timelines) { - if (fresh || (screen->last_finished > ctx->curr_batch && ctx->curr_batch == 1)) { - if (!zink_screen_init_semaphore(screen)) { - debug_printf("timeline init failed, things are about to go dramatically wrong."); - ctx->have_timelines = false; - } + if (ctx->have_timelines && screen->last_finished > ctx->curr_batch && ctx->curr_batch == 1) { + if (!zink_screen_init_semaphore(screen)) { + debug_printf("timeline init failed, things are about to go dramatically wrong."); + ctx->have_timelines = false; } } diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 92e9228..0d1ece0 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -2466,6 +2466,7 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) struct zink_context *ctx = rzalloc(NULL, struct zink_context); if (!ctx) goto fail; + ctx->have_timelines = screen->info.have_KHR_timeline_semaphore; ctx->gfx_pipeline_state.dirty = true; ctx->compute_pipeline_state.dirty = true; diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index ad0a2f3..7aa110d 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -1552,6 +1552,8 @@ zink_internal_create_screen(const struct pipe_screen_config *config) screen->total_video_mem = get_video_mem(screen); if (!os_get_total_physical_memory(&screen->total_mem)) goto fail; + if (screen->info.have_KHR_timeline_semaphore) + zink_screen_init_semaphore(screen); simple_mtx_init(&screen->surface_mtx, mtx_plain); simple_mtx_init(&screen->bufferview_mtx, mtx_plain); -- 2.7.4