diff options
author | Lynne <dev@lynne.ee> | 2024-11-18 06:15:39 +0100 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2024-11-18 07:54:20 +0100 |
commit | 1876026f83bd1d270b014bab35139445245b5d1b (patch) | |
tree | 30e5c20bccddab16f014e1944f2eaef2e0c07217 /libavutil | |
parent | c918b42dcdb76a0326059c9c35678591bf2c3031 (diff) | |
download | ffmpeg-1876026f83bd1d270b014bab35139445245b5d1b.tar.gz |
vulkan: add ff_vk_exec_add_dep_sw_frame
Some software frames may be mapped, and we'd like to have
them as proper dependencies.
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/vulkan.c | 26 | ||||
-rw-r--r-- | libavutil/vulkan.h | 7 |
2 files changed, 33 insertions, 0 deletions
diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index d5299ffb06..a04dfbfadf 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -255,6 +255,7 @@ void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool) ff_vk_exec_discard_deps(s, e); av_free(e->frame_deps); + av_free(e->sw_frame_deps); av_free(e->buf_deps); av_free(e->queue_family_dst); av_free(e->layout_dst); @@ -551,6 +552,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_sw_frame_deps; j++) + av_frame_free(&e->sw_frame_deps[j]); + e->nb_sw_frame_deps = 0; + for (int j = 0; j < e->nb_frame_deps; j++) { AVFrame *f = e->frame_deps[j]; if (e->frame_locked[j]) { @@ -595,6 +600,27 @@ int ff_vk_exec_add_dep_buf(FFVulkanContext *s, FFVkExecContext *e, return 0; } +int ff_vk_exec_add_dep_sw_frame(FFVulkanContext *s, FFVkExecContext *e, + AVFrame *f) +{ + AVFrame **dst = av_fast_realloc(e->sw_frame_deps, &e->sw_frame_deps_alloc_size, + (e->nb_sw_frame_deps + 1) * sizeof(*dst)); + if (!dst) { + ff_vk_exec_discard_deps(s, e); + return AVERROR(ENOMEM); + } + + e->sw_frame_deps = dst; + + e->sw_frame_deps[e->nb_sw_frame_deps] = av_frame_clone(f); + if (!e->sw_frame_deps[e->nb_sw_frame_deps]) { + ff_vk_exec_discard_deps(s, e); + return AVERROR(ENOMEM); + } + + return 0; +} + #define ARR_REALLOC(str, arr, alloc_s, cnt) \ do { \ arr = av_fast_realloc(str->arr, alloc_s, (cnt + 1)*sizeof(*arr)); \ diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h index 4394894baa..9b46a279ca 100644 --- a/libavutil/vulkan.h +++ b/libavutil/vulkan.h @@ -134,6 +134,11 @@ typedef struct FFVkExecContext { unsigned int frame_deps_alloc_size; int nb_frame_deps; + /* Software frame dependencies */ + AVFrame **sw_frame_deps; + unsigned int sw_frame_deps_alloc_size; + int nb_sw_frame_deps; + VkSemaphoreSubmitInfo *sem_wait; unsigned int sem_wait_alloc; int sem_wait_cnt; @@ -441,6 +446,8 @@ int ff_vk_exec_add_dep_bool_sem(FFVulkanContext *s, FFVkExecContext *e, int ff_vk_exec_add_dep_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkPipelineStageFlagBits2 wait_stage, VkPipelineStageFlagBits2 signal_stage); +int ff_vk_exec_add_dep_sw_frame(FFVulkanContext *s, FFVkExecContext *e, + AVFrame *f); void ff_vk_exec_update_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkImageMemoryBarrier2 *bar, uint32_t *nb_img_bar); int ff_vk_exec_mirror_sem_value(FFVulkanContext *s, FFVkExecContext *e, |