[FFmpeg-cvslog] lavfi/vulkan: fix static descriptor set updating

Lynne git at videolan.org
Tue Nov 16 11:35:50 EET 2021


ffmpeg | branch: master | Lynne <dev at lynne.ee> | Tue Nov 16 10:22:03 2021 +0100| [8f9888a8d4f5254aba8ab75a352539b3a46a36cb] | committer: Lynne

lavfi/vulkan: fix static descriptor set updating

Update all descriptor sets for all queues if a descriptor set hasn't
been initialized yet.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8f9888a8d4f5254aba8ab75a352539b3a46a36cb
---

 libavfilter/vulkan.c | 21 +++++++++++++++++++++
 libavfilter/vulkan.h |  1 +
 2 files changed, 22 insertions(+)

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;



More information about the ffmpeg-cvslog mailing list