[FFmpeg-cvslog] hwcontext_vulkan: minor corrections for DMABUF mapping

Lynne git at videolan.org
Thu Mar 12 21:04:09 EET 2020


ffmpeg | branch: master | Lynne <dev at lynne.ee> | Thu Mar 12 16:46:01 2020 +0000| [08d0a8992d75bbcffe9e7f3392cc94a7f84fc9df] | committer: Lynne

hwcontext_vulkan: minor corrections for DMABUF mapping

We need to consider the amount of layers instead of the image's planes.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=08d0a8992d75bbcffe9e7f3392cc94a7f84fc9df
---

 libavutil/hwcontext_vulkan.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 0fe88e6b9f..8ed0e6edfa 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1643,7 +1643,6 @@ static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
     AVHWDeviceContext *ctx = hwfc->device_ctx;
     AVVulkanDeviceContext *hwctx = ctx->hwctx;
     VulkanDevicePriv *p = ctx->internal->priv;
-    const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
     const AVPixFmtDescriptor *fmt_desc = av_pix_fmt_desc_get(hwfc->sw_format);
     const int has_modifiers = p->extensions & EXT_DRM_MODIFIER_FLAGS;
     VkSubresourceLayout plane_data[AV_NUM_DATA_POINTERS];
@@ -1696,7 +1695,8 @@ static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 
         req.memoryTypeBits = fdmp.memoryTypeBits;
 
-        err = alloc_mem(ctx, &req, 0x0, &idesc, &f->flags, &f->mem[i]);
+        err = alloc_mem(ctx, &req, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
+                        &idesc, &f->flags, &f->mem[i]);
         if (err)
             return err;
 
@@ -1789,7 +1789,7 @@ static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
     }
 
     /* Bind the allocated memory to the images */
-    ret = vkBindImageMemory2(hwctx->act_dev, planes, bind_info);
+    ret = vkBindImageMemory2(hwctx->act_dev, desc->nb_layers, bind_info);
     if (ret != VK_SUCCESS) {
         av_log(ctx, AV_LOG_ERROR, "Failed to bind memory: %s\n",
                vk_ret2str(ret));
@@ -1801,11 +1801,12 @@ static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
     return 0;
 
 fail:
-    for (int i = 0; i < planes; i++) {
+    for (int i = 0; i < desc->nb_layers; i++) {
         vkDestroyImage(hwctx->act_dev, f->img[i], hwctx->alloc);
-        vkFreeMemory(hwctx->act_dev, f->mem[i], hwctx->alloc);
         vkDestroySemaphore(hwctx->act_dev, f->sem[i], hwctx->alloc);
     }
+    for (int i = 0; i < desc->nb_objects; i++)
+        vkFreeMemory(hwctx->act_dev, f->mem[i], hwctx->alloc);
 
     av_free(f);
 



More information about the ffmpeg-cvslog mailing list