Commit b48b9c7d3e for ffmpeg
commit b48b9c7d3e85cffd8f26da908bd7a9d6a830a632
Author: Emil J. Tywoniak <emil@tywoniak.eu>
Date: Sat Oct 31 18:47:56 2026 +0100
avcodec/vulkan_encode: make the encoded data available to the host
Add a barrier from the encode writes to host reads, so the packet can
be read back after waiting for the submission.
Assisted-by: Claude Opus 5.5
diff --git a/libavcodec/vulkan_encode.c b/libavcodec/vulkan_encode.c
index d654cf05d6..f3bd443954 100644
--- a/libavcodec/vulkan_encode.c
+++ b/libavcodec/vulkan_encode.c
@@ -461,6 +461,19 @@ static int vulkan_encode_issue(AVCodecContext *avctx,
/* End encoding */
vk->CmdEndVideoCodingKHR(cmd_buf, &encode_end);
+ /* For the host to read the output */
+ vk->CmdPipelineBarrier2(cmd_buf, &(VkDependencyInfo) {
+ .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
+ .pMemoryBarriers = &(VkMemoryBarrier2) {
+ .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2,
+ .srcStageMask = VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR,
+ .srcAccessMask = VK_ACCESS_2_VIDEO_ENCODE_WRITE_BIT_KHR,
+ .dstStageMask = VK_PIPELINE_STAGE_2_HOST_BIT,
+ .dstAccessMask = VK_ACCESS_2_HOST_READ_BIT,
+ },
+ .memoryBarrierCount = 1,
+ });
+
/* End recording and submit for execution */
err = ff_vk_exec_submit(&ctx->s, vp->exec);
if (err < 0)