This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit d0ee5d055661cf736fd8488973629e38d3499b1c
Author:     Lynne <[email protected]>
AuthorDate: Tue Feb 10 20:36:28 2026 +0100
Commit:     Lynne <[email protected]>
CommitDate: Tue Apr 21 08:28:50 2026 +0200

    vf_flip_vulkan: convert to compile-time SPIR-V generation
---
 configure                                          |   6 +-
 libavfilter/vf_flip_vulkan.c                       | 103 ++++++---------------
 libavfilter/vulkan/Makefile                        |   1 +
 .../vulkan/{avgblur.comp.glsl => flip.comp.glsl}   |  34 ++++---
 4 files changed, 46 insertions(+), 98 deletions(-)

diff --git a/configure b/configure
index 7d98674092..16bb02b5b9 100755
--- a/configure
+++ b/configure
@@ -4185,7 +4185,7 @@ elbg_filter_deps="avcodec"
 eq_filter_deps="gpl"
 erosion_opencl_filter_deps="opencl"
 find_rect_filter_deps="avcodec avformat gpl"
-flip_vulkan_filter_deps="vulkan spirv_library"
+flip_vulkan_filter_deps="vulkan spirv_compiler"
 flite_filter_deps="libflite threads"
 framerate_filter_select="scene_sad"
 freezedetect_filter_select="scene_sad"
@@ -4195,7 +4195,7 @@ frei0r_src_filter_deps="frei0r"
 fspp_filter_deps="gpl"
 fsync_filter_deps="avformat"
 gblur_vulkan_filter_deps="vulkan spirv_library"
-hflip_vulkan_filter_deps="vulkan spirv_library"
+hflip_vulkan_filter_deps="vulkan spirv_compiler"
 histeq_filter_deps="gpl"
 hqdn3d_filter_deps="gpl"
 iccdetect_filter_deps="lcms2"
@@ -4288,7 +4288,7 @@ unsharp_opencl_filter_deps="opencl"
 uspp_filter_deps="gpl avcodec"
 v360_vulkan_filter_deps="vulkan spirv_compiler"
 vaguedenoiser_filter_deps="gpl"
-vflip_vulkan_filter_deps="vulkan spirv_library"
+vflip_vulkan_filter_deps="vulkan spirv_compiler"
 vidstabdetect_filter_deps="libvidstab"
 vidstabtransform_filter_deps="libvidstab"
 libvmaf_filter_deps="libvmaf"
diff --git a/libavfilter/vf_flip_vulkan.c b/libavfilter/vf_flip_vulkan.c
index 4f38a39950..b86f236d2a 100644
--- a/libavfilter/vf_flip_vulkan.c
+++ b/libavfilter/vf_flip_vulkan.c
@@ -19,14 +19,15 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/random_seed.h"
 #include "libavutil/opt.h"
-#include "libavutil/vulkan_spirv.h"
 #include "vulkan_filter.h"
 
 #include "filters.h"
 #include "video.h"
 
+extern const unsigned char ff_flip_comp_spv_data[];
+extern const unsigned int ff_flip_comp_spv_len;
+
 enum FlipType {
     FLIP_VERTICAL,
     FLIP_HORIZONTAL,
@@ -42,24 +43,13 @@ typedef struct FlipVulkanContext {
     FFVulkanShader shd;
 } FlipVulkanContext;
 
-static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in, enum 
FlipType type)
+static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
 {
     int err = 0;
-    uint8_t *spv_data;
-    size_t spv_len;
-    void *spv_opaque = NULL;
     FlipVulkanContext *s = ctx->priv;
     FFVulkanContext *vkctx = &s->vkctx;
     const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
     FFVulkanShader *shd = &s->shd;
-    FFVkSPIRVCompiler *spv;
-    FFVulkanDescriptorSetBinding *desc;
-
-    spv = ff_vk_spirv_init();
-    if (!spv) {
-        av_log(ctx, AV_LOG_ERROR, "Unable to initialize SPIR-V compiler!\n");
-        return AVERROR_EXTERNAL;
-    }
 
     s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
     if (!s->qf) {
@@ -69,77 +59,36 @@ static av_cold int init_filter(AVFilterContext *ctx, 
AVFrame *in, enum FlipType
     }
 
     RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, 
NULL));
-    RET(ff_vk_shader_init(vkctx, &s->shd, "flip",
-                          VK_SHADER_STAGE_COMPUTE_BIT,
-                          NULL, 0,
-                          32, 32, 1,
-                          0));
-
-    desc = (FFVulkanDescriptorSetBinding []) {
-        {
-            .name       = "input_image",
-            .type       = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
-            .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.input_format, 
FF_VK_REP_FLOAT),
-            .mem_quali  = "readonly",
-            .dimensions = 2,
-            .elems      = planes,
-            .stages     = VK_SHADER_STAGE_COMPUTE_BIT,
+
+    ff_vk_shader_load(&s->shd, VK_SHADER_STAGE_COMPUTE_BIT, NULL,
+                      (uint32_t []) { 32, 8, planes }, 0);
+
+    ff_vk_shader_add_push_const(&s->shd, 0, sizeof(int),
+                                VK_SHADER_STAGE_COMPUTE_BIT);
+
+    const FFVulkanDescriptorSetBinding desc[] = {
+        { /* input_img */
+            .type   = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
+            .stages = VK_SHADER_STAGE_COMPUTE_BIT,
+            .elems  = planes,
         },
-        {
-            .name       = "output_image",
-            .type       = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
-            .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format, 
FF_VK_REP_FLOAT),
-            .mem_quali  = "writeonly",
-            .dimensions = 2,
-            .elems      = planes,
-            .stages     = VK_SHADER_STAGE_COMPUTE_BIT,
+        { /* output_img */
+            .type   = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
+            .stages = VK_SHADER_STAGE_COMPUTE_BIT,
+            .elems  = planes,
         },
     };
+    ff_vk_shader_add_descriptor_set(vkctx, &s->shd, desc, 2, 0, 0);
 
-    RET(ff_vk_shader_add_descriptor_set(vkctx, &s->shd, desc, 2, 0, 0));
-
-    GLSLC(0, void main()                                                       
             );
-    GLSLC(0, {                                                                 
             );
-    GLSLC(1,     ivec2 size;                                                   
             );
-    GLSLC(1,     const ivec2 pos = ivec2(gl_GlobalInvocationID.xy);            
             );
-    for (int i = 0; i < planes; i++) {
-        GLSLC(0,                                                               
             );
-        GLSLF(1, size = imageSize(output_image[%i]);                           
           ,i);
-        GLSLC(1, if (IS_WITHIN(pos, size)) {                                   
             );
-        switch (type)
-        {
-        case FLIP_HORIZONTAL:
-            GLSLF(2, vec4 res = imageLoad(input_image[%i], ivec2(size.x - 
pos.x, pos.y)); ,i);
-            break;
-        case FLIP_VERTICAL:
-            GLSLF(2, vec4 res = imageLoad(input_image[%i], ivec2(pos.x, size.y 
- pos.y)); ,i);
-            break;
-        case FLIP_BOTH:
-            GLSLF(2, vec4 res = imageLoad(input_image[%i], ivec2(size.xy - 
pos.xy));,      i);
-            break;
-        default:
-            GLSLF(2, vec4 res = imageLoad(input_image[%i], pos);               
           ,i);
-            break;
-        }
-        GLSLF(2,     imageStore(output_image[%i], pos, res);                   
           ,i);
-        GLSLC(1, }                                                             
             );
-    }
-    GLSLC(0, }                                                                 
             );
-
-    RET(spv->compile_shader(vkctx, spv, shd, &spv_data, &spv_len, "main",
-                            &spv_opaque));
-    RET(ff_vk_shader_link(vkctx, shd, spv_data, spv_len, "main"));
+    RET(ff_vk_shader_link(vkctx, shd,
+                          ff_flip_comp_spv_data,
+                          ff_flip_comp_spv_len, "main"));
 
     RET(ff_vk_shader_register_exec(vkctx, &s->e, &s->shd));
 
     s->initialized = 1;
 
 fail:
-    if (spv_opaque)
-        spv->free_shader(spv, &spv_opaque);
-    if (spv)
-        spv->uninit(&spv);
-
     return err;
 }
 
@@ -171,10 +120,10 @@ static int filter_frame(AVFilterLink *link, AVFrame *in, 
enum FlipType type)
     }
 
     if (!s->initialized)
-        RET(init_filter(ctx, in, type));
+        RET(init_filter(ctx, in));
 
     RET(ff_vk_filter_process_simple(&s->vkctx, &s->e, &s->shd, out, in,
-                                    VK_NULL_HANDLE, 1, NULL, 0));
+                                    VK_NULL_HANDLE, 1, &type, sizeof(int)));
 
     RET(av_frame_copy_props(out, in));
 
diff --git a/libavfilter/vulkan/Makefile b/libavfilter/vulkan/Makefile
index 2d321b1fb2..595ca4d532 100644
--- a/libavfilter/vulkan/Makefile
+++ b/libavfilter/vulkan/Makefile
@@ -4,6 +4,7 @@ clean::
 OBJS-$(CONFIG_AVGBLUR_VULKAN_FILTER) += vulkan/avgblur.comp.spv.o
 OBJS-$(CONFIG_BWDIF_VULKAN_FILTER) += vulkan/bwdif.comp.spv.o
 OBJS-$(CONFIG_SCALE_VULKAN_FILTER) += vulkan/debayer.comp.spv.o
+OBJS-$(CONFIG_FLIP_VULKAN_FILTER) += vulkan/flip.comp.spv.o
 OBJS-$(CONFIG_V360_VULKAN_FILTER) += vulkan/v360.comp.spv.o
 OBJS-$(CONFIG_INTERLACE_VULKAN_FILTER) += vulkan/interlace.comp.spv.o
 OBJS-$(CONFIG_XFADE_VULKAN_FILTER) += vulkan/xfade.comp.spv.o
diff --git a/libavfilter/vulkan/avgblur.comp.glsl 
b/libavfilter/vulkan/flip.comp.glsl
similarity index 65%
copy from libavfilter/vulkan/avgblur.comp.glsl
copy to libavfilter/vulkan/flip.comp.glsl
index 4cfd4f433d..a0d556ba8c 100644
--- a/libavfilter/vulkan/avgblur.comp.glsl
+++ b/libavfilter/vulkan/flip.comp.glsl
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2021 Wu Jianhua <[email protected]>
  * Copyright (c) 2026 Lynne <[email protected]>
  *
  * This file is part of FFmpeg.
@@ -29,33 +30,30 @@ layout (local_size_x_id = 253, local_size_y_id = 254, 
local_size_z_id = 255) in;
 layout (set = 0, binding = 0) uniform readonly  image2D input_img[];
 layout (set = 0, binding = 1) uniform writeonly image2D output_img[];
 
+#define FLIP_VERTICAL 0
+#define FLIP_HORIZONTAL 1
+#define FLIP_BOTH 2
+
 layout (push_constant, scalar) uniform pushConstants {
-    vec4 filter_norm;
-    ivec2 filter_len;
-    uint planes;
+    int flip;
 };
 
 void main()
 {
-    const ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
-
-    ivec2 size = imageSize(output_img[nonuniformEXT(gl_LocalInvocationID.z)]);
+    ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
+    ivec2 size = imageSize(input_img[nonuniformEXT(gl_LocalInvocationID.z)]);
     if (any(greaterThanEqual(pos, size)))
         return;
 
-    if ((planes & (1 << gl_LocalInvocationID.z)) == 0) {
-        imageStore(output_img[gl_LocalInvocationID.z], pos,
-                   imageLoad(input_img[nonuniformEXT(gl_LocalInvocationID.z)],
-                             pos));
-        return;
+    ivec2 dst;
+    switch (flip) {
+    case FLIP_HORIZONTAL: dst = ivec2(size.x - pos.x, pos.y); break;
+    case FLIP_VERTICAL:   dst = ivec2(pos.x, size.y - pos.y); break;
+    case FLIP_BOTH:       dst = ivec2(size.xy - pos.xy);      break;
+    default:              dst = pos;                          break;
     }
 
-    vec4 sum = vec4(0);
-    for (int y = -filter_len.y; y <= filter_len.y; y++)
-        for (int x = -filter_len.x; x <= filter_len.x; x++)
-            sum += imageLoad(input_img[nonuniformEXT(gl_LocalInvocationID.z)],
-                             pos + ivec2(x, y));
+    vec4 res = imageLoad(input_img[nonuniformEXT(gl_LocalInvocationID.z)], 
pos);
 
-    imageStore(output_img[nonuniformEXT(gl_LocalInvocationID.z)],
-               pos, sum * filter_norm);
+    imageStore(output_img[nonuniformEXT(gl_LocalInvocationID.z)], dst, res);
 }

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to