zink: move timeline_wait() to screen function

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10882>
This commit is contained in:
Mike Blumenkrantz 2021-05-12 11:08:04 -04:00
parent 6766c983f0
commit 6f5037c9de
3 changed files with 27 additions and 24 deletions

View file

@ -2239,28 +2239,6 @@ zink_fence_wait(struct pipe_context *pctx)
}
}
static bool
timeline_wait(struct zink_screen *screen, uint32_t batch_id, uint64_t timeout)
{
VkSemaphoreWaitInfo wi = {};
wi.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO;
wi.semaphoreCount = 1;
/* handle batch_id overflow */
wi.pSemaphores = batch_id > screen->curr_batch ? &screen->prev_sem : &screen->sem;
uint64_t batch_id64 = batch_id;
wi.pValues = &batch_id64;
bool success = false;
if (screen->device_lost)
return true;
VkResult ret = screen->vk_WaitSemaphores(screen->dev, &wi, timeout);
success = zink_screen_handle_vkresult(screen, ret);
if (success)
zink_screen_update_last_finished(screen, batch_id);
return success;
}
void
zink_wait_on_batch(struct zink_context *ctx, uint32_t batch_id)
{
@ -2270,7 +2248,7 @@ zink_wait_on_batch(struct zink_context *ctx, uint32_t batch_id)
/* not submitted yet */
flush_batch(ctx, true);
if (ctx->have_timelines) {
if (!timeline_wait(zink_screen(ctx->base.screen), batch_id, UINT64_MAX))
if (!zink_screen_timeline_wait(zink_screen(ctx->base.screen), batch_id, UINT64_MAX))
check_device_lost(ctx);
return;
}
@ -2314,7 +2292,7 @@ zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id)
return true;
if (ctx->have_timelines) {
bool success = timeline_wait(zink_screen(ctx->base.screen), batch_id, 0);
bool success = zink_screen_timeline_wait(zink_screen(ctx->base.screen), batch_id, 0);
if (!success)
check_device_lost(ctx);
return success;

View file

@ -1424,6 +1424,28 @@ zink_screen_init_semaphore(struct zink_screen *screen)
return false;
}
bool
zink_screen_timeline_wait(struct zink_screen *screen, uint32_t batch_id, uint64_t timeout)
{
VkSemaphoreWaitInfo wi = {};
wi.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO;
wi.semaphoreCount = 1;
/* handle batch_id overflow */
wi.pSemaphores = batch_id > screen->curr_batch ? &screen->prev_sem : &screen->sem;
uint64_t batch_id64 = batch_id;
wi.pValues = &batch_id64;
bool success = false;
if (screen->device_lost)
return true;
VkResult ret = screen->vk_WaitSemaphores(screen->dev, &wi, timeout);
success = zink_screen_handle_vkresult(screen, ret);
if (success)
zink_screen_update_last_finished(screen, batch_id);
return success;
}
static uint32_t
zink_get_loader_version(void)
{

View file

@ -266,6 +266,9 @@ struct mem_cache_entry {
VkFormat
zink_get_format(struct zink_screen *screen, enum pipe_format format);
bool
zink_screen_timeline_wait(struct zink_screen *screen, uint32_t batch_id, uint64_t timeout);
bool
zink_is_depth_format_supported(struct zink_screen *screen, VkFormat format);