Commit 0c9b8145bc for ffmpeg

commit 0c9b8145bcada59846fa4dadd5c4c3fc0d93e210
Author: Niklas Haas <git@haasn.dev>
Date:   Tue Oct 20 00:31:51 2026 +0200

    avutil/vulkan: add ff_vk_create_imageviews_fmt()

    Like ff_vk_create_imageviews(), but with an explicit view format per plane.

    Signed-off-by: Niklas Haas <git@haasn.dev>

diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index 645fdc4209..6d5038a584 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -2146,16 +2146,16 @@ int ff_vk_create_imageview(FFVulkanContext *s,
     return 0;
 }

-int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e,
-                            VkImageView views[AV_NUM_DATA_POINTERS],
-                            AVFrame *f, enum FFVkShaderRepFormat rep_fmt)
+int ff_vk_create_imageviews_fmt(FFVulkanContext *s, FFVkExecContext *e,
+                                VkImageView views[AV_NUM_DATA_POINTERS],
+                                AVFrame *f,
+                                const VkFormat fmts[AV_NUM_DATA_POINTERS])
 {
     int err = 0;
     VkResult ret;
     FFVulkanFunctions *vk = &s->vkfn;
     AVHWFramesContext *hwfc = (AVHWFramesContext *)f->hw_frames_ctx->data;
     AVVulkanFramesContext *vkfc = hwfc->hwctx;
-    const VkFormat *rep_fmts = av_vkfmt_from_pixfmt(hwfc->sw_format);
     AVVkFrame *vkf = (AVVkFrame *)f->data[0];
     const int nb_images = ff_vk_count_images(vkf);
     const int nb_planes = av_pix_fmt_count_planes(hwfc->sw_format);
@@ -2173,7 +2173,7 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e,
             .pNext      = &view_usage_info,
             .image      = vkf->img[FFMIN(i, nb_images - 1)],
             .viewType   = VK_IMAGE_VIEW_TYPE_2D,
-            .format     = ff_vk_map_fmt_to_rep(rep_fmts[i], rep_fmt),
+            .format     = fmts[i],
             .components = ff_comp_identity_map,
             .subresourceRange = {
                 .aspectMask = ff_vk_aspect_flag(f, i),
@@ -2181,13 +2181,6 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e,
                 .layerCount = 1,
             },
         };
-        if (view_create_info.format == VK_FORMAT_UNDEFINED) {
-            av_log(s, AV_LOG_ERROR, "Unable to find a compatible representation "
-                                    "of format %i and mode %i\n",
-                   rep_fmts[i], rep_fmt);
-            err = AVERROR(EINVAL);
-            goto fail;
-        }

         ret = vk->CreateImageView(s->hwctx->act_dev, &view_create_info,
                                   s->hwctx->alloc, &tmp_views[i]);
@@ -2215,6 +2208,28 @@ fail:
     return err;
 }

+int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e,
+                            VkImageView views[AV_NUM_DATA_POINTERS],
+                            AVFrame *f, enum FFVkShaderRepFormat rep_fmt)
+{
+    AVHWFramesContext *hwfc = (AVHWFramesContext *)f->hw_frames_ctx->data;
+    const VkFormat *rep_fmts = av_vkfmt_from_pixfmt(hwfc->sw_format);
+    const int nb_planes = av_pix_fmt_count_planes(hwfc->sw_format);
+    VkFormat fmts[AV_NUM_DATA_POINTERS] = { 0 };
+
+    for (int i = 0; i < nb_planes; i++) {
+        fmts[i] = ff_vk_map_fmt_to_rep(rep_fmts[i], rep_fmt);
+        if (fmts[i] == VK_FORMAT_UNDEFINED) {
+            av_log(s, AV_LOG_ERROR, "Unable to find a compatible representation "
+                                    "of format %i and mode %i\n",
+                   rep_fmts[i], rep_fmt);
+            return AVERROR(EINVAL);
+        }
+    }
+
+    return ff_vk_create_imageviews_fmt(s, e, views, f, fmts);
+}
+
 void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e,
                          AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar,
                          VkPipelineStageFlags2 src_stage,
diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
index 951052e59e..1b92e6a4b2 100644
--- a/libavutil/vulkan.h
+++ b/libavutil/vulkan.h
@@ -582,6 +582,15 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e,
                             VkImageView views[AV_NUM_DATA_POINTERS],
                             AVFrame *f, enum FFVkShaderRepFormat rep_fmt);

+/**
+ * Same as ff_vk_create_imageviews(), but with an explicit view format for
+ * each plane, which must be compatible with the format of the image.
+ */
+int ff_vk_create_imageviews_fmt(FFVulkanContext *s, FFVkExecContext *e,
+                                VkImageView views[AV_NUM_DATA_POINTERS],
+                                AVFrame *f,
+                                const VkFormat fmts[AV_NUM_DATA_POINTERS]);
+
 #define ff_vk_buf_barrier(dst, vkb, s_stage, s_access, s_access2,              \
                           d_stage, d_access, d_access2, offs, bsz)             \
     do {                                                                       \