Mesa (main): zink: move queue init to screen creation
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 16 15:14:12 UTC 2021
Module: Mesa
Branch: main
Commit: 806251c72df16d0b5a4670dcddc5b677915496ed
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=806251c72df16d0b5a4670dcddc5b677915496ed
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Thu May 6 16:41:36 2021 -0400
zink: move queue init to screen creation
this is a race condition
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11398>
---
src/gallium/drivers/zink/zink_batch.c | 4 ++--
src/gallium/drivers/zink/zink_batch.h | 2 --
src/gallium/drivers/zink/zink_context.c | 9 ++-------
src/gallium/drivers/zink/zink_screen.c | 11 +++++++++++
src/gallium/drivers/zink/zink_screen.h | 2 ++
5 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c
index f0017a15e18..79ebb9ed7eb 100644
--- a/src/gallium/drivers/zink/zink_batch.c
+++ b/src/gallium/drivers/zink/zink_batch.c
@@ -525,11 +525,11 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
return;
if (util_queue_is_initialized(&batch->flush_queue)) {
- batch->state->queue = batch->thread_queue;
+ batch->state->queue = screen->thread_queue;
util_queue_add_job(&batch->flush_queue, batch->state, &batch->state->flush_completed,
submit_queue, post_submit, 0);
} else {
- batch->state->queue = batch->queue;
+ batch->state->queue = screen->queue;
submit_queue(batch->state, 0);
post_submit(batch->state, 0);
}
diff --git a/src/gallium/drivers/zink/zink_batch.h b/src/gallium/drivers/zink/zink_batch.h
index 8db448e3e28..9b4057e3199 100644
--- a/src/gallium/drivers/zink/zink_batch.h
+++ b/src/gallium/drivers/zink/zink_batch.h
@@ -95,8 +95,6 @@ struct zink_batch {
struct zink_batch_state *state;
uint32_t last_batch_id;
- VkQueue queue; //gfx+compute
- VkQueue thread_queue; //gfx+compute
struct util_queue flush_queue; //TODO: move to wsi
bool has_work;
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index c7cc9c2f723..785c80538c0 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -85,7 +85,7 @@ zink_context_destroy(struct pipe_context *pctx)
struct zink_context *ctx = zink_context(pctx);
struct zink_screen *screen = zink_screen(pctx->screen);
- if (ctx->batch.queue && !screen->device_lost && vkQueueWaitIdle(ctx->batch.queue) != VK_SUCCESS)
+ if (screen->queue && !screen->device_lost && vkQueueWaitIdle(screen->queue) != VK_SUCCESS)
debug_printf("vkQueueWaitIdle failed\n");
util_blitter_destroy(ctx->blitter);
@@ -3181,7 +3181,7 @@ zink_resource_commit(struct pipe_context *pctx, struct pipe_resource *pres, unsi
mem_bind.memoryOffset = box->x;
mem_bind.flags = 0;
sparse_bind.pBinds = &mem_bind;
- VkQueue queue = util_queue_is_initialized(&ctx->batch.flush_queue) ? ctx->batch.thread_queue : ctx->batch.queue;
+ VkQueue queue = util_queue_is_initialized(&ctx->batch.flush_queue) ? screen->thread_queue : screen->queue;
VkResult ret = vkQueueBindSparse(queue, 1, &sparse, VK_NULL_HANDLE);
if (!zink_screen_handle_vkresult(screen, ret)) {
@@ -3476,11 +3476,6 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
if (!screen->descriptors_init(ctx))
goto fail;
}
- vkGetDeviceQueue(screen->dev, screen->gfx_queue, 0, &ctx->batch.queue);
- if (screen->threaded && screen->max_queues > 1)
- vkGetDeviceQueue(screen->dev, screen->gfx_queue, 1, &ctx->batch.thread_queue);
- else
- ctx->batch.thread_queue = ctx->batch.queue;
ctx->have_timelines = screen->info.have_KHR_timeline_semaphore;
simple_mtx_init(&ctx->batch_mtx, mtx_plain);
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index 6d5d64c6a81..66155e2901a 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -1101,6 +1101,16 @@ update_queue_props(struct zink_screen *screen)
free(props);
}
+static void
+init_queue(struct zink_screen *screen)
+{
+ vkGetDeviceQueue(screen->dev, screen->gfx_queue, 0, &screen->queue);
+ if (screen->threaded && screen->max_queues > 1)
+ vkGetDeviceQueue(screen->dev, screen->gfx_queue, 1, &screen->thread_queue);
+ else
+ screen->thread_queue = screen->queue;
+}
+
static void
zink_flush_frontbuffer(struct pipe_screen *pscreen,
struct pipe_context *pcontext,
@@ -1632,6 +1642,7 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
if (!screen->dev)
goto fail;
+ init_queue(screen);
if (screen->info.driver_props.driverID == VK_DRIVER_ID_MESA_RADV ||
screen->info.driver_props.driverID == VK_DRIVER_ID_AMD_OPEN_SOURCE ||
screen->info.driver_props.driverID == VK_DRIVER_ID_AMD_PROPRIETARY)
diff --git a/src/gallium/drivers/zink/zink_screen.h b/src/gallium/drivers/zink/zink_screen.h
index d188234bd49..193380c8312 100644
--- a/src/gallium/drivers/zink/zink_screen.h
+++ b/src/gallium/drivers/zink/zink_screen.h
@@ -117,6 +117,8 @@ struct zink_screen {
uint32_t max_queues;
uint32_t timestamp_valid_bits;
VkDevice dev;
+ VkQueue queue; //gfx+compute
+ VkQueue thread_queue; //gfx+compute
VkDebugUtilsMessengerEXT debugUtilsCallbackHandle;
uint32_t cur_custom_border_color_samplers;
More information about the mesa-commit
mailing list