From patchwork Tue Aug 31 01:43:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenbin Chen X-Patchwork-Id: 29884 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp4497993iov; Mon, 30 Aug 2021 18:47:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzN/uV1B4EcWKhoOouEee+EkwPfilBMAkgTsC5ztXrpQAeQ8CNBzdbqy5fvs5KEtTA4hy79 X-Received: by 2002:a05:6402:350d:: with SMTP id b13mr17225555edd.1.1630374451707; Mon, 30 Aug 2021 18:47:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630374451; cv=none; d=google.com; s=arc-20160816; b=jcnO1sE/uZRoxvvLD6ndJyZ0PNlTzsA3DshyoSm0y0KUfahxYyNPJCxFK3/c20VpuO 6GAWp4tzQHD48BQ7+YPsX3fKC7EEvjuWSCfbbZKV/pC6FkGxOdSdGSKHbbnKDa1tZm15 1TwRazluv40V+/yPaVZ5x8O7LdXMYeEj1TObtFZmrf4HqSvqmsd9PBAFteZZ1LJZoNQF wWc3LACObq0mbmppJTO6/0FUWwKCv401C0ltpLr45WkVYqK4kwz43svOvdqc161U7QNS zzsGrXKXEWVTRbY23pvnBxI/NqXXTMoprEI6gnCvl6z0wwVBfDNqlRu4+xNJtKa60Awv t8Vw== 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=PqePHfBzHIvmz76N5pnkIVk/N0cU6FZE2I60parq5YU=; b=ThrOLEqN6pAY3zULQlTg8ze0YcRK17E1TDOYsFv1Ci8W1ZnXNIVtnHEGKcisqD41Oq hro9jrJ747+HMECDIBcEcFf0b09BGlbMGVVLPDYmceEwp9cy1eyhUqpBgmw25Sp+kcVU PezU3ZErkuxe5hbznr/7pOWRB/zCvZ7ROK5HBbwstv10RXnKuXSli7M7gb5++ign964V CQZa8R5f530gjkvqMsublySIA1eQrYBfEhazzhImFcrD2RZKiyfBY6xjbXecowwc2qLz dVn0aVrjzXEBmp1XF1em+1ued28ijTuvF0/WAOMj7sbzJ2GRdQpLl2HmK/M800d1P2ss QR4Q== 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 i18si21613586edc.336.2021.08.30.18.47.31; Mon, 30 Aug 2021 18:47:31 -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 5A6A568A498; Tue, 31 Aug 2021 04:46:10 +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 3FB5D68A42A for ; Tue, 31 Aug 2021 04:46:05 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10092"; a="216531747" X-IronPort-AV: E=Sophos;i="5.84,365,1620716400"; d="scan'208";a="216531747" 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:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,365,1620716400"; d="scan'208";a="530827108" 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:56 -0700 From: wenbin.chen@intel.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 31 Aug 2021 09:43:38 +0800 Message-Id: <20210831014338.134086-10-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 10/10] libavutil/hwcontext_vulkan: Add hwupload and hwdownload support when using one_memory 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 Cc: "Chen,Wenbin" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: mcfsXbojl5Kl From: "Chen,Wenbin" Add hwupload and hwdownload support to vulkan when frames are allocated in one memory Signed-off-by: Wenbin Chen --- libavutil/hwcontext_vulkan.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 99b2190dc3..5dfa7adc6b 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -2252,7 +2252,7 @@ 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; const int planes = av_pix_fmt_count_planes(hwfc->sw_format); @@ -2281,7 +2281,8 @@ 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 = p->use_one_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) { @@ -2292,6 +2293,11 @@ static int vulkan_map_frame_to_mem(AVHWFramesContext *hwfc, AVFrame *dst, } mapped_mem_count++; } + if (p->use_one_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)) &&