zink: init timeline semaphore on screen creation, not first batch creation

this is less racy

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10214>
This commit is contained in:
Mike Blumenkrantz
2021-04-13 09:14:34 -04:00
committed by Marge Bot
parent e34dc0840b
commit 42658ab70c
3 changed files with 7 additions and 7 deletions
+4 -7
View File
@@ -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;
}
}
+1
View File
@@ -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;
+2
View File
@@ -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);