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 625D64E1EC for ; Mon, 10 Mar 2025 03:10:16 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1251D68E7FE; Mon, 10 Mar 2025 05:08:55 +0200 (EET) Received: from vidala.pars.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 966B468E774 for ; Mon, 10 Mar 2025 05:08:40 +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=1741576120; bh=6plga3w1Phe64uqWvmUkdRr Ln5BKeHuOCVPA9+mTzug=; b=NcPpWDW73eUvkQbqh/+OD1KFK9/taH6AyXvOfORQP6dYXZ2CQq HJoysJvHk5Em5pkJJHYgL3gKQ+XSXxRA1IjidjLfACrAhM0H99vqk0rcs4EinGH51OPxSLAX0lH 64gZuN54KasOPHLTOeHj9636QLJJsHKJjOddzABN9cl6o/axOzdnEoF75RK5bBEudk67zE4dDNa qTb2X+9FoW4pitSVG1o8MdO9ZWI2CCoeVhzSdnxVcS9w9KYPH9v8XLHg7Kl3QdHjktEoN4U7qfo 0Qrcjoh3Zc2i2ji05gJXuV/hsHQbPfp6hz34naLn4BLcDyoRpP+50m7a7IlMy19jbCA==; DKIM-Signature: v=1; a=ed25519-sha256; s=202405e; d=lynne.ee; c=relaxed/relaxed; h=Message-ID:Date:Subject:To:From; t=1741576120; bh=6plga3w1Phe64uqWvmUkdRr Ln5BKeHuOCVPA9+mTzug=; b=gexQqj9D10xc83VzOdtBM2YIc2XRQqmLUAeFZQevSwjOVcND23 Mn4tDgpt+/TNaYPaI85dQTqK9sXOcF220dBw==; From: Lynne To: ffmpeg-devel@ffmpeg.org Date: Mon, 10 Mar 2025 04:08:26 +0100 Message-ID: <20250310030837.60814-7-dev@lynne.ee> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250310030837.60814-1-dev@lynne.ee> References: <20250310030837.60814-1-dev@lynne.ee> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/13] vulkan_decode: adjust number of async contexts created 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: This caps the number of contexts we create based on thread count. This saves VRAM and filters out cases where more async is of lesser benefit. --- libavcodec/vulkan_decode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c index 7f638d6fc6..cd77e10e12 100644 --- a/libavcodec/vulkan_decode.c +++ b/libavcodec/vulkan_decode.c @@ -1122,6 +1122,7 @@ int ff_vk_decode_init(AVCodecContext *avctx) FFVulkanDecodeShared *ctx; FFVulkanContext *s; FFVulkanFunctions *vk; + int async_depth; const VkVideoProfileInfoKHR *profile; const FFVulkanDecodeDescriptor *vk_desc; const VkPhysicalDeviceDriverProperties *driver_props; @@ -1191,9 +1192,14 @@ int ff_vk_decode_init(AVCodecContext *avctx) /* Create decode exec context for this specific main thread. * 2 async contexts per thread was experimentally determined to be optimal * for a majority of streams. */ + async_depth = 2*ctx->qf->num; + /* We don't need more than 2 per thread context */ + async_depth = FFMIN(async_depth, 2*avctx->thread_count); + /* Make sure there are enough async contexts for each thread */ + async_depth = FFMAX(async_depth, avctx->thread_count); + err = ff_vk_exec_pool_init(s, ctx->qf, &ctx->exec_pool, - FFMAX(2*ctx->qf->num, avctx->thread_count), - 0, 0, 0, profile); + async_depth, 0, 0, 0, profile); if (err < 0) goto fail; -- 2.47.2 _______________________________________________ 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".