From patchwork Fri Nov 26 02:54:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenbin Chen X-Patchwork-Id: 31741 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp1660408iob; Thu, 25 Nov 2021 18:59:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvpo5ep1F8hNhO0OvWAnVwn3OLYJVSeCyaI2Rz9oJG0dwLYVpJZPVJzisl07abI8CwVxfX X-Received: by 2002:a17:906:2bd5:: with SMTP id n21mr36263186ejg.337.1637895566697; Thu, 25 Nov 2021 18:59:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637895566; cv=none; d=google.com; s=arc-20160816; b=R9+sSqWSwlJtIrV7U4ron60DqwMmjzPmFK+CxY3niHv+wCaDLrCP+zUgW5Tx3S8E0Q etBLp+4xWQbRsn+dke6MOcHdjr6LPj44WOaiq+lZJ52AORCRsSn7HrcaKzmLLRVospxk wYWa+0UeK6UAp7rh8mzEXkXWHgELFjkUVJ8g+oEUHOsIuw4ecrrSGnpGQ6S5jKyg1IIx gVdRWRCoG7j9LS9Cnimclwd8ECDOEeDWTQBs7iHj8Y1D4eHxD1SognFOJHt3O18IdZA9 ICWJcviNOVEDzPum9VxZfy0Y/mD2a65csB5gujaZaWHPjAwJOGwNmy38WbRD/FIKW55X mlmQ== 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=pJigNaReTa9yQAIMsdwdwDCD1VK0e7x0JWbDs/HEDTw=; b=iZkIUuqsLefee6lPzBsM7Hq7MtKsVpBo6gWh1vZq+milt+YHy2S8eNI1IkDRI8SgKV DMnqMXhrYJv841ID6qniXr0bNpmLzC5XFlVsdFmvHKD7sxtIzWFHxGEB61bRa8YIEEQI fF5xPxRvtDkIkUmOML2Z3uNjvPYhbQgosA5a56qXoHe8WocZMayHMQVCdUqiO4qSmJtf rmfx5Yf9XAD6OIT2gI32g7jQBbDpheD2CXN1z6Y1sDIDEyYPB18tKy5u06vGi4vfyQKR skC/asen4s2YTQDatf/x1oIafIL8LxlXpoI5Kxfos4QgCr7fIyaXmnAtdZKaHjknaQew Ya0Q== 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 y8si13191621edd.474.2021.11.25.18.59.26; Thu, 25 Nov 2021 18:59:26 -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 07F5068AE47; Fri, 26 Nov 2021 04:58:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 439EB689AE3 for ; Fri, 26 Nov 2021 04:58:50 +0200 (EET) X-IronPort-AV: E=McAfee;i="6200,9189,10179"; a="233090575" X-IronPort-AV: E=Sophos;i="5.87,263,1631602800"; d="scan'208";a="233090575" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2021 18:58:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,263,1631602800"; d="scan'208";a="458030802" Received: from chenwenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.110]) by orsmga006.jf.intel.com with ESMTP; 25 Nov 2021 18:58:43 -0800 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 Nov 2021 10:54:42 +0800 Message-Id: <20211126025443.22499-4-wenbin.chen@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211126025443.22499-1-wenbin.chen@intel.com> References: <20211126025443.22499-1-wenbin.chen@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH V3 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: L05sY+Zk7I1F 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 b8076fb425..0648e59243 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -2221,9 +2221,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; @@ -2250,7 +2251,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) { @@ -2261,6 +2264,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)) &&