diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index b1640c3dd02..e64549d2182 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -87,7 +87,8 @@ zink_reset_batch_state(struct zink_context *ctx, struct zink_batch_state *bs) 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; diff --git a/src/gallium/drivers/zink/zink_fence.c b/src/gallium/drivers/zink/zink_fence.c index 425136f6e10..28dfded9136 100644 --- a/src/gallium/drivers/zink/zink_fence.c +++ b/src/gallium/drivers/zink/zink_fence.c @@ -37,7 +37,8 @@ destroy_fence(struct zink_screen *screen, struct zink_tc_fence *mfence) { 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); } @@ -221,6 +222,9 @@ zink_fence_server_sync(struct pipe_context *pctx, struct pipe_fence_handle *pfen 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