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.
This commit is contained in:
Lynne 2024-11-18 06:15:39 +01:00
parent c918b42dcd
commit 1876026f83
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
2 changed files with 33 additions and 0 deletions

View File

@ -255,6 +255,7 @@ void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
ff_vk_exec_discard_deps(s, e); ff_vk_exec_discard_deps(s, e);
av_free(e->frame_deps); av_free(e->frame_deps);
av_free(e->sw_frame_deps);
av_free(e->buf_deps); av_free(e->buf_deps);
av_free(e->queue_family_dst); av_free(e->queue_family_dst);
av_free(e->layout_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]); av_buffer_unref(&e->buf_deps[j]);
e->nb_buf_deps = 0; 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++) { for (int j = 0; j < e->nb_frame_deps; j++) {
AVFrame *f = e->frame_deps[j]; AVFrame *f = e->frame_deps[j];
if (e->frame_locked[j]) { if (e->frame_locked[j]) {
@ -595,6 +600,27 @@ int ff_vk_exec_add_dep_buf(FFVulkanContext *s, FFVkExecContext *e,
return 0; 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) \ #define ARR_REALLOC(str, arr, alloc_s, cnt) \
do { \ do { \
arr = av_fast_realloc(str->arr, alloc_s, (cnt + 1)*sizeof(*arr)); \ arr = av_fast_realloc(str->arr, alloc_s, (cnt + 1)*sizeof(*arr)); \

View File

@ -134,6 +134,11 @@ typedef struct FFVkExecContext {
unsigned int frame_deps_alloc_size; unsigned int frame_deps_alloc_size;
int nb_frame_deps; 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; VkSemaphoreSubmitInfo *sem_wait;
unsigned int sem_wait_alloc; unsigned int sem_wait_alloc;
int sem_wait_cnt; 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, int ff_vk_exec_add_dep_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f,
VkPipelineStageFlagBits2 wait_stage, VkPipelineStageFlagBits2 wait_stage,
VkPipelineStageFlagBits2 signal_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, void ff_vk_exec_update_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f,
VkImageMemoryBarrier2 *bar, uint32_t *nb_img_bar); VkImageMemoryBarrier2 *bar, uint32_t *nb_img_bar);
int ff_vk_exec_mirror_sem_value(FFVulkanContext *s, FFVkExecContext *e, int ff_vk_exec_mirror_sem_value(FFVulkanContext *s, FFVkExecContext *e,