From patchwork Sat Oct 7 15:04:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 44198 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4e24:b0:15d:8365:d4b8 with SMTP id gk36csp473452pzb; Sat, 7 Oct 2023 08:04:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHi7XIjcPcG346nzhs/5iNWv167Ry0VFz1n9FrQWKOyykN9ir/PM5xrSfp0r88NPyOoxQwG X-Received: by 2002:a17:906:24d:b0:9a5:ca42:f3a9 with SMTP id 13-20020a170906024d00b009a5ca42f3a9mr10954896ejl.2.1696691055704; Sat, 07 Oct 2023 08:04:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696691055; cv=none; d=google.com; s=arc-20160816; b=EvXrfXxr9BGYJZJu4YB/avs5DR0EJM0nNqSs07JnInKAq8hyGQw3SwVu3tDFiFQePR mSDIV2sPM8i39WsaGnotlilENQ/hb4S2OGvSisa96n0hjztNsBrnRa7OmDDlHyY0cHrK g0Tm+ZLuLWCQI/3lE4Cocz7xNztVvXzRbX/66Brnz1DVxKvzBAH/rbGxkInMPbYuvIV5 6ozyv2UbJt72Mf2/y+W8oSj9hQxxfXtcu66aeA1l3+F5lxwE1E4EpEr5Em7RNz9CGlmx yCnDMB6vag04iHm0MC6XzXu5KR3pm0Uy9YT3q25J+QVbg0j6rKaQZX82lC2XhoCzfrPM QBtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:to:from:date :dkim-signature:delivered-to; bh=t07VvuzpXwHU5uBrnwSgmBx7GhBUQMHcn4N+lKIvIIM=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=Y5QIJ2N7mSVzqKc2EgNVM9m+DhtQVDIA0wlTJA9fQ28MHelZkkxkJEmqojMCUKETqy 65ZFQvWFDZq+ri5DsbBstPbVlAwfn0YgtB56mVjEM2fziDfVgKf80BoGzzxEcUQaioD4 xGi4MWl3lsjG/TOxv4djH19lIXXvT5FRsvppHPu2uqB9miKXwDjZTsw1BclFdDKs2CC+ fDQoQyyUoIm5MrizGVsYQ3SGlJmjC9xSUZ89ht/w3QNz7mPSxjalTkBbdeG4YoHYzpX/ zoZGef64LXzYv0OFH81bwLZ3i875FvMAZ8ctvSbEcgxRKkeVfR4DQxPGSxaZufYI3Eij BZHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@lynne.ee header.s=s1 header.b=1JDRNp7H; 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=lynne.ee Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id rs3-20020a170907036300b009b2b30dcf6asi2701410ejb.559.2023.10.07.08.04.14; Sat, 07 Oct 2023 08:04:15 -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; dkim=neutral (body hash did not verify) header.i=@lynne.ee header.s=s1 header.b=1JDRNp7H; 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=lynne.ee Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7E05C68CA67; Sat, 7 Oct 2023 18:04:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5CCB968CA16 for ; Sat, 7 Oct 2023 18:04:05 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 030001060165 for ; Sat, 7 Oct 2023 15:04:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1696691044; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=bJwYmJ+/va+H3xMsAYvCX+BJa3oY2FvZWZlcSWl2AMI=; b=1JDRNp7HZXgxO0wIOIRgoMPC2WxDGdQgMKwi0sG4djDCTsvaSAJNPF5DLaEvgL3Q JnRaPe/AOhcmVBkFV73TMlyteYxG2loDLmZqaEyucnOox9N4TZJhFZwU1oSBJ+w/lhR 52nusRqsnIbVYCxDvGyHTtN0VNw1v8MFyONKK4IaAYEpxWeIxJs93SA8EAuCPVfoqHL auk+915PvSUEtX72NJ1AiKnMYBoE7vCaH/4Woeo8BkQooWHBkjNrTMgaVBuTasBs9t6 kHKvyjk2LH7lHmyhcUA+urPONu8Ny5rO69dt1pVdRKmU4kkySyJn6LyooPz9o7MhQ0N JJFYCW7DgQ== Date: Sat, 7 Oct 2023 17:04:04 +0200 (CEST) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] nlmeans_vulkan: reduce dispatches by parallelizing the planes 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: hsM7lcKllETp Patch attached. From 863a9977192abf00d131d7b0ed88569210fe0d0c Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 16 Sep 2023 01:04:18 +0200 Subject: [PATCH 2/3] nlmeans_vulkan: reduce dispatches by parallelizing the planes --- libavfilter/vf_nlmeans_vulkan.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/libavfilter/vf_nlmeans_vulkan.c b/libavfilter/vf_nlmeans_vulkan.c index 5b623eb7a6..9741dd67ac 100644 --- a/libavfilter/vf_nlmeans_vulkan.c +++ b/libavfilter/vf_nlmeans_vulkan.c @@ -538,28 +538,29 @@ static av_cold int init_denoise_pipeline(FFVulkanContext *vkctx, FFVkExecPool *e GLSLC(0, { ); GLSLC(1, ivec2 size; ); GLSLC(1, const ivec2 pos = ivec2(gl_GlobalInvocationID.xy); ); + GLSLC(1, const uint plane = uint(gl_WorkGroupID.z); ); GLSLC(0, ); GLSLC(1, float w_sum; ); GLSLC(1, float sum; ); GLSLC(1, vec4 src; ); GLSLC(1, vec4 r; ); GLSLC(0, ); - - for (int i = 0; i < planes; i++) { - GLSLF(1, src = texture(input_img[%i], pos); ,i); - for (int c = 0; c < desc->nb_components; c++) { - if (desc->comp[c].plane == i) { - int off = desc->comp[c].offset / (FFALIGN(desc->comp[c].depth, 8)/8); - GLSLF(1, w_sum = weights_%i[pos.y*ws_stride[%i] + pos.x]; ,c, c); - GLSLF(1, sum = sums_%i[pos.y*ws_stride[%i] + pos.x]; ,c, c); - GLSLF(1, r[%i] = (sum + src[%i]*255) / (1.0 + w_sum) / 255; ,off, off); - GLSLC(0, ); - } - } - GLSLF(1, imageStore(output_img[%i], pos, r); ,i); - GLSLC(0, ); + GLSLC(1, size = imageSize(output_img[plane]); ); + GLSLC(1, if (!IS_WITHIN(pos, size)) ); + GLSLC(2, return; ); + GLSLC(0, ); + GLSLC(1, src = texture(input_img[plane], pos); ); + GLSLC(0, ); + for (int c = 0; c < desc->nb_components; c++) { + int off = desc->comp[c].offset / (FFALIGN(desc->comp[c].depth, 8)/8); + GLSLF(1, if (plane == %i) { ,desc->comp[c].plane); + GLSLF(2, w_sum = weights_%i[pos.y*ws_stride[%i] + pos.x]; ,c, c); + GLSLF(2, sum = sums_%i[pos.y*ws_stride[%i] + pos.x]; ,c, c); + GLSLF(2, r[%i] = (sum + src[%i]*255) / (1.0 + w_sum) / 255; ,off, off); + GLSLC(1, } ); + GLSLC(0, ); } - + GLSLC(1, imageStore(output_img[plane], pos, r); ); GLSLC(0, } ); RET(spv->compile_shader(spv, vkctx, shd, &spv_data, &spv_len, "main", &spv_opaque)); @@ -716,7 +717,7 @@ static int denoise_pass(NLMeansVulkanContext *s, FFVkExecContext *exec, vk->CmdDispatch(exec->buf, FFALIGN(vkctx->output_width, s->pl_denoise.wg_size[0])/s->pl_denoise.wg_size[0], FFALIGN(vkctx->output_height, s->pl_denoise.wg_size[1])/s->pl_denoise.wg_size[1], - 1); + av_pix_fmt_count_planes(s->vkctx.output_format)); return 0; } -- 2.42.0