[FFmpeg-cvslog] vulkan_filter: require storage images properly, set usage flags explicitly

Lynne git at videolan.org
Mon Sep 9 08:09:59 EEST 2024


ffmpeg | branch: master | Lynne <dev at lynne.ee> | Sat Aug 31 23:28:41 2024 +0000| [eb5088d28cdfd7f8001fa265ff975e7ee1fae85f] | committer: Lynne

vulkan_filter: require storage images properly, set usage flags explicitly

This caused images to be created without a storage usage, which broke
at least lavapipe.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eb5088d28cdfd7f8001fa265ff975e7ee1fae85f
---

 libavfilter/vulkan_filter.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vulkan_filter.c b/libavfilter/vulkan_filter.c
index 64e9b8768a..c31d42b91a 100644
--- a/libavfilter/vulkan_filter.c
+++ b/libavfilter/vulkan_filter.c
@@ -68,7 +68,8 @@ int ff_vk_filter_init_context(AVFilterContext *avctx, FFVulkanContext *s,
         vk = &s->vkfn;
 
         /* Usage mismatch */
-        usage_req = VK_IMAGE_USAGE_SAMPLED_BIT;
+        usage_req = VK_IMAGE_USAGE_SAMPLED_BIT |
+                    VK_IMAGE_USAGE_STORAGE_BIT;
 
         /* If format supports hardware encoding, make sure
          * the context includes it. */
@@ -106,9 +107,11 @@ int ff_vk_filter_init_context(AVFilterContext *avctx, FFVulkanContext *s,
         /* Check if it's usable */
         if (no_storage) {
 skip:
+            av_log(avctx, AV_LOG_VERBOSE, "Cannot reuse context, creating a new one\n");
             device_ref = frames_ctx->device_ref;
             frames_ref = NULL;
         } else {
+            av_log(avctx, AV_LOG_VERBOSE, "Reusing existing frames context\n");
             frames_ref = av_buffer_ref(frames_ref);
             if (!frames_ref)
                 return AVERROR(ENOMEM);
@@ -130,6 +133,12 @@ skip:
         frames_ctx->width     = width;
         frames_ctx->height    = height;
 
+        vk_frames = frames_ctx->hwctx;
+        vk_frames->tiling = VK_IMAGE_TILING_OPTIMAL;
+        vk_frames->usage  = VK_IMAGE_USAGE_SAMPLED_BIT |
+                            VK_IMAGE_USAGE_STORAGE_BIT |
+                            VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
+
         err = av_hwframe_ctx_init(frames_ref);
         if (err < 0) {
             av_buffer_unref(&frames_ref);



More information about the ffmpeg-cvslog mailing list