From patchwork Tue Aug 31 01:43:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenbin Chen X-Patchwork-Id: 29881 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp4497754iov; Mon, 30 Aug 2021 18:47:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXUmx3cUsUcaHCjOSCvf8v922vnBHBeY+EQtZ6IazWksepINZ/AV/3HZh/CpSWxmNYUZe4 X-Received: by 2002:a17:906:404:: with SMTP id d4mr27984880eja.449.1630374422602; Mon, 30 Aug 2021 18:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630374422; cv=none; d=google.com; s=arc-20160816; b=vvUoryQvF8KLwitCkWKvGWvGPqqwkGbKAxefPbt8IiFdo3xN+q0b0sX2K9/7wgE3B6 hlmG/RgPAuV5nJM8TR3SKhouwzTeGUpVK3jWArP+s14fttnNCKkdU8prqsp2YC5q7Nvv yrCrPllb7TJ7+dcAncCsfQvoFOxLH/FkZb+pCFnZMY+sCPkiSCo4A2oRI7/TahV3Qpjf 7sCpS3BDIaGxCJ9Dh6DpwEWrcKZoKOKVK3SBip4sOUUkWFXRFoKX+YkKAg7TmFrZaK5f a+fP0Ree8ieOYYe+XbT9ORr01Qsu2o0LiS1uDPK5wDjIgSSHUIc38jjIwtIr6yxO2W1d ws1g== 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=3GPF92gy1WxzmZKaIJLiJOa/zUEuBkZEFzfW+QMhcWU=; b=rnwCzR9sac2nmCo4uAfrJOJjq/9Koov+CFhumMzeR301YeQWD4funzVlMDI87AhwSu uxRs39mRp/hPRscfL2XGvxBbYuq/jp5LBUFDmTeaZozHefij5EzJgaA+kb0VkFCZKZWJ At05V5qyWbHPDYgMI4YDdgqYnRptZrgITg2w/r+OPknJ4HZQdf4NE19ce0aGCKxtrre8 2vSpevCzjaSw+0KZu5+5Qeh9rEFKX+1JfGzhiFSw3Mdw/t6yYeV6GZ0uS7XnKalASf45 U65d6l+3Pi37geveinBF2wBd3XtcCWisirEQb6t6whc+/g3+Hy4k4n8ezxaBS8JZjgG0 Q02Q== 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 j17si16731030edr.153.2021.08.30.18.47.02; Mon, 30 Aug 2021 18:47:02 -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 C765B68A4A4; Tue, 31 Aug 2021 04:46:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5695568A407 for ; Tue, 31 Aug 2021 04:46:04 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10092"; a="216531744" X-IronPort-AV: E=Sophos;i="5.84,365,1620716400"; d="scan'208";a="216531744" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2021 18:45:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,365,1620716400"; d="scan'208";a="530827088" Received: from chenwenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.5]) by FMSMGA003.fm.intel.com with ESMTP; 30 Aug 2021 18:45:53 -0700 From: wenbin.chen@intel.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 31 Aug 2021 09:43:36 +0800 Message-Id: <20210831014338.134086-8-wenbin.chen@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210831014338.134086-1-wenbin.chen@intel.com> References: <20210831014338.134086-1-wenbin.chen@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: "Chen,Wenbin" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: AGS56ihs/gKk From: "Chen,Wenbin" 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;