For in-fence handling, dri2 has this below sequence in a row:
1. create_fence_fd: import external fence fd
2. fence_server_sync: import the pipe fence into the driver ctx
3. fence_reference: deref the created pipe fence
Before this change, zink pushed the wrapped external semaphore to the
wait semaphores of the next batch but the followed fence_reference will
destroy the imported semaphore immediately. Instead of extending the
lifecycle of the pipe fence throughout the batch state, we can simply
transfer the semaphore ownership to the batch and destroy it upon batch
reset.
Fixes:
32597e116d7 ("zink: implement GL semaphores")
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18453>
bs->resource_size = 0;
bs->signal_semaphore = VK_NULL_HANDLE;
- util_dynarray_clear(&bs->wait_semaphores);
+ while (util_dynarray_contains(&bs->wait_semaphores, VkSemaphore))
+ VKSCR(DestroySemaphore)(screen->dev, util_dynarray_pop(&bs->wait_semaphores, VkSemaphore), NULL);
util_dynarray_clear(&bs->wait_semaphore_stages);
bs->present = VK_NULL_HANDLE;
{
mfence->fence = NULL;
tc_unflushed_batch_token_reference(&mfence->tc_token, NULL);
- VKSCR(DestroySemaphore)(screen->dev, mfence->sem, NULL);
+ if (mfence->sem)
+ VKSCR(DestroySemaphore)(screen->dev, mfence->sem, NULL);
FREE(mfence);
}
VkPipelineStageFlags flag = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
util_dynarray_append(&ctx->batch.state->wait_semaphores, VkSemaphore, mfence->sem);
util_dynarray_append(&ctx->batch.state->wait_semaphore_stages, VkPipelineStageFlags, flag);
+
+ /* transfer the external wait sempahore ownership to the next submit */
+ mfence->sem = VK_NULL_HANDLE;
}
void