This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 24170896fa14845e2549ef5db47a4cddf660609b
Author:     Lynne <[email protected]>
AuthorDate: Sun Jul 26 15:38:21 2026 +0800
Commit:     Lynne <[email protected]>
CommitDate: Wed Aug 5 16:04:36 2026 +0900

    vulkan: allow tracking AVRefStruct objects as execution dependencies
    
    RefStructs > BufferRefs. We're converting everything.
---
 libavutil/vulkan.c | 33 ++++++++++++++++++++++++++++++++-
 libavutil/vulkan.h | 17 +++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index 5b8f7497aa..fd408785f0 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "avassert.h"
 #include "mem.h"
+#include "refstruct.h"
 
 #include "vulkan.h"
 #include "libavutil/vulkan_loader.h"
@@ -566,7 +567,8 @@ FFVkExecContext *ff_vk_exec_get(FFVulkanContext *s, 
FFVkExecPool *pool)
         FFVkExecContext *e = &pool->contexts[i];
         if (pthread_mutex_trylock(&e->lock))
             continue; /* In use by a recording or submitting thread */
-        if ((e->nb_buf_deps || e->nb_frame_deps || e->nb_sw_frame_deps) &&
+        if ((e->nb_buf_deps || e->nb_refstruct_deps ||
+             e->nb_frame_deps || e->nb_sw_frame_deps) &&
             vk->GetFenceStatus(s->hwctx->act_dev, e->fence) == VK_SUCCESS)
             ff_vk_exec_discard_deps(s, e);
         pthread_mutex_unlock(&e->lock);
@@ -627,6 +629,10 @@ void ff_vk_exec_discard_deps(FFVulkanContext *s, 
FFVkExecContext *e)
         av_buffer_unref(&e->buf_deps[j]);
     e->nb_buf_deps = 0;
 
+    for (int j = 0; j < e->nb_refstruct_deps; j++)
+        av_refstruct_unref(&e->refstruct_deps[j]);
+    e->nb_refstruct_deps = 0;
+
     for (int j = 0; j < e->nb_sw_frame_deps; j++)
         av_frame_free(&e->sw_frame_deps[j]);
     e->nb_sw_frame_deps = 0;
@@ -669,6 +675,31 @@ int ff_vk_exec_add_dep_buf(FFVulkanContext *s, 
FFVkExecContext *e,
     return 0;
 }
 
+void ff_vk_exec_add_dep_refstruct(FFVulkanContext *s, FFVkExecContext *e,
+                                  void *obj)
+{
+    av_assert1(e->nb_refstruct_deps < FF_VK_EXEC_MAX_BUF_DEPS);
+    e->refstruct_deps[e->nb_refstruct_deps++] = av_refstruct_ref(obj);
+}
+
+void ff_vk_exec_move_dep_refstruct(FFVulkanContext *s, FFVkExecContext *e,
+                                   void *obj)
+{
+    void **ptr = obj;
+
+    av_assert1(e->nb_refstruct_deps < FF_VK_EXEC_MAX_BUF_DEPS);
+
+    for (int i = 0; i < e->nb_refstruct_deps; i++) {
+        if (e->refstruct_deps[i] == *ptr) {
+            av_refstruct_unref(obj);
+            return;
+        }
+    }
+
+    e->refstruct_deps[e->nb_refstruct_deps++] = *ptr;
+    *ptr = NULL;
+}
+
 int ff_vk_exec_add_dep_sw_frame(FFVulkanContext *s, FFVkExecContext *e,
                                 AVFrame *f)
 {
diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
index cb80b8c8d3..ffdc1ff7b9 100644
--- a/libavutil/vulkan.h
+++ b/libavutil/vulkan.h
@@ -23,6 +23,8 @@
 
 #include <stdatomic.h>
 
+#include "refstruct.h"
+
 #include "thread.h"
 #include "pixdesc.h"
 #include "hwcontext.h"
@@ -149,6 +151,10 @@ typedef struct FFVkExecContext {
     AVBufferRef *buf_deps[FF_VK_EXEC_MAX_BUF_DEPS];
     int nb_buf_deps;
 
+    /* AVRefStruct object dependencies */
+    void *refstruct_deps[FF_VK_EXEC_MAX_BUF_DEPS];
+    int nb_refstruct_deps;
+
     /* Frame dependencies */
     AVFrame *frame_deps[FF_VK_EXEC_MAX_FRAME_DEPS];
     int nb_frame_deps;
@@ -478,6 +484,17 @@ void ff_vk_exec_wait(FFVulkanContext *s, FFVkExecContext 
*e);
  */
 int ff_vk_exec_add_dep_buf(FFVulkanContext *s, FFVkExecContext *e,
                            AVBufferRef **deps, int nb_deps, int ref);
+
+/* Takes a new reference to an AVRefStruct-managed object, held until the
+ * execution's dependencies are released. */
+void ff_vk_exec_add_dep_refstruct(FFVulkanContext *s, FFVkExecContext *e,
+                                  void *obj);
+
+/* Moves the caller's reference into the execution's dependencies, given a
+ * pointer to it; a duplicate of an already-tracked object is released. */
+void ff_vk_exec_move_dep_refstruct(FFVulkanContext *s, FFVkExecContext *e,
+                                   void *obj);
+
 void ff_vk_exec_add_dep_wait_sem(FFVulkanContext *s, FFVkExecContext *e,
                                  VkSemaphore sem, uint64_t val,
                                  VkPipelineStageFlagBits2 stage);

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to