From patchwork Tue Aug 31 07:24:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenbin Chen X-Patchwork-Id: 29899 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp4686134iov; Tue, 31 Aug 2021 00:28:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJww1+hKKQfioUwyFqQDxCQOa/tNhQX1Ez3WsghM/08jPXXsonnGVuxNftfm6S1V3X18WowI X-Received: by 2002:a17:907:1184:: with SMTP id uz4mr28363217ejb.363.1630394918017; Tue, 31 Aug 2021 00:28:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630394918; cv=none; d=google.com; s=arc-20160816; b=n2iN08VJfkTLR1NJJj0h5TSrmySpzr09GdSfRmqhBR9b7h4AF/fyDvXBG9rv1tZRm9 J2lh/Ip/Kifhs3YIDZO1Ral4eoI/QetnSHSS0C1UBvku9OmFg9aR7Qno15OAIGismDFE v4NPkWYjbuvrE3Lvjyg+tohKc7QL+qstygDwWvMuELUGZUDXbr4Ay1ilxH7iGO9vaWPk Ux8V/4Y1D1xkKDCDNnuAIU7fJztLow2O8jydKrsMK8a/+fRbxx4OcrAOYlsgiC3zpGGL C6tf6SsIKcrzEuAv1qcTVCTwzn/X8bouagfJ+rzdITiJ5camJ2+txUc+I0Z7t60DLJVg COpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=4f7js9w3HHnryEJrUc9dx/RMZPRbfWnVVhtAIcrC+kY=; b=C7aKUHlcxKWxQdhkkl2E/qqI+xhbyjYUsKRNvJqxriCPqFjfer1miIUTPK2N4W6wwT B5T0yxHSTj1rwA2iRSmI3lbBRkXav1HqNlKqTMQXyDWA2ryb7tAseAtR3bzuYTDTaUiP KSnCzl2YlmO0jaNoQ8CXyWYOV3eoPQQq9FAwR1ZA7w8g+gIU7S4iMPNZxFmIVibgDlPg iD9Eivazz4a853CuO1WmyBTx6o21GdVXMKF1mdVkJtpmtQw1bC35uVZwV4o/VpxxuiOf 2ku/xNFPihXUzBvIXovCxPdBrCi9sgIYtDvOoeOzOZ/tpGAaA11xLAlJxpd3zNv5gjvd q7fg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 10si16932369ejw.91.2021.08.31.00.28.37; Tue, 31 Aug 2021 00:28:38 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4A08168A4D2; Tue, 31 Aug 2021 10:27:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7800A68A43A for ; Tue, 31 Aug 2021 10:27:33 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10092"; a="279429282" X-IronPort-AV: E=Sophos;i="5.84,365,1620716400"; d="scan'208";a="279429282" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2021 00:27:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,365,1620716400"; d="scan'208";a="540905242" Received: from chenwenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.5]) by fmsmga002.fm.intel.com with ESMTP; 31 Aug 2021 00:27:29 -0700 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Tue, 31 Aug 2021 15:24:28 +0800 Message-Id: <20210831072430.303090-8-wenbin.chen@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210831072430.303090-1-wenbin.chen@intel.com> References: <20210831072430.303090-1-wenbin.chen@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [V2 08/10] libavutil/hwcontext_vulkan: fix wrong offset of plane X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Wenbin Chen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: FrhzHv2HbDoa 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 --- libavutil/hwcontext_vulkan.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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;