From: Lynne <dev@lynne.ee> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH 2/3] nlmeans_vulkan: reduce dispatches by parallelizing the planes Date: Sat, 7 Oct 2023 17:04:04 +0200 (CEST) Message-ID: <Ng9eg6t--7-9@lynne.ee> (raw) In-Reply-To: <Ng9eVFH--3-9@lynne.ee-Ng9eZVQ----9> [-- Attachment #1: Type: text/plain, Size: 17 bytes --] Patch attached. [-- Attachment #2: 0002-nlmeans_vulkan-reduce-dispatches-by-parallelizing-th.patch --] [-- Type: text/x-diff, Size: 4331 bytes --] From 863a9977192abf00d131d7b0ed88569210fe0d0c Mon Sep 17 00:00:00 2001 From: Lynne <dev@lynne.ee> 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 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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".
next prev parent reply other threads:[~2023-10-07 15:04 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-10-07 15:03 [FFmpeg-devel] [PATCH 1/3] nlmeans_vulkan: fix width/height for chroma plane weights calculation Lynne [not found] ` <Ng9eVFH--3-9@lynne.ee-Ng9eZVQ----9> 2023-10-07 15:04 ` Lynne [this message] 2023-10-07 15:07 ` [FFmpeg-devel] [PATCH 3/3] nlmeans_vulkan: parallelize workgroup invocations Lynne [not found] ` <Ng9fYdg--3-9@lynne.ee-Ng9faxr----9> 2023-10-11 3:34 ` Lynne
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=Ng9eg6t--7-9@lynne.ee \ --to=dev@lynne.ee \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git