From patchwork Tue Aug 31 07:24:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenbin Chen X-Patchwork-Id: 29895 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp4686054iov; Tue, 31 Aug 2021 00:28:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyl0Eqe+16/0e+za9Eo80vAWbSYqzl2eHr70QEMgG/y5i3G5xE0CmnN9GntuiJTVaJEeGik X-Received: by 2002:a17:906:2bc2:: with SMTP id n2mr29072475ejg.455.1630394908610; Tue, 31 Aug 2021 00:28:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630394908; cv=none; d=google.com; s=arc-20160816; b=IxCyzDApn7qCCUKSLuCv2ssKyu361h/94rP2mjYz7euF8/pNHEjOqw+sjosG5ZZWi4 5IZAV7ES+D6xPxVgK24HZb+ywAsXnf4kug/kUxlPU1l1bKZaZVUByeuL0EDPkwlWVEKm Ao6SrryjImvOghVlka93oX3I4pQQsooiCaQHCC2rqAcjw5C14bHqr6jmFQxL0oQvAdQ7 FoOJEREVJbXPuhZ1FEzD4A3zvWiHFXF1+8NgvnyxgV+x9goBY9SHSyClWHTPOKr365Oi dzqPUADedBqaPRHzKA5LRKNB0S7CULMzEHtWLtFJW/DY8ZNLcpb6tuCV4plnmeyNpizu Wevg== 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=tWDNRD994RG+N+QFv8oiVU3udzISD5V7CTXnHlSP0XY=; b=U2EMqE+93FhTpqqadd3z9giqVIDn/obbJNp6B+5V5k4JXxeyOzFsoavAqcGuAV2nIb qmENUHcBhGKfpnb8k9PmM8a5kUqZV2hxkul97gk3Jbbq/BrJqJYCDeyvOi2LKRIstNzj L60PhsoL7CAWNs0U1SV6HwrvnH0YSy78ifUUJvb3i4V12SeLb8EwIH3DjdQxV4zHbTw/ riVIxu8hDYvihlP527musT/8qQ2seWBjCayEk/dVy+hRl0LWI3sf5ICStgRzA45lJadI jhgAecZene01LvFPTjVgrbyouKIaCsFpCFUqV+au1HJJD+ZuJSnCtiEwSSRJ272EVUYR T3qg== 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 l7si10707559edb.409.2021.08.31.00.28.28; Tue, 31 Aug 2021 00:28:28 -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 482BF68A4C2; Tue, 31 Aug 2021 10:27:42 +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 299FC68A408 for ; Tue, 31 Aug 2021 10:27:36 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10092"; a="279429290" X-IronPort-AV: E=Sophos;i="5.84,365,1620716400"; d="scan'208";a="279429290" 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:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,365,1620716400"; d="scan'208";a="540905267" 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:33 -0700 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Tue, 31 Aug 2021 15:24:30 +0800 Message-Id: <20210831072430.303090-10-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 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: Wenbin Chen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: vK2M+FEHmLdE 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)) &&