mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-14 02:50:11 +01:00
vulkan: remove pointless mutex locks
This code was simply incorrect through and through. It did not protect what actually has to be protected in a multi-threaded setup. Perhaps it was used to silence threading errors? Either way, remove it, and document the correct way to use execution pools in a threaded environment.
This commit is contained in:
@@ -251,7 +251,6 @@ void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
|
|||||||
vk->WaitForFences(s->hwctx->act_dev, 1, &e->fence, VK_TRUE, UINT64_MAX);
|
vk->WaitForFences(s->hwctx->act_dev, 1, &e->fence, VK_TRUE, UINT64_MAX);
|
||||||
vk->DestroyFence(s->hwctx->act_dev, e->fence, s->hwctx->alloc);
|
vk->DestroyFence(s->hwctx->act_dev, e->fence, s->hwctx->alloc);
|
||||||
}
|
}
|
||||||
pthread_mutex_destroy(&e->lock);
|
|
||||||
|
|
||||||
ff_vk_exec_discard_deps(s, e);
|
ff_vk_exec_discard_deps(s, e);
|
||||||
|
|
||||||
@@ -424,11 +423,6 @@ int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf,
|
|||||||
.flags = VK_FENCE_CREATE_SIGNALED_BIT,
|
.flags = VK_FENCE_CREATE_SIGNALED_BIT,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Mutex */
|
|
||||||
err = pthread_mutex_init(&e->lock, NULL);
|
|
||||||
if (err != 0)
|
|
||||||
return AVERROR(err);
|
|
||||||
|
|
||||||
/* Fence */
|
/* Fence */
|
||||||
ret = vk->CreateFence(s->hwctx->act_dev, &fence_create, s->hwctx->alloc,
|
ret = vk->CreateFence(s->hwctx->act_dev, &fence_create, s->hwctx->alloc,
|
||||||
&e->fence);
|
&e->fence);
|
||||||
@@ -498,10 +492,8 @@ FFVkExecContext *ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool)
|
|||||||
void ff_vk_exec_wait(FFVulkanContext *s, FFVkExecContext *e)
|
void ff_vk_exec_wait(FFVulkanContext *s, FFVkExecContext *e)
|
||||||
{
|
{
|
||||||
FFVulkanFunctions *vk = &s->vkfn;
|
FFVulkanFunctions *vk = &s->vkfn;
|
||||||
pthread_mutex_lock(&e->lock);
|
|
||||||
vk->WaitForFences(s->hwctx->act_dev, 1, &e->fence, VK_TRUE, UINT64_MAX);
|
vk->WaitForFences(s->hwctx->act_dev, 1, &e->fence, VK_TRUE, UINT64_MAX);
|
||||||
ff_vk_exec_discard_deps(s, e);
|
ff_vk_exec_discard_deps(s, e);
|
||||||
pthread_mutex_unlock(&e->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
|
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
|
||||||
@@ -517,11 +509,7 @@ int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
|
|||||||
|
|
||||||
/* Wait for the fence to be signalled */
|
/* Wait for the fence to be signalled */
|
||||||
vk->WaitForFences(s->hwctx->act_dev, 1, &e->fence, VK_TRUE, UINT64_MAX);
|
vk->WaitForFences(s->hwctx->act_dev, 1, &e->fence, VK_TRUE, UINT64_MAX);
|
||||||
|
|
||||||
/* vkResetFences is defined as being host-synchronized */
|
|
||||||
pthread_mutex_lock(&e->lock);
|
|
||||||
vk->ResetFences(s->hwctx->act_dev, 1, &e->fence);
|
vk->ResetFences(s->hwctx->act_dev, 1, &e->fence);
|
||||||
pthread_mutex_unlock(&e->lock);
|
|
||||||
|
|
||||||
/* Discard queue dependencies */
|
/* Discard queue dependencies */
|
||||||
ff_vk_exec_discard_deps(s, e);
|
ff_vk_exec_discard_deps(s, e);
|
||||||
|
|||||||
@@ -400,6 +400,8 @@ int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocates/frees an execution pool.
|
* Allocates/frees an execution pool.
|
||||||
|
* If used in a multi-threaded context, there must be at least as many contexts
|
||||||
|
* as there are threads.
|
||||||
* ff_vk_exec_pool_init_desc() MUST be called if ff_vk_exec_descriptor_set_add()
|
* ff_vk_exec_pool_init_desc() MUST be called if ff_vk_exec_descriptor_set_add()
|
||||||
* has been called.
|
* has been called.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user