From 931d45d4d6aa34629e38066154bdea395fd83035 Mon Sep 17 00:00:00 2001 From: Lynne Date: Wed, 16 Oct 2024 12:06:12 +0200 Subject: [PATCH] vulkan: do not create imageviews with video encode/decode usage This function is only used for filtering and generic compute. The issue is that a view inherits the usage flags from the image by default, and the spec says the view format must be compatible with the usage. VkImageViewUsageCreateInfo allows us to filter out the indeded uses of the imageview. Pffff. --- libavutil/vulkan.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index 11884fbd50..dd5e0f0e2b 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -1553,6 +1553,7 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, AVBufferRef *buf; 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); @@ -1570,9 +1571,15 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, VK_IMAGE_ASPECT_PLANE_1_BIT, VK_IMAGE_ASPECT_PLANE_2_BIT, }; + VkImageViewUsageCreateInfo view_usage_info = { + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO, + .usage = vkfc->usage & + (~(VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | + VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR)), + }; VkImageViewCreateInfo view_create_info = { .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, - .pNext = NULL, + .pNext = &view_usage_info, .image = vkf->img[FFMIN(i, nb_images - 1)], .viewType = VK_IMAGE_VIEW_TYPE_2D, .format = map_fmt_to_rep(rep_fmts[i], rep_fmt),