From patchwork Tue Dec 7 09:05:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenbin Chen X-Patchwork-Id: 32100 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5976874iog; Tue, 7 Dec 2021 01:10:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3lAs1WfU71NhGKbeVUlPfs0IRv3ckayxePYrlsG9lsxm3J9J1RNICOMFWk989XIOSDBM4 X-Received: by 2002:a17:906:fcc8:: with SMTP id qx8mr51275227ejb.370.1638868244051; Tue, 07 Dec 2021 01:10:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638868244; cv=none; d=google.com; s=arc-20160816; b=umTntCFRd1eydoDSJN82pU60F/i+1wzWBRdPL67FGXqU9dp0EOgcocKKIT6HkwXflb IJtCEtahYB8vV6b291IUF9IPEOOJc56O7MKScpIlfNLIciYCHOLni2uvAhPjXuO7tf/W nRiTiN2mSZWfXRiw68Q7KTUPGgYf+L/Sxc/zSKnDVmJrQNE1rolfL/vti0QTDaaavuvZ GNJSW0XXq6mBubjTi9/ZAbteUnu8bc5PFRu4eKjtrDILYFuXVO8Uof4e1VRi5sUuiA0T 4nXJ5AaaZLyCU0vnct7hRcIoru+gmry3ImteP4AmjfFOXu9ad8EagFA5TcmYMWpupSWb 457Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=stBrkhpINOmB/+B92/eZM2ix2cpztV/CtQ+mvHSHkKs=; b=OFuqoyqoBWfoOrhTHwKuY+Y4wfOh71p+0SfdzN3hoHnBnfljGWl1bu0nbZRRiGAeIx kZupWaXknLOvQdas1hastxZltqEMT8oMW5r97F1r9ogfEGBuuGpWdUlch/53a/Six8VG fwBRMU3HZNKIY8LBSn+ftMvOkZoJYJpCABnanPrPYD5QIgi23Z3pL+zZYbx3o7wsu6Vd azhwMCi6KmqtMk6y9HNPRvXxvVcd9oIl3xY5XwGa5KQ89pt2E/rov+GK/uwFjbgk8dRm 7Ddks5YZJt3Mi58bOcuityPv9MzbvZv7DcgduAuyrDp684hmcSfvLOEsXMuWNr7Ku2Gv ykfA== 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 hp34si30922386ejc.640.2021.12.07.01.10.43; Tue, 07 Dec 2021 01:10:44 -0800 (PST) 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 85B4668AE57; Tue, 7 Dec 2021 11:10:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C776568ADF2 for ; Tue, 7 Dec 2021 11:10:08 +0200 (EET) X-IronPort-AV: E=McAfee;i="6200,9189,10190"; a="224794096" X-IronPort-AV: E=Sophos;i="5.87,293,1631602800"; d="scan'208";a="224794096" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2021 01:10:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,293,1631602800"; d="scan'208";a="515198472" Received: from chenwenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.110]) by orsmga008.jf.intel.com with ESMTP; 07 Dec 2021 01:10:01 -0800 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Tue, 7 Dec 2021 17:05:52 +0800 Message-Id: <20211207090553.2138848-4-wenbin.chen@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207090553.2138848-1-wenbin.chen@intel.com> References: <20211207090553.2138848-1-wenbin.chen@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH V6 4/5] libavutil/hwcontext_vulkan: Add support to hwmap to software frame when using contiguous_planes flag. 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: G3zcjKfQIeva Add support to map vulkan frames to software frames when using contiguous_planes flag. Signed-off-by: Wenbin Chen --- libavutil/hwcontext_vulkan.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index eef9009ae1..f980b72720 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -2327,9 +2327,10 @@ static int vulkan_map_frame_to_mem(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags) { VkResult ret; - int err, mapped_mem_count = 0; + int err, mapped_mem_count = 0, loop = 0; AVVkFrame *f = (AVVkFrame *)src->data[0]; AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx; + AVVulkanFramesContext *hwfctx = hwfc->hwctx; const int planes = av_pix_fmt_count_planes(hwfc->sw_format); VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; FFVulkanFunctions *vk = &p->vkfn; @@ -2356,7 +2357,9 @@ static int vulkan_map_frame_to_mem(AVHWFramesContext *hwfc, AVFrame *dst, dst->width = src->width; dst->height = src->height; - for (int i = 0; i < planes; i++) { + loop = VKF_FLAG(hwfctx->flags, AV_VK_FRAME_FLAG_CONTIGUOUS_MEMORY) ? + 1 : planes; + for (int i = 0; i < loop; i++) { ret = vk->MapMemory(hwctx->act_dev, f->mem[i], 0, VK_WHOLE_SIZE, 0, (void **)&dst->data[i]); if (ret != VK_SUCCESS) { @@ -2367,6 +2370,10 @@ static int vulkan_map_frame_to_mem(AVHWFramesContext *hwfc, AVFrame *dst, } mapped_mem_count++; } + if (VKF_FLAG(hwfctx->flags, AV_VK_FRAME_FLAG_CONTIGUOUS_MEMORY)) { + for (int i = 0; i < planes; i++) + dst->data[i] = dst->data[0] + f->offset[i]; + } /* Check if the memory contents matter */ if (((flags & AV_HWFRAME_MAP_READ) || !(flags & AV_HWFRAME_MAP_OVERWRITE)) &&