Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 01/11] vulkan_filter: use GENERAL image layout when no sampler is given
@ 2025-02-17 18:31 Lynne
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 02/11] bwdif_vulkan: convert to storage images Lynne
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Lynne @ 2025-02-17 18:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne

This allows using the generic filter code with STORAGE image inputs.
---
 libavfilter/vulkan_filter.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/libavfilter/vulkan_filter.c b/libavfilter/vulkan_filter.c
index bdbebb3cb2..ecb24711f3 100644
--- a/libavfilter/vulkan_filter.c
+++ b/libavfilter/vulkan_filter.c
@@ -249,6 +249,8 @@ int ff_vk_filter_process_simple(FFVulkanContext *vkctx, FFVkExecPool *e,
     VkImageView out_views[AV_NUM_DATA_POINTERS];
     VkImageMemoryBarrier2 img_bar[37];
     int nb_img_bar = 0;
+    VkImageLayout in_layout = sampler ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL :
+                                        VK_IMAGE_LAYOUT_GENERAL;
 
     /* Update descriptors and init the exec context */
     FFVkExecContext *exec = ff_vk_exec_get(vkctx, e);
@@ -267,8 +269,8 @@ int ff_vk_filter_process_simple(FFVulkanContext *vkctx, FFVkExecPool *e,
                                      VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
         RET(ff_vk_create_imageviews(vkctx, exec, in_views,  in_f, FF_VK_REP_FLOAT));
         ff_vk_shader_update_img_array(vkctx, exec, shd,  in_f,  in_views, 0, 0,
-                                          VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
-                                          sampler);
+                                      in_layout,
+                                      sampler);
     }
 
     /* Bind pipeline, update push data */
@@ -289,7 +291,7 @@ int ff_vk_filter_process_simple(FFVulkanContext *vkctx, FFVkExecPool *e,
                             VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
                             VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
                             VK_ACCESS_SHADER_READ_BIT,
-                            VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
+                            in_layout,
                             VK_QUEUE_FAMILY_IGNORED);
 
     vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
@@ -321,6 +323,8 @@ int ff_vk_filter_process_2pass(FFVulkanContext *vkctx, FFVkExecPool *e,
     VkImageView out_views[AV_NUM_DATA_POINTERS];
     VkImageMemoryBarrier2 img_bar[37];
     int nb_img_bar = 0;
+    VkImageLayout in_layout = sampler ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL :
+                                        VK_IMAGE_LAYOUT_GENERAL;
 
     /* Update descriptors and init the exec context */
     FFVkExecContext *exec = ff_vk_exec_get(vkctx, e);
@@ -344,7 +348,7 @@ int ff_vk_filter_process_2pass(FFVulkanContext *vkctx, FFVkExecPool *e,
                         VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
                         VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
                         VK_ACCESS_SHADER_READ_BIT,
-                        VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
+                        in_layout,
                         VK_QUEUE_FAMILY_IGNORED);
     ff_vk_frame_barrier(vkctx, exec, tmp, img_bar, &nb_img_bar,
                         VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
@@ -373,7 +377,7 @@ int ff_vk_filter_process_2pass(FFVulkanContext *vkctx, FFVkExecPool *e,
         VkImageView *dst_views = !i ? tmp_views : out_views;
 
         ff_vk_shader_update_img_array(vkctx, exec, shd, src_f, src_views, 0, 0,
-                                      !i ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL :
+                                      !i ? in_layout :
                                            VK_IMAGE_LAYOUT_GENERAL,
                                       sampler);
         ff_vk_shader_update_img_array(vkctx, exec, shd, dst_f, dst_views, 0, 1,
@@ -409,6 +413,9 @@ int ff_vk_filter_process_Nin(FFVulkanContext *vkctx, FFVkExecPool *e,
     VkImageView out_views[AV_NUM_DATA_POINTERS];
     VkImageMemoryBarrier2 img_bar[128];
     int nb_img_bar = 0;
+    VkImageLayout in_layout = sampler != VK_NULL_HANDLE ?
+                              VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL :
+                              VK_IMAGE_LAYOUT_GENERAL;
 
     /* Update descriptors and init the exec context */
     FFVkExecContext *exec = ff_vk_exec_get(vkctx, e);
@@ -432,7 +439,7 @@ int ff_vk_filter_process_Nin(FFVulkanContext *vkctx, FFVkExecPool *e,
                                   VK_NULL_HANDLE);
     for (int i = 0; i < nb_in; i++)
         ff_vk_shader_update_img_array(vkctx, exec, shd, in[i], in_views[i], 0, i,
-                                      VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
+                                      in_layout,
                                       sampler);
 
     /* Bind pipeline, update push data */
@@ -453,7 +460,7 @@ int ff_vk_filter_process_Nin(FFVulkanContext *vkctx, FFVkExecPool *e,
                             VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
                             VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
                             VK_ACCESS_SHADER_READ_BIT,
-                            VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
+                            in_layout,
                             VK_QUEUE_FAMILY_IGNORED);
 
     vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
-- 
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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [FFmpeg-devel] [PATCH 02/11] bwdif_vulkan: convert to storage images
  2025-02-17 18:31 [FFmpeg-devel] [PATCH 01/11] vulkan_filter: use GENERAL image layout when no sampler is given Lynne
@ 2025-02-17 18:31 ` Lynne
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 03/11] nlmeans_vulkan: switch to imageLoad() Lynne
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Lynne @ 2025-02-17 18:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne

texture() uses bilinear scaling; imageLoad() accesses the image directly.
The reason why texture() was used throughout Vulkan filters is that
back when they were written, they were targetting old Intel hardware,
which had a texel cache only for sampled images.

These days, GPUs have a generic cache that doesn't care what source it
gets populated with. Additionally, bypassing the sampling circuitry saves
us some performance.

Finally, all the old texture() code had an issue where unnormalized
coordinates were used, but an offset of 0.5 was not added, hence each
pixel ended up being interpolated. This fixes this.
---
 libavfilter/vf_bwdif_vulkan.c | 26 ++++++--------
 libavfilter/vulkan/bwdif.comp | 68 +++++++++++++++++------------------
 2 files changed, 45 insertions(+), 49 deletions(-)

diff --git a/libavfilter/vf_bwdif_vulkan.c b/libavfilter/vf_bwdif_vulkan.c
index 0afe8ac0ed..549e814886 100644
--- a/libavfilter/vf_bwdif_vulkan.c
+++ b/libavfilter/vf_bwdif_vulkan.c
@@ -34,7 +34,6 @@ typedef struct BWDIFVulkanContext {
     int initialized;
     FFVkExecPool e;
     AVVulkanDeviceQueueFamily *qf;
-    VkSampler sampler;
     FFVulkanShader shd;
 } BWDIFVulkanContext;
 
@@ -73,7 +72,6 @@ static av_cold int init_filter(AVFilterContext *ctx)
     }
 
     RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
-    RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
 
     RET(ff_vk_shader_init(vkctx, &s->shd, "bwdif",
                           VK_SHADER_STAGE_COMPUTE_BIT,
@@ -85,27 +83,30 @@ static av_cold int init_filter(AVFilterContext *ctx)
     desc = (FFVulkanDescriptorSetBinding []) {
         {
             .name       = "prev",
-            .type       = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+            .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,
-            .samplers   = DUP_SAMPLER(s->sampler),
         },
         {
             .name       = "cur",
-            .type       = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+            .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,
-            .samplers   = DUP_SAMPLER(s->sampler),
         },
         {
             .name       = "next",
-            .type       = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+            .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,
-            .samplers   = DUP_SAMPLER(s->sampler),
         },
         {
             .name       = "dst",
@@ -166,7 +167,7 @@ static av_cold int init_filter(AVFilterContext *ctx)
             GLSLC(2, if (!IS_WITHIN(pos, size))                                    );
             GLSLC(3,     return;                                                   );
         }
-        GLSLF(2,     imageStore(dst[%i], pos, texture(cur[%i], pos));              ,i, i);
+        GLSLF(2,     imageStore(dst[%i], pos, imageLoad(cur[%i], pos));            ,i, i);
     }
     GLSLC(1,     }                                                                 );
     GLSLC(0, }                                                                     );
@@ -201,7 +202,7 @@ static void bwdif_vulkan_filter_frame(AVFilterContext *ctx, AVFrame *dst,
 
     ff_vk_filter_process_Nin(&s->vkctx, &s->e, &s->shd, dst,
                              (AVFrame *[]){ y->prev, y->cur, y->next }, 3,
-                             s->sampler, &params, sizeof(params));
+                             VK_NULL_HANDLE, &params, sizeof(params));
 
     if (y->current_field == YADIF_FIELD_END)
         y->current_field = YADIF_FIELD_NORMAL;
@@ -211,15 +212,10 @@ static void bwdif_vulkan_uninit(AVFilterContext *avctx)
 {
     BWDIFVulkanContext *s = avctx->priv;
     FFVulkanContext *vkctx = &s->vkctx;
-    FFVulkanFunctions *vk = &vkctx->vkfn;
 
     ff_vk_exec_pool_free(vkctx, &s->e);
     ff_vk_shader_free(vkctx, &s->shd);
 
-    if (s->sampler)
-        vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
-                           vkctx->hwctx->alloc);
-
     ff_vk_uninit(&s->vkctx);
 
     ff_yadif_uninit(avctx);
diff --git a/libavfilter/vulkan/bwdif.comp b/libavfilter/vulkan/bwdif.comp
index aec58c656b..5c988f472e 100644
--- a/libavfilter/vulkan/bwdif.comp
+++ b/libavfilter/vulkan/bwdif.comp
@@ -30,10 +30,10 @@ vec4 process_intra(vec4 cur[4])
 void process_plane_intra(int idx, ivec2 pos)
 {
     vec4 dcur[4];
-    dcur[0] = texture(cur[idx], pos - ivec2(0, 3));
-    dcur[1] = texture(cur[idx], pos - ivec2(0, 1));
-    dcur[2] = texture(cur[idx], pos + ivec2(0, 1));
-    dcur[3] = texture(cur[idx], pos + ivec2(0, 3));
+    dcur[0] = imageLoad(cur[idx], pos - ivec2(0, 3));
+    dcur[1] = imageLoad(cur[idx], pos - ivec2(0, 1));
+    dcur[2] = imageLoad(cur[idx], pos + ivec2(0, 1));
+    dcur[3] = imageLoad(cur[idx], pos + ivec2(0, 3));
     imageStore(dst[idx], pos, process_intra(dcur));
 }
 
@@ -81,41 +81,41 @@ void process_plane(int idx, const ivec2 pos, bool filter_field,
     vec4 prev2[5];
     vec4 next2[5];
 
-    dcur[0] = texture(cur[idx], pos - ivec2(0, 3));
-    dcur[1] = texture(cur[idx], pos - ivec2(0, 1));
-    dcur[2] = texture(cur[idx], pos + ivec2(0, 1));
-    dcur[3] = texture(cur[idx], pos + ivec2(0, 3));
+    dcur[0] = imageLoad(cur[idx], pos - ivec2(0, 3));
+    dcur[1] = imageLoad(cur[idx], pos - ivec2(0, 1));
+    dcur[2] = imageLoad(cur[idx], pos + ivec2(0, 1));
+    dcur[3] = imageLoad(cur[idx], pos + ivec2(0, 3));
 
-    prev1[0] = texture(prev[idx], pos - ivec2(0, 1));
-    prev1[1] = texture(prev[idx], pos + ivec2(0, 1));
+    prev1[0] = imageLoad(prev[idx], pos - ivec2(0, 1));
+    prev1[1] = imageLoad(prev[idx], pos + ivec2(0, 1));
 
-    next1[0] = texture(next[idx], pos - ivec2(0, 1));
-    next1[1] = texture(next[idx], pos + ivec2(0, 1));
+    next1[0] = imageLoad(next[idx], pos - ivec2(0, 1));
+    next1[1] = imageLoad(next[idx], pos + ivec2(0, 1));
 
     if (field_parity) {
-        prev2[0] = texture(prev[idx], pos - ivec2(0, 4));
-        prev2[1] = texture(prev[idx], pos - ivec2(0, 2));
-        prev2[2] = texture(prev[idx], pos);
-        prev2[3] = texture(prev[idx], pos + ivec2(0, 2));
-        prev2[4] = texture(prev[idx], pos + ivec2(0, 4));
-
-        next2[0] = texture(cur[idx], pos - ivec2(0, 4));
-        next2[1] = texture(cur[idx], pos - ivec2(0, 2));
-        next2[2] = texture(cur[idx], pos);
-        next2[3] = texture(cur[idx], pos + ivec2(0, 2));
-        next2[4] = texture(cur[idx], pos + ivec2(0, 4));
+        prev2[0] = imageLoad(prev[idx], pos - ivec2(0, 4));
+        prev2[1] = imageLoad(prev[idx], pos - ivec2(0, 2));
+        prev2[2] = imageLoad(prev[idx], pos);
+        prev2[3] = imageLoad(prev[idx], pos + ivec2(0, 2));
+        prev2[4] = imageLoad(prev[idx], pos + ivec2(0, 4));
+
+        next2[0] = imageLoad(cur[idx], pos - ivec2(0, 4));
+        next2[1] = imageLoad(cur[idx], pos - ivec2(0, 2));
+        next2[2] = imageLoad(cur[idx], pos);
+        next2[3] = imageLoad(cur[idx], pos + ivec2(0, 2));
+        next2[4] = imageLoad(cur[idx], pos + ivec2(0, 4));
     } else {
-        prev2[0] = texture(cur[idx], pos - ivec2(0, 4));
-        prev2[1] = texture(cur[idx], pos - ivec2(0, 2));
-        prev2[2] = texture(cur[idx], pos);
-        prev2[3] = texture(cur[idx], pos + ivec2(0, 2));
-        prev2[4] = texture(cur[idx], pos + ivec2(0, 4));
-
-        next2[0] = texture(next[idx], pos - ivec2(0, 4));
-        next2[1] = texture(next[idx], pos - ivec2(0, 2));
-        next2[2] = texture(next[idx], pos);
-        next2[3] = texture(next[idx], pos + ivec2(0, 2));
-        next2[4] = texture(next[idx], pos + ivec2(0, 4));
+        prev2[0] = imageLoad(cur[idx], pos - ivec2(0, 4));
+        prev2[1] = imageLoad(cur[idx], pos - ivec2(0, 2));
+        prev2[2] = imageLoad(cur[idx], pos);
+        prev2[3] = imageLoad(cur[idx], pos + ivec2(0, 2));
+        prev2[4] = imageLoad(cur[idx], pos + ivec2(0, 4));
+
+        next2[0] = imageLoad(next[idx], pos - ivec2(0, 4));
+        next2[1] = imageLoad(next[idx], pos - ivec2(0, 2));
+        next2[2] = imageLoad(next[idx], pos);
+        next2[3] = imageLoad(next[idx], pos + ivec2(0, 2));
+        next2[4] = imageLoad(next[idx], pos + ivec2(0, 4));
     }
 
     imageStore(dst[idx], pos, process_line(prev2, prev1, dcur, next1, next2));
-- 
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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [FFmpeg-devel] [PATCH 03/11] nlmeans_vulkan: switch to imageLoad()
  2025-02-17 18:31 [FFmpeg-devel] [PATCH 01/11] vulkan_filter: use GENERAL image layout when no sampler is given Lynne
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 02/11] bwdif_vulkan: convert to storage images Lynne
@ 2025-02-17 18:31 ` Lynne
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 04/11] avgblur_vulkan: port " Lynne
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Lynne @ 2025-02-17 18:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne

---
 libavfilter/vf_nlmeans_vulkan.c | 56 ++++++++++++++-------------------
 1 file changed, 24 insertions(+), 32 deletions(-)

diff --git a/libavfilter/vf_nlmeans_vulkan.c b/libavfilter/vf_nlmeans_vulkan.c
index 67360dc745..22a2a73eae 100644
--- a/libavfilter/vf_nlmeans_vulkan.c
+++ b/libavfilter/vf_nlmeans_vulkan.c
@@ -37,7 +37,6 @@ typedef struct NLMeansVulkanContext {
     int initialized;
     FFVkExecPool e;
     AVVulkanDeviceQueueFamily *qf;
-    VkSampler sampler;
 
     AVBufferPool *integral_buf_pool;
     AVBufferPool *ws_buf_pool;
@@ -66,16 +65,16 @@ typedef struct NLMeansVulkanContext {
 
 static void insert_first(FFVulkanShader *shd, int r, const char *off, int horiz, int plane, int comp)
 {
-    GLSLF(4, s1    = texture(input_img[%i], pos + ivec2(%i + %s, %i + %s))[%i];
+    GLSLF(4, s1    = imageLoad(input_img[%i], pos + ivec2(%i + %s, %i + %s))[%i];
           ,plane, horiz ? r : 0, horiz ? off : "0", !horiz ? r : 0, !horiz ? off : "0", comp);
 
-    GLSLF(4, s2[0] = texture(input_img[%i], pos + offs[0] + ivec2(%i + %s, %i + %s))[%i];
+    GLSLF(4, s2[0] = imageLoad(input_img[%i], pos + offs[0] + ivec2(%i + %s, %i + %s))[%i];
           ,plane, horiz ? r : 0, horiz ? off : "0", !horiz ? r : 0, !horiz ? off : "0", comp);
-    GLSLF(4, s2[1] = texture(input_img[%i], pos + offs[1] + ivec2(%i + %s, %i + %s))[%i];
+    GLSLF(4, s2[1] = imageLoad(input_img[%i], pos + offs[1] + ivec2(%i + %s, %i + %s))[%i];
           ,plane, horiz ? r : 0, horiz ? off : "0", !horiz ? r : 0, !horiz ? off : "0", comp);
-    GLSLF(4, s2[2] = texture(input_img[%i], pos + offs[2] + ivec2(%i + %s, %i + %s))[%i];
+    GLSLF(4, s2[2] = imageLoad(input_img[%i], pos + offs[2] + ivec2(%i + %s, %i + %s))[%i];
           ,plane, horiz ? r : 0, horiz ? off : "0", !horiz ? r : 0, !horiz ? off : "0", comp);
-    GLSLF(4, s2[3] = texture(input_img[%i], pos + offs[3] + ivec2(%i + %s, %i + %s))[%i];
+    GLSLF(4, s2[3] = imageLoad(input_img[%i], pos + offs[3] + ivec2(%i + %s, %i + %s))[%i];
           ,plane, horiz ? r : 0, horiz ? off : "0", !horiz ? r : 0, !horiz ? off : "0", comp);
 
     GLSLC(4, s2 = (s1 - s2) * (s1 - s2);                                                    );
@@ -164,10 +163,10 @@ static void insert_weights_pass(FFVulkanShader *shd, int nb_rows, int vert,
     GLSLC(0,                                                                  );
     GLSLC(3,         lt = ((pos.x - p) < 0) || ((pos.y - p) < 0);             );
     GLSLC(0,                                                                  );
-    GLSLF(3,         src[0] = texture(input_img[%i], pos + offs[0])[%i];      ,plane, comp);
-    GLSLF(3,         src[1] = texture(input_img[%i], pos + offs[1])[%i];      ,plane, comp);
-    GLSLF(3,         src[2] = texture(input_img[%i], pos + offs[2])[%i];      ,plane, comp);
-    GLSLF(3,         src[3] = texture(input_img[%i], pos + offs[3])[%i];      ,plane, comp);
+    GLSLF(3,         src[0] = imageLoad(input_img[%i], pos + offs[0])[%i];    ,plane, comp);
+    GLSLF(3,         src[1] = imageLoad(input_img[%i], pos + offs[1])[%i];    ,plane, comp);
+    GLSLF(3,         src[2] = imageLoad(input_img[%i], pos + offs[2])[%i];    ,plane, comp);
+    GLSLF(3,         src[3] = imageLoad(input_img[%i], pos + offs[3])[%i];    ,plane, comp);
     GLSLC(0,                                                                  );
     GLSLC(3,         if (lt == false) {                                       );
     GLSLC(3,             offset = int_stride * uint64_t(pos.y - p);           );
@@ -210,7 +209,7 @@ typedef struct HorizontalPushData {
 
 static av_cold int init_weights_pipeline(FFVulkanContext *vkctx, FFVkExecPool *exec,
                                          FFVulkanShader *shd,
-                                         VkSampler sampler, FFVkSPIRVCompiler *spv,
+                                         FFVkSPIRVCompiler *spv,
                                          int width, int height, int t,
                                          const AVPixFmtDescriptor *desc,
                                          int planes, int *nb_rows)
@@ -275,11 +274,12 @@ static av_cold int init_weights_pipeline(FFVulkanContext *vkctx, FFVkExecPool *e
     desc_set = (FFVulkanDescriptorSetBinding []) {
         {
             .name       = "input_img",
-            .type       = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+            .type       = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
+            .mem_layout = ff_vk_shader_rep_fmt(vkctx->input_format, FF_VK_REP_FLOAT),
+            .mem_quali  = "readonly",
             .dimensions = 2,
             .elems      = planes,
             .stages     = VK_SHADER_STAGE_COMPUTE_BIT,
-            .samplers   = DUP_SAMPLER(sampler),
         },
         {
             .name        = "weights_buffer_0",
@@ -418,8 +418,7 @@ typedef struct DenoisePushData {
 } DenoisePushData;
 
 static av_cold int init_denoise_pipeline(FFVulkanContext *vkctx, FFVkExecPool *exec,
-                                         FFVulkanShader *shd,
-                                         VkSampler sampler, FFVkSPIRVCompiler *spv,
+                                         FFVulkanShader *shd, FFVkSPIRVCompiler *spv,
                                          const AVPixFmtDescriptor *desc, int planes)
 {
     int err;
@@ -445,11 +444,12 @@ static av_cold int init_denoise_pipeline(FFVulkanContext *vkctx, FFVkExecPool *e
     desc_set = (FFVulkanDescriptorSetBinding []) {
         {
             .name        = "input_img",
-            .type        = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+            .type        = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
+            .mem_layout  = ff_vk_shader_rep_fmt(vkctx->input_format, FF_VK_REP_FLOAT),
+            .mem_quali   = "readonly",
             .dimensions  = 2,
             .elems       = planes,
             .stages      = VK_SHADER_STAGE_COMPUTE_BIT,
-            .samplers    = DUP_SAMPLER(sampler),
         },
         {
             .name        = "output_img",
@@ -539,7 +539,7 @@ static av_cold int init_denoise_pipeline(FFVulkanContext *vkctx, FFVkExecPool *e
     GLSLC(1,     if (!IS_WITHIN(pos, size))                                   );
     GLSLC(2,         return;                                                  );
     GLSLC(0,                                                                  );
-    GLSLC(1,     src = texture(input_img[plane], pos);                        );
+    GLSLC(1,     src = imageLoad(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);
@@ -660,13 +660,12 @@ static av_cold int init_filter(AVFilterContext *ctx)
     }
 
     RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, 1, 0, 0, 0, NULL));
-    RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
 
-    RET(init_weights_pipeline(vkctx, &s->e, &s->shd_weights, s->sampler,
+    RET(init_weights_pipeline(vkctx, &s->e, &s->shd_weights,
                               spv, s->vkctx.output_width, s->vkctx.output_height,
                               s->opts.t, desc, planes, &s->pl_weights_rows));
 
-    RET(init_denoise_pipeline(vkctx, &s->e, &s->shd_denoise, s->sampler,
+    RET(init_denoise_pipeline(vkctx, &s->e, &s->shd_denoise,
                               spv, desc, planes));
 
     RET(ff_vk_shader_update_desc_buffer(vkctx, &s->e.contexts[0], &s->shd_weights,
@@ -865,7 +864,7 @@ static int nlmeans_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
                         VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
                         VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
                         VK_ACCESS_SHADER_READ_BIT,
-                        VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
+                        VK_IMAGE_LAYOUT_GENERAL,
                         VK_QUEUE_FAMILY_IGNORED);
 
     /* Output frame prep */
@@ -944,8 +943,7 @@ static int nlmeans_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
 
     /* Update weights descriptors */
     ff_vk_shader_update_img_array(vkctx, exec, &s->shd_weights, in, in_views, 0, 0,
-                                  VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
-                                  s->sampler);
+                                  VK_IMAGE_LAYOUT_GENERAL, VK_NULL_HANDLE);
     for (int i = 0; i < desc->nb_components; i++) {
         RET(ff_vk_shader_update_desc_buffer(&s->vkctx, exec, &s->shd_weights, 0, 1 + i*2 + 0, 0,
                                             ws_vk, weights_offs[i], ws_size[i],
@@ -957,10 +955,9 @@ static int nlmeans_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
 
     /* Update denoise descriptors */
     ff_vk_shader_update_img_array(vkctx, exec, &s->shd_denoise, in, in_views, 0, 0,
-                                  VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
-                                  s->sampler);
+                                  VK_IMAGE_LAYOUT_GENERAL, VK_NULL_HANDLE);
     ff_vk_shader_update_img_array(vkctx, exec, &s->shd_denoise, out, out_views, 0, 1,
-                                  VK_IMAGE_LAYOUT_GENERAL, s->sampler);
+                                  VK_IMAGE_LAYOUT_GENERAL, VK_NULL_HANDLE);
     for (int i = 0; i < desc->nb_components; i++) {
         RET(ff_vk_shader_update_desc_buffer(&s->vkctx, exec, &s->shd_denoise, 1, i*2 + 0, 0,
                                             ws_vk, weights_offs[i], ws_size[i],
@@ -1052,7 +1049,6 @@ static void nlmeans_vulkan_uninit(AVFilterContext *avctx)
 {
     NLMeansVulkanContext *s = avctx->priv;
     FFVulkanContext *vkctx = &s->vkctx;
-    FFVulkanFunctions *vk = &vkctx->vkfn;
 
     ff_vk_exec_pool_free(vkctx, &s->e);
     ff_vk_shader_free(vkctx, &s->shd_weights);
@@ -1061,10 +1057,6 @@ static void nlmeans_vulkan_uninit(AVFilterContext *avctx)
     av_buffer_pool_uninit(&s->integral_buf_pool);
     av_buffer_pool_uninit(&s->ws_buf_pool);
 
-    if (s->sampler)
-        vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
-                           vkctx->hwctx->alloc);
-
     ff_vk_uninit(&s->vkctx);
 
     av_freep(&s->xoffsets);
-- 
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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [FFmpeg-devel] [PATCH 04/11] avgblur_vulkan: port to imageLoad()
  2025-02-17 18:31 [FFmpeg-devel] [PATCH 01/11] vulkan_filter: use GENERAL image layout when no sampler is given Lynne
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 02/11] bwdif_vulkan: convert to storage images Lynne
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 03/11] nlmeans_vulkan: switch to imageLoad() Lynne
@ 2025-02-17 18:31 ` Lynne
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 05/11] chromaber_vulkan: fix use of texture() Lynne
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Lynne @ 2025-02-17 18:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne

---
 libavfilter/vf_avgblur_vulkan.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/libavfilter/vf_avgblur_vulkan.c b/libavfilter/vf_avgblur_vulkan.c
index e291d5d8e9..5a7012531b 100644
--- a/libavfilter/vf_avgblur_vulkan.c
+++ b/libavfilter/vf_avgblur_vulkan.c
@@ -32,7 +32,6 @@ typedef struct AvgBlurVulkanContext {
     int initialized;
     FFVkExecPool e;
     AVVulkanDeviceQueueFamily *qf;
-    VkSampler sampler;
     FFVulkanShader shd;
 
     /* Push constants / options */
@@ -52,7 +51,7 @@ static const char blur_kernel[] = {
     C(1,     vec4 sum = vec4(0);                                              )
     C(1,     for (int y = -filter_len.y; y <= filter_len.y; y++)              )
     C(1,        for (int x = -filter_len.x; x <= filter_len.x; x++)           )
-    C(2,            sum += texture(input_img[idx], pos + ivec2(x, y));        )
+    C(2,            sum += imageLoad(input_img[idx], pos + ivec2(x, y));      )
     C(0,                                                                      )
     C(1,     imageStore(output_img[idx], pos, sum * filter_norm);             )
     C(0, }                                                                    )
@@ -85,7 +84,6 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
     }
 
     RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
-    RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR));
     RET(ff_vk_shader_init(vkctx, &s->shd, "avgblur",
                           VK_SHADER_STAGE_COMPUTE_BIT,
                           NULL, 0,
@@ -96,11 +94,12 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
     desc = (FFVulkanDescriptorSetBinding []) {
         {
             .name       = "input_img",
-            .type       = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+            .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,
-            .samplers   = DUP_SAMPLER(s->sampler),
         },
         {
             .name       = "output_img",
@@ -137,7 +136,7 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
         if (s->planes & (1 << i)) {
             GLSLF(1, distort(pos, %i);                                  ,i);
         } else {
-            GLSLF(1, vec4 res = texture(input_img[%i], pos);            ,i);
+            GLSLF(1, vec4 res = imageLoad(input_img[%i], pos);          ,i);
             GLSLF(1, imageStore(output_img[%i], pos, res);              ,i);
         }
     }
@@ -186,7 +185,8 @@ static int avgblur_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
         RET(init_filter(ctx, in));
 
     RET(ff_vk_filter_process_simple(&s->vkctx, &s->e, &s->shd,
-                                    out, in, s->sampler, &s->opts, sizeof(s->opts)));
+                                    out, in, VK_NULL_HANDLE,
+                                    &s->opts, sizeof(s->opts)));
 
     err = av_frame_copy_props(out, in);
     if (err < 0)
@@ -206,15 +206,10 @@ static void avgblur_vulkan_uninit(AVFilterContext *avctx)
 {
     AvgBlurVulkanContext *s = avctx->priv;
     FFVulkanContext *vkctx = &s->vkctx;
-    FFVulkanFunctions *vk = &vkctx->vkfn;
 
     ff_vk_exec_pool_free(vkctx, &s->e);
     ff_vk_shader_free(vkctx, &s->shd);
 
-    if (s->sampler)
-        vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
-                           vkctx->hwctx->alloc);
-
     ff_vk_uninit(&s->vkctx);
 
     s->initialized = 0;
-- 
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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [FFmpeg-devel] [PATCH 05/11] chromaber_vulkan: fix use of texture()
  2025-02-17 18:31 [FFmpeg-devel] [PATCH 01/11] vulkan_filter: use GENERAL image layout when no sampler is given Lynne
                   ` (2 preceding siblings ...)
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 04/11] avgblur_vulkan: port " Lynne
@ 2025-02-17 18:31 ` Lynne
  2025-02-17 20:03   ` Lynne
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 06/11] flip_vulkan: port to imageLoad() Lynne
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Lynne @ 2025-02-17 18:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne

While the rest of texture() uses were fine, this one was not.
---
 libavfilter/vf_chromaber_vulkan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_chromaber_vulkan.c b/libavfilter/vf_chromaber_vulkan.c
index 65b53afd64..f8cfab1480 100644
--- a/libavfilter/vf_chromaber_vulkan.c
+++ b/libavfilter/vf_chromaber_vulkan.c
@@ -142,7 +142,7 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
     } else {
         GLSLC(1, ivec2 size = imageSize(output_img[0]);                   );
         GLSLC(1, vec2 npos = vec2(pos)/vec2(size);                        );
-        GLSLC(1, vec4 res = texture(input_img[0], npos);                  );
+        GLSLC(1, vec4 res = texture(input_img[0], npos + 0.5f);           );
         GLSLC(1, imageStore(output_img[0], pos, res);                     );
         for (int i = 1; i < planes; i++) {
             GLSLC(0,                                                      );
-- 
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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [FFmpeg-devel] [PATCH 06/11] flip_vulkan: port to imageLoad()
  2025-02-17 18:31 [FFmpeg-devel] [PATCH 01/11] vulkan_filter: use GENERAL image layout when no sampler is given Lynne
                   ` (3 preceding siblings ...)
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 05/11] chromaber_vulkan: fix use of texture() Lynne
@ 2025-02-17 18:31 ` Lynne
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 07/11] gblur_vulkan: " Lynne
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Lynne @ 2025-02-17 18:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne

---
 libavfilter/vf_flip_vulkan.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/libavfilter/vf_flip_vulkan.c b/libavfilter/vf_flip_vulkan.c
index 2cf793cfe8..3e2aed0fda 100644
--- a/libavfilter/vf_flip_vulkan.c
+++ b/libavfilter/vf_flip_vulkan.c
@@ -40,7 +40,6 @@ typedef struct FlipVulkanContext {
     FFVkExecPool e;
     AVVulkanDeviceQueueFamily *qf;
     FFVulkanShader shd;
-    VkSampler sampler;
 } FlipVulkanContext;
 
 static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in, enum FlipType type)
@@ -70,7 +69,6 @@ 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_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR));
     RET(ff_vk_shader_init(vkctx, &s->shd, "flip",
                           VK_SHADER_STAGE_COMPUTE_BIT,
                           NULL, 0,
@@ -80,11 +78,12 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in, enum FlipType
     desc = (FFVulkanDescriptorSetBinding []) {
         {
             .name       = "input_image",
-            .type       = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+            .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,
-            .samplers   = DUP_SAMPLER(s->sampler),
         },
         {
             .name       = "output_image",
@@ -110,16 +109,16 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in, enum FlipType
         switch (type)
         {
         case FLIP_HORIZONTAL:
-            GLSLF(2, vec4 res = texture(input_image[%i], ivec2(size.x - pos.x, pos.y));   ,i);
+            GLSLF(2, vec4 res = imageLoad(input_image[%i], ivec2(size.x - pos.x, pos.y)); ,i);
             break;
         case FLIP_VERTICAL:
-            GLSLF(2, vec4 res = texture(input_image[%i], ivec2(pos.x, size.y - pos.y));   ,i);
+            GLSLF(2, vec4 res = imageLoad(input_image[%i], ivec2(pos.x, size.y - pos.y)); ,i);
             break;
         case FLIP_BOTH:
-            GLSLF(2, vec4 res = texture(input_image[%i], ivec2(size.xy - pos.xy));,         i);
+            GLSLF(2, vec4 res = imageLoad(input_image[%i], ivec2(size.xy - pos.xy));,      i);
             break;
         default:
-            GLSLF(2, vec4 res = texture(input_image[%i], pos);                            ,i);
+            GLSLF(2, vec4 res = imageLoad(input_image[%i], pos);                          ,i);
             break;
         }
         GLSLF(2,     imageStore(output_image[%i], pos, res);                              ,i);
@@ -147,17 +146,11 @@ fail:
 static av_cold void flip_vulkan_uninit(AVFilterContext *avctx)
 {
     FlipVulkanContext *s = avctx->priv;
-
     FFVulkanContext *vkctx = &s->vkctx;
-    FFVulkanFunctions *vk = &vkctx->vkfn;
 
     ff_vk_exec_pool_free(vkctx, &s->e);
     ff_vk_shader_free(vkctx, &s->shd);
 
-    if (s->sampler)
-        vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
-                           vkctx->hwctx->alloc);
-
     ff_vk_uninit(&s->vkctx);
 
     s->initialized = 0;
@@ -181,7 +174,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in, enum FlipType type)
         RET(init_filter(ctx, in, type));
 
     RET(ff_vk_filter_process_simple(&s->vkctx, &s->e, &s->shd, out, in,
-                                    s->sampler, NULL, 0));
+                                    VK_NULL_HANDLE, NULL, 0));
 
     RET(av_frame_copy_props(out, in));
 
-- 
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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [FFmpeg-devel] [PATCH 07/11] gblur_vulkan: port to imageLoad()
  2025-02-17 18:31 [FFmpeg-devel] [PATCH 01/11] vulkan_filter: use GENERAL image layout when no sampler is given Lynne
                   ` (4 preceding siblings ...)
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 06/11] flip_vulkan: port to imageLoad() Lynne
@ 2025-02-17 18:31 ` Lynne
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 08/11] " Lynne
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Lynne @ 2025-02-17 18:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne

---
 libavfilter/vf_gblur_vulkan.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/libavfilter/vf_gblur_vulkan.c b/libavfilter/vf_gblur_vulkan.c
index 58251c4a17..101c8ffd8c 100644
--- a/libavfilter/vf_gblur_vulkan.c
+++ b/libavfilter/vf_gblur_vulkan.c
@@ -53,11 +53,11 @@ typedef struct GBlurVulkanContext {
 static const char gblur_func[] = {
     C(0, void gblur(const ivec2 pos, const int index)                           )
     C(0, {                                                                      )
-    C(1,     vec4 sum = texture(input_images[index], pos) * kernel[0];          )
+    C(1,     vec4 sum = imageLoad(input_images[index], pos) * kernel[0];          )
     C(0,                                                                        )
     C(1,     for(int i = 1; i < kernel.length(); i++) {                         )
-    C(2,         sum += texture(input_images[index], pos + OFFSET) * kernel[i]; )
-    C(2,         sum += texture(input_images[index], pos - OFFSET) * kernel[i]; )
+    C(2,         sum += imageLoad(input_images[index], pos + OFFSET) * kernel[i]; )
+    C(2,         sum += imageLoad(input_images[index], pos - OFFSET) * kernel[i]; )
     C(1,     }                                                                  )
     C(0,                                                                        )
     C(1,     imageStore(output_images[index], pos, sum);                        )
@@ -163,7 +163,7 @@ static int init_gblur_pipeline(GBlurVulkanContext *s,
         if (s->planes & (1 << i)) {
             GLSLF(1,      gblur(pos, %i);                           ,i);
         } else {
-            GLSLF(1, vec4 res = texture(input_images[%i], pos);     ,i);
+            GLSLF(1, vec4 res = imageLoad(input_images[%i], pos);   ,i);
             GLSLF(1, imageStore(output_images[%i], pos, res);       ,i);
         }
     }
@@ -220,16 +220,16 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
     }
 
     RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
-    RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR));
 
     desc = (FFVulkanDescriptorSetBinding []) {
         {
             .name       = "input_images",
-            .type       = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+            .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,
-            .samplers   = DUP_SAMPLER(s->sampler),
         },
         {
             .name       = "output_images",
@@ -293,10 +293,6 @@ static av_cold void gblur_vulkan_uninit(AVFilterContext *avctx)
     ff_vk_free_buf(vkctx, &s->params_hor);
     ff_vk_free_buf(vkctx, &s->params_ver);
 
-    if (s->sampler)
-        vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
-                           vkctx->hwctx->alloc);
-
     ff_vk_uninit(&s->vkctx);
 
     s->initialized = 0;
@@ -327,7 +323,7 @@ static int gblur_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
 
     RET(ff_vk_filter_process_2pass(&s->vkctx, &s->e,
                                    (FFVulkanShader *[2]){ &s->shd_hor, &s->shd_ver },
-                                   out, tmp, in, s->sampler, NULL, 0));
+                                   out, tmp, in, VK_NULL_HANDLE, NULL, 0));
 
     err = av_frame_copy_props(out, in);
     if (err < 0)
-- 
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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [FFmpeg-devel] [PATCH 08/11] gblur_vulkan: port to imageLoad()
  2025-02-17 18:31 [FFmpeg-devel] [PATCH 01/11] vulkan_filter: use GENERAL image layout when no sampler is given Lynne
                   ` (5 preceding siblings ...)
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 07/11] gblur_vulkan: " Lynne
@ 2025-02-17 18:31 ` Lynne
  2025-02-17 19:49   ` Lynne
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 09/11] transpose_vulkan: " Lynne
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Lynne @ 2025-02-17 18:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne

---
 libavfilter/vf_gblur_vulkan.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/libavfilter/vf_gblur_vulkan.c b/libavfilter/vf_gblur_vulkan.c
index 101c8ffd8c..bc4c2217b5 100644
--- a/libavfilter/vf_gblur_vulkan.c
+++ b/libavfilter/vf_gblur_vulkan.c
@@ -51,17 +51,17 @@ typedef struct GBlurVulkanContext {
 } GBlurVulkanContext;
 
 static const char gblur_func[] = {
-    C(0, void gblur(const ivec2 pos, const int index)                           )
-    C(0, {                                                                      )
+    C(0, void gblur(const ivec2 pos, const int index)                             )
+    C(0, {                                                                        )
     C(1,     vec4 sum = imageLoad(input_images[index], pos) * kernel[0];          )
-    C(0,                                                                        )
-    C(1,     for(int i = 1; i < kernel.length(); i++) {                         )
+    C(0,                                                                          )
+    C(1,     for(int i = 1; i < kernel.length(); i++) {                           )
     C(2,         sum += imageLoad(input_images[index], pos + OFFSET) * kernel[i]; )
     C(2,         sum += imageLoad(input_images[index], pos - OFFSET) * kernel[i]; )
-    C(1,     }                                                                  )
-    C(0,                                                                        )
-    C(1,     imageStore(output_images[index], pos, sum);                        )
-    C(0, }                                                                      )
+    C(1,     }                                                                    )
+    C(0,                                                                          )
+    C(1,     imageStore(output_images[index], pos, sum);                          )
+    C(0, }                                                                        )
 };
 
 static inline float gaussian(float sigma, float x)
@@ -254,7 +254,7 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
 
         RET(ff_vk_shader_add_descriptor_set(vkctx, shd, desc, 2, 0, 0));
 
-        GLSLC(0, #define OFFSET (vec2(i, 0.0)));
+        GLSLC(0, #define OFFSET (ivec2(i, 0.0)));
         RET(init_gblur_pipeline(s, shd, &s->params_hor, s->size, s->sigma, spv));
     }
 
@@ -268,7 +268,7 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
 
         RET(ff_vk_shader_add_descriptor_set(vkctx, shd, desc, 2, 0, 0));
 
-        GLSLC(0, #define OFFSET (vec2(0.0, i)));
+        GLSLC(0, #define OFFSET (ivec2(0.0, i)));
         RET(init_gblur_pipeline(s, shd, &s->params_ver, s->sizeV, s->sigmaV, spv));
     }
 
@@ -285,7 +285,6 @@ static av_cold void gblur_vulkan_uninit(AVFilterContext *avctx)
 {
     GBlurVulkanContext *s = avctx->priv;
     FFVulkanContext *vkctx = &s->vkctx;
-    FFVulkanFunctions *vk = &vkctx->vkfn;
 
     ff_vk_exec_pool_free(vkctx, &s->e);
     ff_vk_shader_free(vkctx, &s->shd_hor);
-- 
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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [FFmpeg-devel] [PATCH 09/11] transpose_vulkan: port to imageLoad()
  2025-02-17 18:31 [FFmpeg-devel] [PATCH 01/11] vulkan_filter: use GENERAL image layout when no sampler is given Lynne
                   ` (6 preceding siblings ...)
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 08/11] " Lynne
@ 2025-02-17 18:31 ` Lynne
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 10/11] blend_vulkan: " Lynne
  2025-02-17 18:32 ` [FFmpeg-devel] [PATCH 11/11] overlay_vulkan: " Lynne
  9 siblings, 0 replies; 13+ messages in thread
From: Lynne @ 2025-02-17 18:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne

---
 libavfilter/vf_transpose_vulkan.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/libavfilter/vf_transpose_vulkan.c b/libavfilter/vf_transpose_vulkan.c
index 0169804fbb..3fe2d11cb2 100644
--- a/libavfilter/vf_transpose_vulkan.c
+++ b/libavfilter/vf_transpose_vulkan.c
@@ -35,7 +35,6 @@ typedef struct TransposeVulkanContext {
     FFVkExecPool e;
     AVVulkanDeviceQueueFamily *qf;
     FFVulkanShader shd;
-    VkSampler sampler;
 
     int dir;
     int passthrough;
@@ -69,7 +68,6 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
     }
 
     RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
-    RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR));
     RET(ff_vk_shader_init(vkctx, &s->shd, "transpose",
                           VK_SHADER_STAGE_COMPUTE_BIT,
                           NULL, 0,
@@ -79,11 +77,12 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
     desc = (FFVulkanDescriptorSetBinding []) {
         {
             .name       = "input_images",
-            .type       = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+            .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,
-            .samplers   = DUP_SAMPLER(s->sampler),
         },
         {
             .name       = "output_images",
@@ -107,13 +106,13 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
         GLSLF(1, size = imageSize(output_images[%i]);                ,i);
         GLSLC(1, if (IS_WITHIN(pos, size)) {                           );
         if (s->dir == TRANSPOSE_CCLOCK)
-            GLSLF(2, vec4 res = texture(input_images[%i], ivec2(size.y - pos.y, pos.x)); ,i);
+            GLSLF(2, vec4 res = imageLoad(input_images[%i], ivec2(size.y - pos.y, pos.x)); ,i);
         else if (s->dir == TRANSPOSE_CLOCK_FLIP || s->dir == TRANSPOSE_CLOCK) {
-            GLSLF(2, vec4 res = texture(input_images[%i], ivec2(size.yx - pos.yx));      ,i);
+            GLSLF(2, vec4 res = imageLoad(input_images[%i], ivec2(size.yx - pos.yx));      ,i);
             if (s->dir == TRANSPOSE_CLOCK)
                 GLSLC(2, pos = ivec2(pos.x, size.y - pos.y);           );
         } else
-            GLSLF(2, vec4 res = texture(input_images[%i], pos.yx);   ,i);
+            GLSLF(2, vec4 res = imageLoad(input_images[%i], pos.yx);  ,i);
         GLSLF(2,     imageStore(output_images[%i], pos, res);        ,i);
         GLSLC(1, }                                                     );
     }
@@ -157,7 +156,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         RET(init_filter(ctx, in));
 
     RET(ff_vk_filter_process_simple(&s->vkctx, &s->e, &s->shd, out, in,
-                                    s->sampler, NULL, 0));
+                                    VK_NULL_HANDLE, NULL, 0));
 
     RET(av_frame_copy_props(out, in));
 
@@ -182,15 +181,10 @@ static av_cold void transpose_vulkan_uninit(AVFilterContext *avctx)
 {
     TransposeVulkanContext *s = avctx->priv;
     FFVulkanContext *vkctx = &s->vkctx;
-    FFVulkanFunctions *vk = &vkctx->vkfn;
 
     ff_vk_exec_pool_free(vkctx, &s->e);
     ff_vk_shader_free(vkctx, &s->shd);
 
-    if (s->sampler)
-        vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
-                           vkctx->hwctx->alloc);
-
     ff_vk_uninit(&s->vkctx);
 
     s->initialized = 0;
-- 
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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [FFmpeg-devel] [PATCH 10/11] blend_vulkan: port to imageLoad()
  2025-02-17 18:31 [FFmpeg-devel] [PATCH 01/11] vulkan_filter: use GENERAL image layout when no sampler is given Lynne
                   ` (7 preceding siblings ...)
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 09/11] transpose_vulkan: " Lynne
@ 2025-02-17 18:31 ` Lynne
  2025-02-17 18:32 ` [FFmpeg-devel] [PATCH 11/11] overlay_vulkan: " Lynne
  9 siblings, 0 replies; 13+ messages in thread
From: Lynne @ 2025-02-17 18:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne

---
 libavfilter/vf_blend_vulkan.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/libavfilter/vf_blend_vulkan.c b/libavfilter/vf_blend_vulkan.c
index 58a8f24d5c..57cf3c696b 100644
--- a/libavfilter/vf_blend_vulkan.c
+++ b/libavfilter/vf_blend_vulkan.c
@@ -49,7 +49,6 @@ typedef struct BlendVulkanContext {
     FFVkExecPool e;
     AVVulkanDeviceQueueFamily *qf;
     FFVulkanShader shd;
-    VkSampler sampler;
 
     FilterParamsVulkan params[4];
     double all_opacity;
@@ -149,7 +148,6 @@ static av_cold int init_filter(AVFilterContext *avctx)
     }
 
     RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
-    RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
     RET(ff_vk_shader_init(vkctx, &s->shd, "blend",
                           VK_SHADER_STAGE_COMPUTE_BIT,
                           NULL, 0,
@@ -159,19 +157,21 @@ static av_cold int init_filter(AVFilterContext *avctx)
     desc = (FFVulkanDescriptorSetBinding []) {
         {
             .name       = "top_images",
-            .type       = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+            .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,
-            .samplers   = DUP_SAMPLER(s->sampler),
         },
         {
             .name       = "bottom_images",
-            .type       = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+            .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,
-            .samplers   = DUP_SAMPLER(s->sampler),
         },
         {
             .name       = "output_images",
@@ -204,8 +204,8 @@ static av_cold int init_filter(AVFilterContext *avctx)
         GLSLC(0,                                                            );
         GLSLF(1, size = imageSize(output_images[%i]);                     ,i);
         GLSLC(1, if (IS_WITHIN(pos, size)) {                                );
-        GLSLF(2,     const vec4 top = texture(top_images[%i], pos);       ,i);
-        GLSLF(2,     const vec4 bottom = texture(bottom_images[%i], pos); ,i);
+        GLSLF(2,     const vec4 top = imageLoad(top_images[%i], pos);       ,i);
+        GLSLF(2,     const vec4 bottom = imageLoad(bottom_images[%i], pos); ,i);
         GLSLF(2,     const float opacity = %f;                            ,s->params[i].opacity);
         GLSLF(2,     vec4 dst = %s(top, bottom, opacity);                 ,s->params[i].blend);
         GLSLC(0,                                                            );
@@ -264,7 +264,7 @@ static int blend_frame(FFFrameSync *fs)
 
     RET(ff_vk_filter_process_Nin(&s->vkctx, &s->e, &s->shd,
                                  out, (AVFrame *[]){ top, bottom }, 2,
-                                 s->sampler, NULL, 0));
+                                 VK_NULL_HANDLE, NULL, 0));
 
     return ff_filter_frame(outlink, out);
 
@@ -286,15 +286,10 @@ static av_cold void uninit(AVFilterContext *avctx)
 {
     BlendVulkanContext *s = avctx->priv;
     FFVulkanContext *vkctx = &s->vkctx;
-    FFVulkanFunctions *vk = &vkctx->vkfn;
 
     ff_vk_exec_pool_free(vkctx, &s->e);
     ff_vk_shader_free(vkctx, &s->shd);
 
-    if (s->sampler)
-        vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
-                           vkctx->hwctx->alloc);
-
     ff_vk_uninit(&s->vkctx);
     ff_framesync_uninit(&s->fs);
 
-- 
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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [FFmpeg-devel] [PATCH 11/11] overlay_vulkan: port to imageLoad()
  2025-02-17 18:31 [FFmpeg-devel] [PATCH 01/11] vulkan_filter: use GENERAL image layout when no sampler is given Lynne
                   ` (8 preceding siblings ...)
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 10/11] blend_vulkan: " Lynne
@ 2025-02-17 18:32 ` Lynne
  9 siblings, 0 replies; 13+ messages in thread
From: Lynne @ 2025-02-17 18:32 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne

---
 libavfilter/vf_overlay_vulkan.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/libavfilter/vf_overlay_vulkan.c b/libavfilter/vf_overlay_vulkan.c
index 7d5c201cb5..3c6fb96014 100644
--- a/libavfilter/vf_overlay_vulkan.c
+++ b/libavfilter/vf_overlay_vulkan.c
@@ -35,7 +35,6 @@ typedef struct OverlayVulkanContext {
     FFVkExecPool e;
     AVVulkanDeviceQueueFamily *qf;
     FFVulkanShader shd;
-    VkSampler sampler;
 
     /* Push constants / options */
     struct {
@@ -55,10 +54,10 @@ static const char overlay_noalpha[] = {
     C(1,     if ((o_offset[i].x <= pos.x) && (o_offset[i].y <= pos.y) &&
                  (pos.x < (o_offset[i].x + o_size[i].x)) &&
                  (pos.y < (o_offset[i].y + o_size[i].y))) {                    )
-    C(2,         vec4 res = texture(overlay_img[i], pos - o_offset[i]);        )
+    C(2,         vec4 res = imageLoad(overlay_img[i], pos - o_offset[i]);      )
     C(2,         imageStore(output_img[i], pos, res);                          )
     C(1,     } else {                                                          )
-    C(2,         vec4 res = texture(main_img[i], pos);                         )
+    C(2,         vec4 res = imageLoad(main_img[i], pos);                       )
     C(2,         imageStore(output_img[i], pos, res);                          )
     C(1,     }                                                                 )
     C(0, }                                                                     )
@@ -67,11 +66,11 @@ static const char overlay_noalpha[] = {
 static const char overlay_alpha[] = {
     C(0, void overlay_alpha_opaque(int i, ivec2 pos)                           )
     C(0, {                                                                     )
-    C(1,     vec4 res = texture(main_img[i], pos);                             )
+    C(1,     vec4 res = imageLoad(main_img[i], pos);                           )
     C(1,     if ((o_offset[i].x <= pos.x) && (o_offset[i].y <= pos.y) &&
                  (pos.x < (o_offset[i].x + o_size[i].x)) &&
                  (pos.y < (o_offset[i].y + o_size[i].y))) {                    )
-    C(2,         vec4 ovr = texture(overlay_img[i], pos - o_offset[i]);        )
+    C(2,         vec4 ovr = imageLoad(overlay_img[i], pos - o_offset[i]);      )
     C(2,         res = ovr * ovr.a + res * (1.0f - ovr.a);                     )
     C(2,         res.a = 1.0f;                                                 )
     C(2,         imageStore(output_img[i], pos, res);                          )
@@ -109,7 +108,6 @@ static av_cold int init_filter(AVFilterContext *ctx)
     }
 
     RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
-    RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
     RET(ff_vk_shader_init(vkctx, &s->shd, "overlay",
                           VK_SHADER_STAGE_COMPUTE_BIT,
                           NULL, 0,
@@ -128,19 +126,21 @@ static av_cold int init_filter(AVFilterContext *ctx)
     desc = (FFVulkanDescriptorSetBinding []) {
         {
             .name       = "main_img",
-            .type       = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+            .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,
-            .samplers   = DUP_SAMPLER(s->sampler),
         },
         {
             .name       = "overlay_img",
-            .type       = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+            .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,
-            .samplers   = DUP_SAMPLER(s->sampler),
         },
         {
             .name       = "output_img",
@@ -240,7 +240,7 @@ static int overlay_vulkan_blend(FFFrameSync *fs)
 
     RET(ff_vk_filter_process_Nin(&s->vkctx, &s->e, &s->shd,
                                  out, (AVFrame *[]){ input_main, input_overlay }, 2,
-                                 s->sampler, &s->opts, sizeof(s->opts)));
+                                 VK_NULL_HANDLE, &s->opts, sizeof(s->opts)));
 
     err = av_frame_copy_props(out, input_main);
     if (err < 0)
@@ -295,10 +295,6 @@ static void overlay_vulkan_uninit(AVFilterContext *avctx)
     ff_vk_exec_pool_free(vkctx, &s->e);
     ff_vk_shader_free(vkctx, &s->shd);
 
-    if (s->sampler)
-        vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
-                           vkctx->hwctx->alloc);
-
     ff_vk_uninit(&s->vkctx);
     ff_framesync_uninit(&s->fs);
 
-- 
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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [FFmpeg-devel] [PATCH 08/11] gblur_vulkan: port to imageLoad()
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 08/11] " Lynne
@ 2025-02-17 19:49   ` Lynne
  0 siblings, 0 replies; 13+ messages in thread
From: Lynne @ 2025-02-17 19:49 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1.1.1: Type: text/plain, Size: 3407 bytes --]

On 17/02/2025 19:31, Lynne wrote:
> ---
>   libavfilter/vf_gblur_vulkan.c | 21 ++++++++++-----------
>   1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/libavfilter/vf_gblur_vulkan.c b/libavfilter/vf_gblur_vulkan.c
> index 101c8ffd8c..bc4c2217b5 100644
> --- a/libavfilter/vf_gblur_vulkan.c
> +++ b/libavfilter/vf_gblur_vulkan.c
> @@ -51,17 +51,17 @@ typedef struct GBlurVulkanContext {
>   } GBlurVulkanContext;
>   
>   static const char gblur_func[] = {
> -    C(0, void gblur(const ivec2 pos, const int index)                           )
> -    C(0, {                                                                      )
> +    C(0, void gblur(const ivec2 pos, const int index)                             )
> +    C(0, {                                                                        )
>       C(1,     vec4 sum = imageLoad(input_images[index], pos) * kernel[0];          )
> -    C(0,                                                                        )
> -    C(1,     for(int i = 1; i < kernel.length(); i++) {                         )
> +    C(0,                                                                          )
> +    C(1,     for(int i = 1; i < kernel.length(); i++) {                           )
>       C(2,         sum += imageLoad(input_images[index], pos + OFFSET) * kernel[i]; )
>       C(2,         sum += imageLoad(input_images[index], pos - OFFSET) * kernel[i]; )
> -    C(1,     }                                                                  )
> -    C(0,                                                                        )
> -    C(1,     imageStore(output_images[index], pos, sum);                        )
> -    C(0, }                                                                      )
> +    C(1,     }                                                                    )
> +    C(0,                                                                          )
> +    C(1,     imageStore(output_images[index], pos, sum);                          )
> +    C(0, }                                                                        )
>   };
>   
>   static inline float gaussian(float sigma, float x)
> @@ -254,7 +254,7 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
>   
>           RET(ff_vk_shader_add_descriptor_set(vkctx, shd, desc, 2, 0, 0));
>   
> -        GLSLC(0, #define OFFSET (vec2(i, 0.0)));
> +        GLSLC(0, #define OFFSET (ivec2(i, 0.0)));
>           RET(init_gblur_pipeline(s, shd, &s->params_hor, s->size, s->sigma, spv));
>       }
>   
> @@ -268,7 +268,7 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
>   
>           RET(ff_vk_shader_add_descriptor_set(vkctx, shd, desc, 2, 0, 0));
>   
> -        GLSLC(0, #define OFFSET (vec2(0.0, i)));
> +        GLSLC(0, #define OFFSET (ivec2(0.0, i)));
>           RET(init_gblur_pipeline(s, shd, &s->params_ver, s->sizeV, s->sigmaV, spv));
>       }
>   
> @@ -285,7 +285,6 @@ static av_cold void gblur_vulkan_uninit(AVFilterContext *avctx)
>   {
>       GBlurVulkanContext *s = avctx->priv;
>       FFVulkanContext *vkctx = &s->vkctx;
> -    FFVulkanFunctions *vk = &vkctx->vkfn;
>   
>       ff_vk_exec_pool_free(vkctx, &s->e);
>       ff_vk_shader_free(vkctx, &s->shd_hor);

Note, this patch was a fix for the previous patch, merged both together.

[-- Attachment #1.1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 637 bytes --]

[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

[-- Attachment #2: 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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [FFmpeg-devel] [PATCH 05/11] chromaber_vulkan: fix use of texture()
  2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 05/11] chromaber_vulkan: fix use of texture() Lynne
@ 2025-02-17 20:03   ` Lynne
  0 siblings, 0 replies; 13+ messages in thread
From: Lynne @ 2025-02-17 20:03 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1.1.1: Type: text/plain, Size: 1165 bytes --]

On 17/02/2025 19:31, Lynne wrote:
> While the rest of texture() uses were fine, this one was not.
> ---
>   libavfilter/vf_chromaber_vulkan.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavfilter/vf_chromaber_vulkan.c b/libavfilter/vf_chromaber_vulkan.c
> index 65b53afd64..f8cfab1480 100644
> --- a/libavfilter/vf_chromaber_vulkan.c
> +++ b/libavfilter/vf_chromaber_vulkan.c
> @@ -142,7 +142,7 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
>       } else {
>           GLSLC(1, ivec2 size = imageSize(output_img[0]);                   );
>           GLSLC(1, vec2 npos = vec2(pos)/vec2(size);                        );
> -        GLSLC(1, vec4 res = texture(input_img[0], npos);                  );
> +        GLSLC(1, vec4 res = texture(input_img[0], npos + 0.5f);           );
>           GLSLC(1, imageStore(output_img[0], pos, res);                     );
>           for (int i = 1; i < planes; i++) {
>               GLSLC(0,                                                      );

This patch actually broke the filter, since the sampler is normalized 
(-1;1), so patch dropped.

[-- Attachment #1.1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 637 bytes --]

[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

[-- Attachment #2: 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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-02-17 20:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-17 18:31 [FFmpeg-devel] [PATCH 01/11] vulkan_filter: use GENERAL image layout when no sampler is given Lynne
2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 02/11] bwdif_vulkan: convert to storage images Lynne
2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 03/11] nlmeans_vulkan: switch to imageLoad() Lynne
2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 04/11] avgblur_vulkan: port " Lynne
2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 05/11] chromaber_vulkan: fix use of texture() Lynne
2025-02-17 20:03   ` Lynne
2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 06/11] flip_vulkan: port to imageLoad() Lynne
2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 07/11] gblur_vulkan: " Lynne
2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 08/11] " Lynne
2025-02-17 19:49   ` Lynne
2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 09/11] transpose_vulkan: " Lynne
2025-02-17 18:31 ` [FFmpeg-devel] [PATCH 10/11] blend_vulkan: " Lynne
2025-02-17 18:32 ` [FFmpeg-devel] [PATCH 11/11] overlay_vulkan: " Lynne

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