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.
This commit is contained in:
Lynne 2024-10-16 12:06:12 +02:00
parent 4b128de44a
commit 931d45d4d6
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
1 changed files with 8 additions and 1 deletions

View File

@ -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),