diff options
author | Lynne <dev@lynne.ee> | 2021-11-16 10:22:03 +0100 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2021-11-16 10:32:35 +0100 |
commit | 8f9888a8d4f5254aba8ab75a352539b3a46a36cb (patch) | |
tree | 0da1e1f777254dd1cb2bea956a1bed33bcff853c | |
parent | 5fc935c7fa6ee943a05b0624ab60a4e3aff4874a (diff) | |
download | ffmpeg-8f9888a8d4f5254aba8ab75a352539b3a46a36cb.tar.gz |
lavfi/vulkan: fix static descriptor set updating
Update all descriptor sets for all queues if a descriptor set hasn't
been initialized yet.
-rw-r--r-- | libavfilter/vulkan.c | 21 | ||||
-rw-r--r-- | libavfilter/vulkan.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/libavfilter/vulkan.c b/libavfilter/vulkan.c index a30699963e..5258e0c3d6 100644 --- a/libavfilter/vulkan.c +++ b/libavfilter/vulkan.c @@ -1105,6 +1105,13 @@ int ff_vk_add_descriptor_set(AVFilterContext *avctx, FFVulkanPipeline *pl, if (!pl->desc_layout) return AVERROR(ENOMEM); + pl->desc_set_initialized = av_realloc_array(pl->desc_set_initialized, + sizeof(*pl->desc_set_initialized), + pl->descriptor_sets_num + 1); + if (!pl->desc_set_initialized) + return AVERROR(ENOMEM); + + pl->desc_set_initialized[pl->descriptor_sets_num] = 0; layout = &pl->desc_layout[pl->desc_layout_num]; { /* Create descriptor set layout descriptions */ @@ -1245,6 +1252,19 @@ void ff_vk_update_descriptor_set(AVFilterContext *avctx, FFVulkanPipeline *pl, FFVulkanContext *s = avctx->priv; FFVulkanFunctions *vk = &s->vkfn; + /* If a set has never been updated, update all queues' sets. */ + if (!pl->desc_set_initialized[set_id]) { + for (int i = 0; i < pl->qf->nb_queues; i++) { + set_id = set_id*pl->qf->nb_queues + i; + vk->UpdateDescriptorSetWithTemplate(s->hwctx->act_dev, + pl->desc_set[set_id], + pl->desc_template[set_id], + s); + } + pl->desc_set_initialized[set_id] = 1; + return; + } + set_id = set_id*pl->qf->nb_queues + pl->qf->cur_queue; vk->UpdateDescriptorSetWithTemplate(s->hwctx->act_dev, @@ -1514,6 +1534,7 @@ static void free_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl) av_freep(&pl->shaders); av_freep(&pl->desc_layout); av_freep(&pl->desc_template); + av_freep(&pl->desc_set_initialized); av_freep(&pl->push_consts); pl->push_consts_num = 0; diff --git a/libavfilter/vulkan.h b/libavfilter/vulkan.h index 9d17d2b14f..df8abf9e30 100644 --- a/libavfilter/vulkan.h +++ b/libavfilter/vulkan.h @@ -113,6 +113,7 @@ typedef struct FFVulkanPipeline { void **desc_staging; VkDescriptorSetLayoutBinding **desc_binding; VkDescriptorUpdateTemplate *desc_template; + int *desc_set_initialized; int desc_layout_num; int descriptor_sets_num; int total_descriptor_sets; |