aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2022-12-22 05:02:50 +0100
committerLynne <dev@lynne.ee>2023-05-29 00:41:46 +0200
commitf3fb1b50bba09d0a3e8583102b663a348cd92220 (patch)
tree5ae0f35dc53d9f3998086c9f6405547984bd4b2e
parentd386988c39670aadb4fa9d22bc1e0f3be8373b5c (diff)
downloadffmpeg-f3fb1b50bba09d0a3e8583102b663a348cd92220.tar.gz
vulkan: minor indent fix, add support for synchronous submission/waiting
-rw-r--r--libavutil/vulkan.c20
-rw-r--r--libavutil/vulkan.h9
2 files changed, 27 insertions, 2 deletions
diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index 8a583248d1..b5e08ecc46 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -564,7 +564,7 @@ int ff_vk_create_exec_ctx(FFVulkanContext *s, FFVkExecContext **ctx,
/* Create command pool */
ret = vk->CreateCommandPool(s->hwctx->act_dev, &cqueue_create,
- s->hwctx->alloc, &e->pool);
+ s->hwctx->alloc, &e->pool);
if (ret != VK_SUCCESS) {
av_log(s, AV_LOG_ERROR, "Command pool creation failure: %s\n",
ff_vk_ret2str(ret));
@@ -631,11 +631,13 @@ int ff_vk_start_exec_recording(FFVulkanContext *s, FFVkExecContext *e)
ff_vk_ret2str(ret));
return AVERROR_EXTERNAL;
}
- } else {
+ } else if (!q->synchronous) {
vk->WaitForFences(s->hwctx->act_dev, 1, &q->fence, VK_TRUE, UINT64_MAX);
vk->ResetFences(s->hwctx->act_dev, 1, &q->fence);
}
+ q->synchronous = 0;
+
/* Discard queue dependencies */
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++)
*e->sem_sig_val_dst[i] += 1;
+ q->submitted = 1;
+
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,
AVBufferRef **deps, int nb_deps)
{
diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
index 2cd2c1f8fa..a17cc4a34e 100644
--- a/libavutil/vulkan.h
+++ b/libavutil/vulkan.h
@@ -147,6 +147,9 @@ typedef struct FFVkQueueCtx {
VkFence fence;
VkQueue queue;
+ int synchronous;
+ int submitted;
+
/* Buffer dependencies */
AVBufferRef **buf_deps;
int nb_buf_deps;
@@ -418,6 +421,12 @@ int ff_vk_add_exec_dep(FFVulkanContext *s, FFVkExecContext *e, AVFrame *frame,
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.
*/
int ff_vk_create_buf(FFVulkanContext *s, FFVkBuffer *buf, size_t size,