diff options
author | Lynne <dev@lynne.ee> | 2024-08-14 17:25:00 +0200 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2024-08-16 01:22:16 +0200 |
commit | 18d964fc2c520dd690aa3d737aea62e60fc3786b (patch) | |
tree | 326f875a03f1d8d9d04729e88807a18f069ea6e5 /libavutil | |
parent | 46c13834b6a08d4e7d9b2c457805bfdca55f4613 (diff) | |
download | ffmpeg-18d964fc2c520dd690aa3d737aea62e60fc3786b.tar.gz |
vulkan: enable encoding of images if video_maintenance1 is enabled
Vulkan encoding was designed in a very... consolidated way.
You had to know the exact codec and profile that the image was going to
eventually be encoded as at... image creation time. Unfortunately, as good
as our code is, glimpsing into the exact future isn't what its capable of.
video_maintenance1 removed that requirement, which only then made encoding
images practically possible.
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/hwcontext_vulkan.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index b897a54621..3e00781e9e 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -2632,6 +2632,12 @@ static int vulkan_frames_init(AVHWFramesContext *hwfc) VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT); + + /* Enables encoding of images, if supported by format and extensions */ + if ((supported_usage & VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR) && + (p->vkctx.extensions & (FF_VK_EXT_VIDEO_ENCODE_QUEUE | + FF_VK_EXT_VIDEO_MAINTENANCE_1))) + hwctx->usage |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR; } /* Image creation flags. @@ -2650,6 +2656,28 @@ static int vulkan_frames_init(AVHWFramesContext *hwfc) } } + /* If the image has an ENCODE_SRC usage, and the maintenance1 + * extension is supported, check if it has a profile list. + * If there's no profile list, or it has no encode operations, + * then allow creating the image with no specific profile. */ + if ((hwctx->usage & VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR) && + p->video_maint_1_features.videoMaintenance1) { + const VkVideoProfileListInfoKHR *pl; + pl = ff_vk_find_struct(hwctx->create_pnext, VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR); + if (!pl) { + hwctx->img_flags |= VK_IMAGE_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR; + } else { + uint32_t i; + for (i = 0; i < pl->profileCount; i++) { + /* Video ops start at exactly 0x00010000 */ + if (pl->pProfiles[i].videoCodecOperation & 0xFFFF0000) + break; + } + if (i == pl->profileCount) + hwctx->img_flags |= VK_IMAGE_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR; + } + } + if (!hwctx->lock_frame) hwctx->lock_frame = lock_frame; |