[FFmpeg-cvslog] vulkan: do not create imageviews with video encode/decode usage
Lynne
git at videolan.org
Wed Oct 16 13:48:42 EEST 2024
ffmpeg | branch: master | Lynne <dev at lynne.ee> | Wed Oct 16 12:06:12 2024 +0200| [931d45d4d6aa34629e38066154bdea395fd83035] | committer: Lynne
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.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=931d45d4d6aa34629e38066154bdea395fd83035
---
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),
More information about the ffmpeg-cvslog
mailing list