mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
zink: do not create fences at all if timeline semaphores are supported
there's no point in doing this, as it's just extra objects that don't need to ever be used Acked-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15904>
This commit is contained in:
parent
8806f444a5
commit
07c86e99b1
3 changed files with 40 additions and 9 deletions
|
|
@ -244,11 +244,13 @@ create_batch_state(struct zink_context *ctx)
|
|||
if (!screen->batch_descriptor_init(screen, bs))
|
||||
goto fail;
|
||||
|
||||
VkFenceCreateInfo fci = {0};
|
||||
fci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
|
||||
if (!screen->info.have_KHR_timeline_semaphore) {
|
||||
VkFenceCreateInfo fci = {0};
|
||||
fci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
|
||||
|
||||
if (VKSCR(CreateFence)(screen->dev, &fci, NULL, &bs->fence.fence) != VK_SUCCESS)
|
||||
goto fail;
|
||||
if (VKSCR(CreateFence)(screen->dev, &fci, NULL, &bs->fence.fence) != VK_SUCCESS)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
util_queue_fence_init(&bs->flush_completed);
|
||||
bs->queue = screen->threaded ? screen->thread_queue : screen->queue;
|
||||
|
|
@ -288,7 +290,7 @@ get_batch_state(struct zink_context *ctx, struct zink_batch *batch)
|
|||
}
|
||||
simple_mtx_unlock(&ctx->batch_mtx);
|
||||
if (bs) {
|
||||
if (bs->fence.submitted && !bs->fence.completed)
|
||||
if (bs->fence.submitted && !bs->fence.completed && bs->fence.fence)
|
||||
/* this fence is already done, so we need vulkan to release the cmdbuf */
|
||||
zink_vkfence_wait(screen, &bs->fence, PIPE_TIMEOUT_INFINITE);
|
||||
zink_reset_batch_state(ctx, bs);
|
||||
|
|
@ -374,7 +376,7 @@ submit_queue(void *data, void *gdata, int thread_index)
|
|||
}
|
||||
}
|
||||
|
||||
if (VKSCR(ResetFences)(screen->dev, 1, &bs->fence.fence) != VK_SUCCESS) {
|
||||
if (bs->fence.fence && VKSCR(ResetFences)(screen->dev, 1, &bs->fence.fence) != VK_SUCCESS) {
|
||||
mesa_loge("ZINK: vkResetFences failed");
|
||||
}
|
||||
|
||||
|
|
@ -473,7 +475,7 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
|
|||
if (!zink_check_batch_completion(ctx, fence->batch_id, true))
|
||||
break;
|
||||
|
||||
if (bs->fence.submitted && !bs->fence.completed)
|
||||
if (bs->fence.submitted && !bs->fence.completed && bs->fence.fence)
|
||||
/* this fence is already done, so we need vulkan to release the cmdbuf */
|
||||
zink_vkfence_wait(screen, &bs->fence, PIPE_TIMEOUT_INFINITE);
|
||||
pop_batch_state(ctx);
|
||||
|
|
|
|||
|
|
@ -2612,8 +2612,12 @@ reapply_color_write(struct zink_context *ctx)
|
|||
static void
|
||||
stall(struct zink_context *ctx)
|
||||
{
|
||||
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
||||
sync_flush(ctx, zink_batch_state(ctx->last_fence));
|
||||
zink_vkfence_wait(zink_screen(ctx->base.screen), ctx->last_fence, PIPE_TIMEOUT_INFINITE);
|
||||
if (ctx->have_timelines)
|
||||
zink_screen_timeline_wait(screen, ctx->last_fence->batch_id, PIPE_TIMEOUT_INFINITE);
|
||||
else
|
||||
zink_vkfence_wait(screen, ctx->last_fence, PIPE_TIMEOUT_INFINITE);
|
||||
zink_batch_reset_all(ctx);
|
||||
}
|
||||
|
||||
|
|
@ -3326,7 +3330,9 @@ zink_flush(struct pipe_context *pctx,
|
|||
* in some cases in order to correctly draw the first frame, though it's
|
||||
* unknown at this time why this is the case
|
||||
*/
|
||||
if (!ctx->first_frame_done)
|
||||
if (screen->info.have_KHR_timeline_semaphore)
|
||||
zink_screen_timeline_wait(screen, fence->batch_id, PIPE_TIMEOUT_INFINITE);
|
||||
else
|
||||
zink_vkfence_wait(screen, fence, PIPE_TIMEOUT_INFINITE);
|
||||
ctx->first_frame_done = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,6 +117,27 @@ tc_fence_finish(struct zink_context *ctx, struct zink_tc_fence *mfence, uint64_t
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
fence_wait(struct zink_screen *screen, struct zink_fence *fence, uint64_t timeout_ns)
|
||||
{
|
||||
if (screen->device_lost)
|
||||
return true;
|
||||
if (p_atomic_read(&fence->completed))
|
||||
return true;
|
||||
|
||||
assert(fence->batch_id);
|
||||
assert(fence->submitted);
|
||||
|
||||
bool success = zink_screen_timeline_wait(screen, fence->batch_id, timeout_ns);
|
||||
|
||||
if (success) {
|
||||
p_atomic_set(&fence->completed, true);
|
||||
zink_batch_state(fence)->usage.usage = 0;
|
||||
zink_screen_update_last_finished(screen, fence->batch_id);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
bool
|
||||
zink_vkfence_wait(struct zink_screen *screen, struct zink_fence *fence, uint64_t timeout_ns)
|
||||
{
|
||||
|
|
@ -186,6 +207,8 @@ zink_fence_finish(struct zink_screen *screen, struct pipe_context *pctx, struct
|
|||
if (fence->submitted && zink_screen_check_last_finished(screen, fence->batch_id))
|
||||
return true;
|
||||
|
||||
if (screen->info.have_KHR_timeline_semaphore)
|
||||
return fence_wait(screen, fence, timeout_ns);
|
||||
return zink_vkfence_wait(screen, fence, timeout_ns);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue