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.
Showing the changes to libavcodec (1 of 3 files). Show all
Unified · Split
| @@ -934,6 +934,10 @@ static int vulkan_decode_get_profile(AVCodecContext *avctx, AVBufferRef *frames_ · 933 unmodified lines | ||
| 934 | 934 | VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | |
| 935 | 935 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | |
| 936 | 936 | VK_IMAGE_USAGE_SAMPLED_BIT; |
| 937 | + | |
| 938 | + if (ctx->s.extensions & (FF_VK_EXT_VIDEO_ENCODE_QUEUE | | |
| 939 | + FF_VK_EXT_VIDEO_MAINTENANCE_1)) | |
| 940 | + fmt_info.imageUsage |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR; | |
| 937 | 941 | } |
| 938 | 942 | |
| 939 | 943 | /* Get the format of the images necessary */ |
| @@ -1023,6 +1027,7 @@ int ff_vk_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx) · 83 unmodified lines | ||
| 1023 | 1027 | AVVulkanFramesContext *hwfc = frames_ctx->hwctx; |
| 1024 | 1028 | FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data; |
| 1025 | 1029 | FFVulkanDecodeProfileData *prof; |
| 1030 | + FFVulkanDecodeShared *ctx; | |
| 1026 | 1031 | |
| 1027 | 1032 | frames_ctx->sw_format = AV_PIX_FMT_NONE; |
| 1028 | 1033 | |
| @@ -1059,6 +1064,11 @@ int ff_vk_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx) · 30 unmodified lines | ||
| 1059 | 1064 | if (!dec->dedicated_dpb) |
| 1060 | 1065 | hwfc->usage |= VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR; |
| 1061 | 1066 | |
| 1067 | + ctx = dec->shared_ctx; | |
| 1068 | + if (ctx->s.extensions & (FF_VK_EXT_VIDEO_ENCODE_QUEUE | | |
| 1069 | + FF_VK_EXT_VIDEO_MAINTENANCE_1)) | |
| 1070 | + hwfc->usage |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR; | |
| 1071 | + | |
| 1062 | 1072 | return err; |
| 1063 | 1073 | } |
| 1064 | 1074 | |