diff options
author | Lynne <dev@lynne.ee> | 2024-09-29 08:07:05 +0200 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2024-10-04 10:10:42 +0200 |
commit | 37d5cb84e8ab724e575c5819518f761ba88886c7 (patch) | |
tree | 2dc8684b34ccc03a0facd80d097460516459df94 /libavutil/vulkan.c | |
parent | 877c5a969233866983ff0c4e7b32b83a00ce0973 (diff) | |
download | ffmpeg-37d5cb84e8ab724e575c5819518f761ba88886c7.tar.gz |
vulkan: check if current buffer has finished execution before picking another
This saves resources, as dependencies are freed/reclaimed with a lower latency,
and provies a speedup.
Diffstat (limited to 'libavutil/vulkan.c')
-rw-r--r-- | libavutil/vulkan.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index 7f9008618e..1dc168e645 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -482,11 +482,18 @@ VkResult ff_vk_exec_get_query(FFVulkanContext *s, FFVkExecContext *e, pool->qd_size, qf); } -FFVkExecContext *ff_vk_exec_get(FFVkExecPool *pool) +FFVkExecContext *ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool) { - uint32_t idx = pool->idx++; - idx %= pool->pool_size; - return &pool->contexts[idx]; + FFVulkanFunctions *vk = &s->vkfn; + FFVkExecContext *e = &pool->contexts[pool->idx]; + + /* Check if last submission has already finished. + * If so, don't waste resources and reuse the same buffer. */ + if (vk->GetFenceStatus(s->hwctx->act_dev, e->fence) == VK_SUCCESS) + return e; + + pool->idx = (pool->idx + 1) % pool->pool_size; + return &pool->contexts[pool->idx]; } void ff_vk_exec_wait(FFVulkanContext *s, FFVkExecContext *e) |