diff mbox series

[FFmpeg-devel,08/10] libavutil/hwcontext_vulkan: fix wrong offset of plane

Message ID 20210831014338.134086-8-wenbin.chen@intel.com
State New
Headers show
Series [FFmpeg-devel,01/10] libavfilter/vulkan: Fix problem when device have queue_count greater than 1 | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Wenbin Chen Aug. 31, 2021, 1:43 a.m. UTC
From: "Chen,Wenbin" <wenbin.chen@intel.com>

According to spec, if we use VkBindImagePlaneMemoryInfo to bind image
we mush create image with disjoint flag.
The offset in subresourcelayout is relative to the base address of
the plane, but the offset in drm is relative to the drm objectis so
I think this offset should be 0.
Also, when I import vaapi frame to vulkan I got broken frame, and
setting plane_data->offset to 0 makes command works.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 libavutil/hwcontext_vulkan.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 4983518a77..3a639c997b 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -2382,7 +2382,9 @@  static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
             .extent.depth          = 1,
             .mipLevels             = 1,
             .arrayLayers           = 1,
-            .flags                 = VK_IMAGE_CREATE_ALIAS_BIT,
+            .flags                 = VK_IMAGE_CREATE_ALIAS_BIT |
+                                     (has_modifiers && planes > 1) ? VK_IMAGE_CREATE_DISJOINT_BIT :
+                                     0,
             .tiling                = f->tiling,
             .initialLayout         = VK_IMAGE_LAYOUT_UNDEFINED, /* specs say so */
             .usage                 = frames_hwctx->usage,
@@ -2397,7 +2399,7 @@  static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
                      hwfc->sw_format, src->width, src->height, i);
 
         for (int j = 0; j < planes; j++) {
-            plane_data[j].offset     = desc->layers[i].planes[j].offset;
+            plane_data[j].offset     = 0;
             plane_data[j].rowPitch   = desc->layers[i].planes[j].pitch;
             plane_data[j].size       = 0; /* The specs say so for all 3 */
             plane_data[j].arrayPitch = 0;