From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 3BB0145CB8 for ; Sun, 19 Jan 2025 10:37:00 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 73B7168B47F; Sun, 19 Jan 2025 12:36:56 +0200 (EET) Received: from vidala.pars.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EBB5968B132 for ; Sun, 19 Jan 2025 12:36:49 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; s=202405r; d=lynne.ee; c=relaxed/relaxed; h=Message-ID:Date:Subject:To:From; t=1737283008; bh=xFxcqc0YzA+EMIjwB/HXNy8 wvQOfu+93RdGot71s/f8=; b=TOR8rsXFh8tCYll73SIUWMVgyvV+Y4ofdtpN9/eB94RoEuzlSl gN+n1OuBWolfCl+u/pkakUC72qWXUlTTlsuMSxHjtBDc4izhoMXJTeOEVOwEDrE8BSh7V5wTiND QGnXjlEQ/ICiigfO/oYFqftqqvsEYWC+yOo0qZ/nx00FxqCa/rST7e6LWIIk+2ay9oeRvihKZTq dMuWk4iEcFF1PNJ73bPvrz61ppsRfyMqZhTtZNWLywSHVy6WFqHVT5LSU80G/vWobuz12zk6jUQ yDOwt4UuIAhEE2Xp+5AucNJvnnXy3cpugsG+21JOSONZZhTK7Rr/geUnS2hH3W3U5wg==; DKIM-Signature: v=1; a=ed25519-sha256; s=202405e; d=lynne.ee; c=relaxed/relaxed; h=Message-ID:Date:Subject:To:From; t=1737283008; bh=xFxcqc0YzA+EMIjwB/HXNy8 wvQOfu+93RdGot71s/f8=; b=9PYN63nX+c3V2w6T1+TmLUsik8GA6GNx419Lu1jWQvZER0s+kZ bDTkXVmio5ktNmP91JRFkFhhw0j3S1taYGCQ==; From: Lynne To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 Jan 2025 19:36:19 +0900 Message-ID: <20250119103640.1224690-1-dev@lynne.ee> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/12] vulkan: add ff_vk_create_imageview 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: Lynne Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --- libavutil/vulkan.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++ libavutil/vulkan.h | 7 +++++++ 2 files changed, 58 insertions(+) diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index 7315af928f..c86b77c3ee 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -1586,6 +1586,57 @@ static VkFormat map_fmt_to_rep(VkFormat fmt, enum FFVkShaderRepFormat rep_fmt) return VK_FORMAT_UNDEFINED; } +int ff_vk_create_imageview(FFVulkanContext *s, + VkImageView *img_view, VkImageAspectFlags *aspect, + AVFrame *f, int plane, enum FFVkShaderRepFormat rep_fmt) +{ + VkResult ret; + FFVulkanFunctions *vk = &s->vkfn; + AVHWFramesContext *hwfc = (AVHWFramesContext *)f->hw_frames_ctx->data; + AVVulkanFramesContext *vkfc = hwfc->hwctx; + const VkFormat *rep_fmts = av_vkfmt_from_pixfmt(hwfc->sw_format); + AVVkFrame *vkf = (AVVkFrame *)f->data[0]; + const int nb_images = ff_vk_count_images(vkf); + + VkImageViewUsageCreateInfo view_usage_info = { + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO, + .usage = vkfc->usage & + (~(VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | + VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR)), + }; + VkImageViewCreateInfo view_create_info = { + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, + .pNext = &view_usage_info, + .image = vkf->img[FFMIN(plane, nb_images - 1)], + .viewType = VK_IMAGE_VIEW_TYPE_2D, + .format = map_fmt_to_rep(rep_fmts[plane], rep_fmt), + .components = ff_comp_identity_map, + .subresourceRange = { + .aspectMask = ff_vk_aspect_flag(f, plane), + .levelCount = 1, + .layerCount = 1, + }, + }; + if (view_create_info.format == VK_FORMAT_UNDEFINED) { + av_log(s, AV_LOG_ERROR, "Unable to find a compatible representation " + "of format %i and mode %i\n", + rep_fmts[plane], rep_fmt); + return AVERROR(EINVAL); + } + + ret = vk->CreateImageView(s->hwctx->act_dev, &view_create_info, + s->hwctx->alloc, img_view); + if (ret != VK_SUCCESS) { + av_log(s, AV_LOG_ERROR, "Failed to create imageview: %s\n", + ff_vk_ret2str(ret)); + return AVERROR_EXTERNAL; + } + + *aspect = view_create_info.subresourceRange.aspectMask; + + return 0; +} + int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, VkImageView views[AV_NUM_DATA_POINTERS], AVFrame *f, enum FFVkShaderRepFormat rep_fmt) diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h index 41f71df376..4bc5b57a1b 100644 --- a/libavutil/vulkan.h +++ b/libavutil/vulkan.h @@ -456,6 +456,13 @@ int ff_vk_exec_mirror_sem_value(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f); void ff_vk_exec_discard_deps(FFVulkanContext *s, FFVkExecContext *e); +/** + * Create a single imageview for a given plane. + */ +int ff_vk_create_imageview(FFVulkanContext *s, + VkImageView *img_view, VkImageAspectFlags *aspect, + AVFrame *f, int plane, enum FFVkShaderRepFormat rep_fmt); + /** * Create an imageview and add it as a dependency to an execution. */ -- 2.47.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".