History

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.

Lynne committed 1 year ago

Commit 157cd821 parent 7239be02 files · +2 −12Browse files

Unified · Split

2 files
  1. libavutil/vulkan.c +0 −12
  2. libavutil/vulkan.h +2 −0
libavutil/vulkan.c+0−12
@@ -251,7 +251,6 @@ void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool) · 250 unmodified lines
251251 vk->WaitForFences(s->hwctx->act_dev, 1, &e->fence, VK_TRUE, UINT64_MAX);
252252 vk->DestroyFence(s->hwctx->act_dev, e->fence, s->hwctx->alloc);
253253 }
254− pthread_mutex_destroy(&e->lock);
255254
256255 ff_vk_exec_discard_deps(s, e);
257256
@@ -424,11 +423,6 @@ int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, · 166 unmodified lines
424423 .flags = VK_FENCE_CREATE_SIGNALED_BIT,
425424 };
426425
427− /* Mutex */
428− err = pthread_mutex_init(&e->lock, NULL);
429− if (err != 0)
430− return AVERROR(err);
431−
432426 /* Fence */
433427 ret = vk->CreateFence(s->hwctx->act_dev, &fence_create, s->hwctx->alloc,
434428 &e->fence);
@@ -498,10 +492,8 @@ FFVkExecContext *ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool) · 63 unmodified lines
498492 void ff_vk_exec_wait(FFVulkanContext *s, FFVkExecContext *e)
499493 {
500494 FFVulkanFunctions *vk = &s->vkfn;
501− pthread_mutex_lock(&e->lock);
502495 vk->WaitForFences(s->hwctx->act_dev, 1, &e->fence, VK_TRUE, UINT64_MAX);
503496 ff_vk_exec_discard_deps(s, e);
504− pthread_mutex_unlock(&e->lock);
505497 }
506498
507499 int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
@@ -517,11 +509,7 @@ int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e) · 9 unmodified lines
517509
518510 /* Wait for the fence to be signalled */
519511 vk->WaitForFences(s->hwctx->act_dev, 1, &e->fence, VK_TRUE, UINT64_MAX);
520−
521− /* vkResetFences is defined as being host-synchronized */
522− pthread_mutex_lock(&e->lock);
523512 vk->ResetFences(s->hwctx->act_dev, 1, &e->fence);
524− pthread_mutex_unlock(&e->lock);
525513
526514 /* Discard queue dependencies */
527515 ff_vk_exec_discard_deps(s, e);
libavutil/vulkan.h+2−0
@@ -400,6 +400,8 @@ int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, · 399 unmodified lines
400400
401401 /**
402402 * Allocates/frees an execution pool.
403+ * If used in a multi-threaded context, there must be at least as many contexts
404+ * as there are threads.
403405 * ff_vk_exec_pool_init_desc() MUST be called if ff_vk_exec_descriptor_set_add()
404406 * has been called.
405407 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t