From patchwork Tue Nov 9 09:18:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenbin Chen X-Patchwork-Id: 31336 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp886151iob; Tue, 9 Nov 2021 01:23:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBbPkL2JFfBXZ7oDqFRhfyrft3WVhYQ7ZlpXbzOqGITL+WbKcRTG5nrYFKObodpKYTSN7y X-Received: by 2002:a17:907:6287:: with SMTP id nd7mr7537280ejc.152.1636449833371; Tue, 09 Nov 2021 01:23:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636449833; cv=none; d=google.com; s=arc-20160816; b=RhvMl1WP92cnn7QGCgwG8ksGTI+DJLbC3FCpDgUldZtE6lgiVm3XiOYbWUigOYtIdv uUp5+jNGX6Yx+a0lx5qab84ZtWERsmR6YumiFcdOVZpDBFSm7YC0xskEqeLkRA8zBM+C 0R+aSztlAYLP9GtimQJewJJ4d1iBqb/B+B6O/2HRHf5UNdHCXbMz7G5u6fjmXcBijwtw oIiaBP8BzN6ga92qMI/hUK8e3iG11VE/ZNnJe14eV6u8bDuV+f620eYKORtrEobMpqZ4 g6EITI7JK2MLDTOlD09NFLf/nTIfX2lZmgVweLiA3KkNH3COTLcExTQ1KtYPZWBDn5Eb lpXw== 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=cJEqR1JaQePbeVamxzv71AjlzQ+8c9WVN17f/W4pP1s=; b=uS8pjIne1D38ST1J3tujRVbM1PnmxK7BDTMOXrCDK6A85yyqYqoDf3yfRXe8oziVlc cKhsASL+hkCDXe1SWO3Cf52SQ2O2ae6nU4hBrfCJWmFW2v9lQC07ncarID5GEHnFIOp0 wbN0Q1fmlORFMBzWuQ59CdAoqECZPYDKM5JTgw1aTV3A/MlPomK6a7+dFzDDrmQ+fjo2 OqS3NhiZHBV8TpzaOjWKf2Pg8GSJR6uCfPcQlLvKCiY45va1gqwUX32E4KFO1qTuMp5r 8PLmcUogKRFLtNA+qJwhxpsKNM+4fZ+w1nQDbWvv7TPgLmusU2SlirCC2k9KprsS315X MlEg== 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 29si27104927ejf.281.2021.11.09.01.23.53; Tue, 09 Nov 2021 01:23:53 -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 C735568AC06; Tue, 9 Nov 2021 11:23:03 +0200 (EET) 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 759D968AA35 for ; Tue, 9 Nov 2021 11:22:54 +0200 (EET) X-IronPort-AV: E=McAfee;i="6200,9189,10162"; a="231131828" X-IronPort-AV: E=Sophos;i="5.87,219,1631602800"; d="scan'208";a="231131828" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2021 01:22:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,219,1631602800"; d="scan'208";a="491593956" Received: from chenwenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.110]) by orsmga007.jf.intel.com with ESMTP; 09 Nov 2021 01:22:49 -0800 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Tue, 9 Nov 2021 17:18:41 +0800 Message-Id: <20211109091843.2024927-5-wenbin.chen@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211109091843.2024927-1-wenbin.chen@intel.com> References: <20211109091843.2024927-1-wenbin.chen@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/7] 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: slG+JgGJUB9Y 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 f7878ed9c3..b857d1a9ed 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -2138,7 +2138,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); @@ -2167,7 +2167,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) { @@ -2178,6 +2179,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)) &&