zink: move queue init to screen creation

this is a race condition

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11398>
This commit is contained in:
Mike Blumenkrantz 2021-05-06 16:41:36 -04:00 committed by Marge Bot
parent 0cfcc0602b
commit 806251c72d
5 changed files with 17 additions and 11 deletions

View file

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

View file

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

View file

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

View file

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

View file

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