History

hwcontext_vulkan: use all enabled queues for transfers, make uploads async

This commit makes full use of the enabled queues to provide asynchronous uploads of images (downloads remain synchronous). For a pure uploading use cases, the performance gains can be significant.

Lynne committed 6 years ago

Commit c0b08071 parent cdb949a1 file · +237 −96Browse files

Unified · Split

libavutil/hwcontext_vulkan.c+237−96
@@ -41,11 +41,23 @@ · 40 unmodified lines
4141 #define CHECK_CU(x) FF_CUDA_CHECK_DL(cuda_cu, cu, x)
4242 #endif
4343
44+typedef struct VulkanQueueCtx {
45+ VkFence fence;
46+ VkQueue queue;
47+ int was_synchronous;
48+
49+ /* Buffer dependencies */
50+ AVBufferRef **buf_deps;
51+ int nb_buf_deps;
52+ int buf_deps_alloc_size;
53+} VulkanQueueCtx;
54+
4455 typedef struct VulkanExecCtx {
4556 VkCommandPool pool;
46− VkCommandBuffer buf;
47− VkQueue queue;
48− VkFence fence;
57+ VkCommandBuffer *bufs;
58+ VulkanQueueCtx *queues;
59+ int nb_queues;
60+ int cur_queue_idx;
4961 } VulkanExecCtx;
5062
5163 typedef struct VulkanDevicePriv {
@@ -60,8 +72,9 @@ typedef struct VulkanDevicePriv { · 8 unmodified lines
6072 /* Debug callback */
6173 VkDebugUtilsMessengerEXT debug_ctx;
6274
63− /* Image uploading */
64− VulkanExecCtx cmd;
75+ /* Image transfers */
76+ VulkanExecCtx upload_ctx;
77+ VulkanExecCtx download_ctx;
6578
6679 /* Extensions */
6780 uint64_t extensions;
@@ -89,6 +102,16 @@ typedef struct AVVkFrameInternal { · 21 unmodified lines
89102 #endif
90103 } AVVkFrameInternal;
91104
105+#define GET_QUEUE_COUNT(hwctx, graph, comp, tx) ( \
106+ graph ? hwctx->nb_graphics_queues : \
107+ comp ? (hwctx->nb_comp_queues ? \
108+ hwctx->nb_comp_queues : hwctx->nb_graphics_queues) : \
109+ tx ? (hwctx->nb_tx_queues ? hwctx->nb_tx_queues : \
110+ (hwctx->nb_comp_queues ? \
111+ hwctx->nb_comp_queues : hwctx->nb_graphics_queues)) : \
112+ 0 \
113+)
114+
92115 #define VK_LOAD_PFN(inst, name) PFN_##name pfn_##name = (PFN_##name) \
93116 vkGetInstanceProcAddr(inst, #name)
94117
@@ -709,7 +732,7 @@ fail: · 614 unmodified lines
709732 }
710733
711734 static int create_exec_ctx(AVHWDeviceContext *ctx, VulkanExecCtx *cmd,
712− int queue_family_index)
735+ int queue_family_index, int num_queues)
713736 {
714737 VkResult ret;
715738 AVVulkanDeviceContext *hwctx = ctx->hwctx;
@@ -722,21 +745,20 @@ static int create_exec_ctx(AVHWDeviceContext *ctx, VulkanExecCtx *cmd, · 6 unmodified lines
722745 VkCommandBufferAllocateInfo cbuf_create = {
723746 .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
724747 .level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
725− .commandBufferCount = 1,
748+ .commandBufferCount = num_queues,
726749 };
727750
728− VkFenceCreateInfo fence_spawn = {
729− .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
730− };
751+ cmd->nb_queues = num_queues;
731752
732− ret = vkCreateFence(hwctx->act_dev, &fence_spawn,
733− hwctx->alloc, &cmd->fence);
734− if (ret != VK_SUCCESS) {
735− av_log(ctx, AV_LOG_ERROR, "Failed to create frame fence: %s\n",
736− vk_ret2str(ret));
737− return AVERROR_EXTERNAL;
738− }
753+ cmd->queues = av_mallocz(num_queues * sizeof(*cmd->queues));
754+ if (!cmd->queues)
755+ return AVERROR(ENOMEM);
739756
757+ cmd->bufs = av_mallocz(num_queues * sizeof(*cmd->bufs));
758+ if (!cmd->bufs)
759+ return AVERROR(ENOMEM);
760+
761+ /* Create command pool */
740762 ret = vkCreateCommandPool(hwctx->act_dev, &cqueue_create,
741763 hwctx->alloc, &cmd->pool);
742764 if (ret != VK_SUCCESS) {
@@ -747,15 +769,19 @@ static int create_exec_ctx(AVHWDeviceContext *ctx, VulkanExecCtx *cmd, · 4 unmodified lines
747769
748770 cbuf_create.commandPool = cmd->pool;
749771
750− ret = vkAllocateCommandBuffers(hwctx->act_dev, &cbuf_create, &cmd->buf);
772+ /* Allocate command buffer */
773+ ret = vkAllocateCommandBuffers(hwctx->act_dev, &cbuf_create, cmd->bufs);
751774 if (ret != VK_SUCCESS) {
752775 av_log(ctx, AV_LOG_ERROR, "Command buffer alloc failure: %s\n",
753776 vk_ret2str(ret));
754777 return AVERROR_EXTERNAL;
755778 }
756779
757− vkGetDeviceQueue(hwctx->act_dev, cqueue_create.queueFamilyIndex, 0,
758− &cmd->queue);
780+ for (int i = 0; i < num_queues; i++) {
781+ VulkanQueueCtx *q = &cmd->queues[i];
782+ vkGetDeviceQueue(hwctx->act_dev, queue_family_index, i, &q->queue);
783+ q->was_synchronous = 1;
784+ }
759785
760786 return 0;
761787 }
@@ -764,12 +790,154 @@ static void free_exec_ctx(AVHWDeviceContext *ctx, VulkanExecCtx *cmd) · 2 unmodified lines
764790 {
765791 AVVulkanDeviceContext *hwctx = ctx->hwctx;
766792
767− if (cmd->fence)
768− vkDestroyFence(hwctx->act_dev, cmd->fence, hwctx->alloc);
769− if (cmd->buf)
770− vkFreeCommandBuffers(hwctx->act_dev, cmd->pool, 1, &cmd->buf);
793+ /* Make sure all queues have finished executing */
794+ for (int i = 0; i < cmd->nb_queues; i++) {
795+ VulkanQueueCtx *q = &cmd->queues[i];
796+
797+ if (q->fence && !q->was_synchronous) {
798+ vkWaitForFences(hwctx->act_dev, 1, &q->fence, VK_TRUE, UINT64_MAX);
799+ vkResetFences(hwctx->act_dev, 1, &q->fence);
800+ }
801+
802+ /* Free the fence */
803+ if (q->fence)
804+ vkDestroyFence(hwctx->act_dev, q->fence, hwctx->alloc);
805+
806+ /* Free buffer dependencies */
807+ for (int j = 0; j < q->nb_buf_deps; j++)
808+ av_buffer_unref(&q->buf_deps[j]);
809+ av_free(q->buf_deps);
810+ }
811+
812+ if (cmd->bufs)
813+ vkFreeCommandBuffers(hwctx->act_dev, cmd->pool, cmd->nb_queues, cmd->bufs);
771814 if (cmd->pool)
772815 vkDestroyCommandPool(hwctx->act_dev, cmd->pool, hwctx->alloc);
816+
817+ av_freep(&cmd->bufs);
818+ av_freep(&cmd->queues);
819+}
820+
821+static VkCommandBuffer get_buf_exec_ctx(AVHWDeviceContext *ctx, VulkanExecCtx *cmd)
822+{
823+ return cmd->bufs[cmd->cur_queue_idx];
824+}
825+
826+static void unref_exec_ctx_deps(AVHWDeviceContext *ctx, VulkanExecCtx *cmd)
827+{
828+ VulkanQueueCtx *q = &cmd->queues[cmd->cur_queue_idx];
829+
830+ for (int j = 0; j < q->nb_buf_deps; j++)
831+ av_buffer_unref(&q->buf_deps[j]);
832+ q->nb_buf_deps = 0;
833+}
834+
835+static int wait_start_exec_ctx(AVHWDeviceContext *ctx, VulkanExecCtx *cmd)
836+{
837+ VkResult ret;
838+ AVVulkanDeviceContext *hwctx = ctx->hwctx;
839+ VulkanQueueCtx *q = &cmd->queues[cmd->cur_queue_idx];
840+
841+ VkCommandBufferBeginInfo cmd_start = {
842+ .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
843+ .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
844+ };
845+
846+ /* Create the fence and don't wait for it initially */
847+ if (!q->fence) {
848+ VkFenceCreateInfo fence_spawn = {
849+ .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
850+ };
851+ ret = vkCreateFence(hwctx->act_dev, &fence_spawn, hwctx->alloc,
852+ &q->fence);
853+ if (ret != VK_SUCCESS) {
854+ av_log(ctx, AV_LOG_ERROR, "Failed to queue frame fence: %s\n",
855+ vk_ret2str(ret));
856+ return AVERROR_EXTERNAL;
857+ }
858+ } else if (!q->was_synchronous) {
859+ vkWaitForFences(hwctx->act_dev, 1, &q->fence, VK_TRUE, UINT64_MAX);
860+ vkResetFences(hwctx->act_dev, 1, &q->fence);
861+ }
862+
863+ /* Discard queue dependencies */
864+ unref_exec_ctx_deps(ctx, cmd);
865+
866+ ret = vkBeginCommandBuffer(cmd->bufs[cmd->cur_queue_idx], &cmd_start);
867+ if (ret != VK_SUCCESS) {
868+ av_log(ctx, AV_LOG_ERROR, "Unable to init command buffer: %s\n",
869+ vk_ret2str(ret));
870+ return AVERROR_EXTERNAL;
871+ }
872+
873+ return 0;
874+}
875+
876+static int add_buf_dep_exec_ctx(AVHWDeviceContext *ctx, VulkanExecCtx *cmd,
877+ AVBufferRef * const *deps, int nb_deps)
878+{
879+ AVBufferRef **dst;
880+ VulkanQueueCtx *q = &cmd->queues[cmd->cur_queue_idx];
881+
882+ if (!deps || !nb_deps)
883+ return 0;
884+
885+ dst = av_fast_realloc(q->buf_deps, &q->buf_deps_alloc_size,
886+ (q->nb_buf_deps + nb_deps) * sizeof(*dst));
887+ if (!dst)
888+ goto err;
889+
890+ q->buf_deps = dst;
891+
892+ for (int i = 0; i < nb_deps; i++) {
893+ q->buf_deps[q->nb_buf_deps] = av_buffer_ref(deps[i]);
894+ if (!q->buf_deps[q->nb_buf_deps])
895+ goto err;
896+ q->nb_buf_deps++;
897+ }
898+
899+ return 0;
900+
901+err:
902+ unref_exec_ctx_deps(ctx, cmd);
903+ return AVERROR(ENOMEM);
904+}
905+
906+static int submit_exec_ctx(AVHWDeviceContext *ctx, VulkanExecCtx *cmd,
907+ VkSubmitInfo *s_info, int synchronous)
908+{
909+ VkResult ret;
910+ VulkanQueueCtx *q = &cmd->queues[cmd->cur_queue_idx];
911+
912+ ret = vkEndCommandBuffer(cmd->bufs[cmd->cur_queue_idx]);
913+ if (ret != VK_SUCCESS) {
914+ av_log(ctx, AV_LOG_ERROR, "Unable to finish command buffer: %s\n",
915+ vk_ret2str(ret));
916+ unref_exec_ctx_deps(ctx, cmd);
917+ return AVERROR_EXTERNAL;
918+ }
919+
920+ s_info->pCommandBuffers = &cmd->bufs[cmd->cur_queue_idx];
921+ s_info->commandBufferCount = 1;
922+
923+ ret = vkQueueSubmit(q->queue, 1, s_info, q->fence);
924+ if (ret != VK_SUCCESS) {
925+ unref_exec_ctx_deps(ctx, cmd);
926+ return AVERROR_EXTERNAL;
927+ }
928+
929+ q->was_synchronous = synchronous;
930+
931+ if (synchronous) {
932+ AVVulkanDeviceContext *hwctx = ctx->hwctx;
933+ vkWaitForFences(hwctx->act_dev, 1, &q->fence, VK_TRUE, UINT64_MAX);
934+ vkResetFences(hwctx->act_dev, 1, &q->fence);
935+ unref_exec_ctx_deps(ctx, cmd);
936+ } else { /* Rotate queues */
937+ cmd->cur_queue_idx = (cmd->cur_queue_idx + 1) % cmd->nb_queues;
938+ }
939+
940+ return 0;
773941 }
774942
775943 static void vulkan_device_free(AVHWDeviceContext *ctx)
@@ -937,7 +1105,8 @@ if (n >= queue_num) { · 161 unmodified lines
9371105 p->qfs[p->num_qfs++] = hwctx->queue_family_comp_index;
9381106
9391107 /* Create exec context - if there's something invalid this will error out */
940− err = create_exec_ctx(ctx, &p->cmd, hwctx->queue_family_tx_index);
1108+ err = create_exec_ctx(ctx, &p->cmd, hwctx->queue_family_tx_index,
1109+ GET_QUEUE_COUNT(hwctx, 0, 0, 1));
9411110 if (err)
9421111 return err;
9431112
@@ -1257,26 +1426,17 @@ enum PrepMode { · 313 unmodified lines
12571426 static int prepare_frame(AVHWFramesContext *hwfc, VulkanExecCtx *ectx,
12581427 AVVkFrame *frame, enum PrepMode pmode)
12591428 {
1260− VkResult ret;
1429+ int err;
12611430 uint32_t dst_qf;
12621431 VkImageLayout new_layout;
12631432 VkAccessFlags new_access;
12641433 AVHWDeviceContext *ctx = hwfc->device_ctx;
1265− AVVulkanDeviceContext *hwctx = ctx->hwctx;
12661434 const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
12671435
12681436 VkImageMemoryBarrier img_bar[AV_NUM_DATA_POINTERS] = { 0 };
12691437
1270− VkCommandBufferBeginInfo cmd_start = {
1271− .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
1272− .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
1273− };
1274−
12751438 VkSubmitInfo s_info = {
12761439 .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
1277− .commandBufferCount = 1,
1278− .pCommandBuffers = &ectx->buf,
1279−
12801440 .pSignalSemaphores = frame->sem,
12811441 .signalSemaphoreCount = planes,
12821442 };
@@ -1306,9 +1466,8 @@ static int prepare_frame(AVHWFramesContext *hwfc, VulkanExecCtx *ectx, · 23 unmodified lines
13061466 break;
13071467 }
13081468
1309− ret = vkBeginCommandBuffer(ectx->buf, &cmd_start);
1310− if (ret != VK_SUCCESS)
1311− return AVERROR_EXTERNAL;
1469+ if ((err = wait_start_exec_ctx(ctx, ectx)))
1470+ return err;
13121471
13131472 /* Change the image layout to something more optimal for writes.
13141473 * This also signals the newly created semaphore, making it usable
@@ -1330,23 +1489,12 @@ static int prepare_frame(AVHWFramesContext *hwfc, VulkanExecCtx *ectx, · 15 unmodified lines
13301489 frame->access[i] = img_bar[i].dstAccessMask;
13311490 }
13321491
1333− vkCmdPipelineBarrier(ectx->buf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
1334− VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
1335− 0, NULL, 0, NULL, planes, img_bar);
1336−
1337− ret = vkEndCommandBuffer(ectx->buf);
1338− if (ret != VK_SUCCESS)
1339− return AVERROR_EXTERNAL;
1340−
1341− ret = vkQueueSubmit(ectx->queue, 1, &s_info, ectx->fence);
1342− if (ret != VK_SUCCESS) {
1343− return AVERROR_EXTERNAL;
1344− } else {
1345− vkWaitForFences(hwctx->act_dev, 1, &ectx->fence, VK_TRUE, UINT64_MAX);
1346− vkResetFences(hwctx->act_dev, 1, &ectx->fence);
1347− }
1492+ vkCmdPipelineBarrier(get_buf_exec_ctx(ctx, ectx),
1493+ VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
1494+ VK_PIPELINE_STAGE_TRANSFER_BIT,
1495+ 0, 0, NULL, 0, NULL, planes, img_bar);
13481496
1349− return 0;
1497+ return submit_exec_ctx(ctx, ectx, &s_info, 0);
13501498 }
13511499
13521500 static int create_frame(AVHWFramesContext *hwfc, AVVkFrame **frame,
@@ -1559,7 +1707,8 @@ static int vulkan_frames_init(AVHWFramesContext *hwfc) · 206 unmodified lines
15591707 hwctx->usage |= DEFAULT_USAGE_FLAGS;
15601708
15611709 err = create_exec_ctx(hwfc->device_ctx, &fp->cmd,
1562− dev_hwctx->queue_family_tx_index);
1710+ dev_hwctx->queue_family_tx_index,
1711+ GET_QUEUE_COUNT(dev_hwctx, 0, 0, 1));
15631712 if (err)
15641713 return err;
15651714
@@ -2620,12 +2769,12 @@ static int unmap_buffers(AVHWDeviceContext *ctx, AVBufferRef **bufs, · 1054 unmodified lines
26202769 return err;
26212770 }
26222771
2623−static int transfer_image_buf(AVHWDeviceContext *ctx, AVVkFrame *frame,
2772+static int transfer_image_buf(AVHWDeviceContext *ctx, const AVFrame *f,
26242773 AVBufferRef **bufs, const int *buf_stride, int w,
26252774 int h, enum AVPixelFormat pix_fmt, int to_buf)
26262775 {
2627− VkResult ret;
2628− AVVulkanDeviceContext *hwctx = ctx->hwctx;
2776+ int err;
2777+ AVVkFrame *frame = (AVVkFrame *)f->data[0];
26292778 VulkanDevicePriv *s = ctx->internal->priv;
26302779
26312780 int bar_num = 0;
@@ -2634,17 +2783,11 @@ static int transfer_image_buf(AVHWDeviceContext *ctx, AVVkFrame *frame, · 2 unmodified lines
26342783 const int planes = av_pix_fmt_count_planes(pix_fmt);
26352784 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
26362785
2637− VkCommandBufferBeginInfo cmd_start = {
2638− .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
2639− .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
2640− };
2641−
26422786 VkImageMemoryBarrier img_bar[AV_NUM_DATA_POINTERS] = { 0 };
2787+ VkCommandBuffer cmd_buf = get_buf_exec_ctx(ctx, &s->cmd);
26432788
26442789 VkSubmitInfo s_info = {
26452790 .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
2646− .commandBufferCount = 1,
2647− .pCommandBuffers = &s->cmd.buf,
26482791 .pSignalSemaphores = frame->sem,
26492792 .pWaitSemaphores = frame->sem,
26502793 .pWaitDstStageMask = sem_wait_dst,
@@ -2652,12 +2795,8 @@ static int transfer_image_buf(AVHWDeviceContext *ctx, AVVkFrame *frame, · 1 unmodified line
26522795 .waitSemaphoreCount = planes,
26532796 };
26542797
2655− ret = vkBeginCommandBuffer(s->cmd.buf, &cmd_start);
2656− if (ret != VK_SUCCESS) {
2657− av_log(ctx, AV_LOG_ERROR, "Unable to init command buffer: %s\n",
2658− vk_ret2str(ret));
2659− return AVERROR_EXTERNAL;
2660− }
2798+ if ((err = wait_start_exec_ctx(ctx, &s->cmd)))
2799+ return err;
26612800
26622801 /* Change the image layout to something more optimal for transfers */
26632802 for (int i = 0; i < planes; i++) {
@@ -2691,7 +2830,7 @@ static int transfer_image_buf(AVHWDeviceContext *ctx, AVVkFrame *frame, · 27 unmodified lines
26912830 }
26922831
26932832 if (bar_num)
2694− vkCmdPipelineBarrier(s->cmd.buf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
2833+ vkCmdPipelineBarrier(cmd_buf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
26952834 VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
26962835 0, NULL, 0, NULL, bar_num, img_bar);
26972836
@@ -2715,33 +2854,33 @@ static int transfer_image_buf(AVHWDeviceContext *ctx, AVVkFrame *frame, · 17 unmodified lines
27152854 };
27162855
27172856 if (to_buf)
2718− vkCmdCopyImageToBuffer(s->cmd.buf, frame->img[i], frame->layout[i],
2857+ vkCmdCopyImageToBuffer(cmd_buf, frame->img[i], frame->layout[i],
27192858 vkbuf->buf, 1, &buf_reg);
27202859 else
2721− vkCmdCopyBufferToImage(s->cmd.buf, vkbuf->buf, frame->img[i],
2860+ vkCmdCopyBufferToImage(cmd_buf, vkbuf->buf, frame->img[i],
27222861 frame->layout[i], 1, &buf_reg);
27232862 }
27242863
2725− ret = vkEndCommandBuffer(s->cmd.buf);
2726− if (ret != VK_SUCCESS) {
2727− av_log(ctx, AV_LOG_ERROR, "Unable to finish command buffer: %s\n",
2728− vk_ret2str(ret));
2729− return AVERROR_EXTERNAL;
2730− }
2731−
2732− /* Wait for the download/upload to finish if uploading, otherwise the
2733− * semaphore will take care of synchronization when uploading */
2734− ret = vkQueueSubmit(s->cmd.queue, 1, &s_info, s->cmd.fence);
2735− if (ret != VK_SUCCESS) {
2736− av_log(ctx, AV_LOG_ERROR, "Unable to submit command buffer: %s\n",
2737− vk_ret2str(ret));
2738− return AVERROR_EXTERNAL;
2864+ /* When uploading, do this asynchronously if the source is refcounted by
2865+ * keeping the buffers as a submission dependency.
2866+ * The hwcontext is guaranteed to not be freed until all frames are freed
2867+ * in the frames_unint function.
2868+ * When downloading to buffer, do this synchronously and wait for the
2869+ * queue submission to finish executing */
2870+ if (!to_buf) {
2871+ int ref;
2872+ for (ref = 0; ref < AV_NUM_DATA_POINTERS; ref++) {
2873+ if (!f->buf[ref])
2874+ break;
2875+ if ((err = add_buf_dep_exec_ctx(hwfc, &s->cmd, &f->buf[ref], 1)))
2876+ return err;
2877+ }
2878+ if (ref && (err = add_buf_dep_exec_ctx(hwfc, &s->cmd, bufs, planes)))
2879+ return err;
2880+ return submit_exec_ctx(hwfc, &s->cmd, &s_info, !ref);
27392881 } else {
2740− vkWaitForFences(hwctx->act_dev, 1, &s->cmd.fence, VK_TRUE, UINT64_MAX);
2741− vkResetFences(hwctx->act_dev, 1, &s->cmd.fence);
2882+ return submit_exec_ctx(hwfc, &s->cmd, &s_info, 1);
27422883 }
2743−
2744− return 0;
27452884 }
27462885
27472886 /* Technically we can use VK_EXT_external_memory_host to upload and download,
@@ -2778,11 +2917,11 @@ static int vulkan_transfer_data_from_mem(AVHWFramesContext *hwfc, AVFrame *dst, · 30 unmodified lines
27782917
27792918 err = vulkan_map_frame_to_mem(hwfc, map, dst, AV_HWFRAME_MAP_WRITE);
27802919 if (err)
2781− goto end;
2920+ return err;
27822921
27832922 err = av_frame_copy(map, src);
27842923 av_frame_free(&map);
2785− goto end;
2924+ return err;
27862925 }
27872926
27882927 /* Create buffers */
@@ -2809,7 +2948,7 @@ static int vulkan_transfer_data_from_mem(AVHWFramesContext *hwfc, AVFrame *dst, · 20 unmodified lines
28092948 goto end;
28102949
28112950 /* Copy buffers to image */
2812− err = transfer_image_buf(dev_ctx, f, bufs, tmp.linesize,
2951+ err = transfer_image_buf(dev_ctx, dst, bufs, tmp.linesize,
28132952 src->width, src->height, src->format, 0);
28142953
28152954 end:
@@ -2949,10 +3088,12 @@ static int vulkan_transfer_data_to_mem(AVHWFramesContext *hwfc, AVFrame *dst, · 133 unmodified lines
29493088 err = create_buf(dev_ctx, &bufs[i], p_height,
29503089 &tmp.linesize[i], VK_BUFFER_USAGE_TRANSFER_DST_BIT,
29513090 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, NULL, NULL);
3091+ if (err)
3092+ goto end;
29523093 }
29533094
29543095 /* Copy image to buffer */
2955− if ((err = transfer_image_buf(dev_ctx, f, bufs, tmp.linesize,
3096+ if ((err = transfer_image_buf(dev_ctx, src, bufs, tmp.linesize,
29563097 dst->width, dst->height, dst->format, 1)))
29573098 goto end;
29583099

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t