vulkan: minor indent fix, add support for synchronous submission/waiting

This commit is contained in:
Lynne
2022-12-22 05:02:50 +01:00
parent d386988c39
commit f3fb1b50bb
2 changed files with 27 additions and 2 deletions

View File

@ -631,11 +631,13 @@ int ff_vk_start_exec_recording(FFVulkanContext *s, FFVkExecContext *e)
ff_vk_ret2str(ret)); ff_vk_ret2str(ret));
return AVERROR_EXTERNAL; return AVERROR_EXTERNAL;
} }
} else { } else if (!q->synchronous) {
vk->WaitForFences(s->hwctx->act_dev, 1, &q->fence, VK_TRUE, UINT64_MAX); vk->WaitForFences(s->hwctx->act_dev, 1, &q->fence, VK_TRUE, UINT64_MAX);
vk->ResetFences(s->hwctx->act_dev, 1, &q->fence); vk->ResetFences(s->hwctx->act_dev, 1, &q->fence);
} }
q->synchronous = 0;
/* Discard queue dependencies */ /* Discard queue dependencies */
ff_vk_discard_exec_deps(e); ff_vk_discard_exec_deps(e);
@ -788,9 +790,23 @@ int ff_vk_submit_exec_queue(FFVulkanContext *s, FFVkExecContext *e)
for (int i = 0; i < e->sem_sig_cnt; i++) for (int i = 0; i < e->sem_sig_cnt; i++)
*e->sem_sig_val_dst[i] += 1; *e->sem_sig_val_dst[i] += 1;
q->submitted = 1;
return 0; return 0;
} }
void ff_vk_wait_on_exec_ctx(FFVulkanContext *s, FFVkExecContext *e)
{
FFVulkanFunctions *vk = &s->vkfn;
FFVkQueueCtx *q = &e->queues[e->qf->cur_queue];
if (!q->submitted)
return;
vk->WaitForFences(s->hwctx->act_dev, 1, &q->fence, VK_TRUE, UINT64_MAX);
vk->ResetFences(s->hwctx->act_dev, 1, &q->fence);
q->synchronous = 1;
}
int ff_vk_add_dep_exec_ctx(FFVulkanContext *s, FFVkExecContext *e, int ff_vk_add_dep_exec_ctx(FFVulkanContext *s, FFVkExecContext *e,
AVBufferRef **deps, int nb_deps) AVBufferRef **deps, int nb_deps)
{ {

View File

@ -147,6 +147,9 @@ typedef struct FFVkQueueCtx {
VkFence fence; VkFence fence;
VkQueue queue; VkQueue queue;
int synchronous;
int submitted;
/* Buffer dependencies */ /* Buffer dependencies */
AVBufferRef **buf_deps; AVBufferRef **buf_deps;
int nb_buf_deps; int nb_buf_deps;
@ -417,6 +420,12 @@ int ff_vk_add_exec_dep(FFVulkanContext *s, FFVkExecContext *e, AVFrame *frame,
*/ */
int ff_vk_submit_exec_queue(FFVulkanContext *s, FFVkExecContext *e); int ff_vk_submit_exec_queue(FFVulkanContext *s, FFVkExecContext *e);
/**
* Wait on a command buffer's execution. Mainly useful for debugging and
* development.
*/
void ff_vk_wait_on_exec_ctx(FFVulkanContext *s, FFVkExecContext *e);
/** /**
* Create a VkBuffer with the specified parameters. * Create a VkBuffer with the specified parameters.
*/ */