| 2976 | } |
| 2977 | |
| 2978 | static int vulkan_frames_init(AVHWFramesContext *hwfc) |
| 2979 | { |
| 2980 | int err; |
| 2981 | AVVkFrame *f; |
| 2982 | VulkanFramesPriv *fp = hwfc->hwctx; |
| 2983 | AVVulkanFramesContext *hwctx = &fp->p; |
| 2984 | VulkanDevicePriv *p = hwfc->device_ctx->hwctx; |
| 2985 | AVVulkanDeviceContext *dev_hwctx = &p->p; |
| 2986 | VkImageUsageFlags supported_usage; |
| 2987 | FFVulkanFunctions *vk = &p->vkctx.vkfn; |
| 2988 | const struct FFVkFormatEntry *fmt; |
| 2989 | int disable_multiplane = p->disable_multiplane || |
| 2990 | (hwctx->flags & AV_VK_FRAME_FLAG_DISABLE_MULTIPLANE); |
| 2991 | int is_lone_dpb = ((hwctx->usage & VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR) || |
| 2992 | ((hwctx->usage & VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR) && |
| 2993 | !(hwctx->usage & VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR))); |
| 2994 | |
| 2995 | /* Defaults */ |
| 2996 | if (!hwctx->nb_layers) |
| 2997 | hwctx->nb_layers = 1; |
| 2998 | |
| 2999 | /* VK_IMAGE_TILING_OPTIMAL == 0, can't check for it really */ |
| 3000 | if (p->use_linear_images && |
| 3001 | (hwctx->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT)) |
| 3002 | hwctx->tiling = VK_IMAGE_TILING_LINEAR; |
| 3003 | |
| 3004 | |
| 3005 | fmt = vk_find_format_entry(hwfc->sw_format); |
| 3006 | if (!fmt) { |
| 3007 | av_log(hwfc, AV_LOG_ERROR, "Unsupported pixel format: %s!\n", |
| 3008 | av_get_pix_fmt_name(hwfc->sw_format)); |
| 3009 | return AVERROR(EINVAL); |
| 3010 | } |
| 3011 | |
| 3012 | if (hwctx->format[0] != VK_FORMAT_UNDEFINED) { |
| 3013 | if (hwctx->format[0] != fmt->vkf) { |
| 3014 | for (int i = 0; i < fmt->nb_images_fallback; i++) { |
| 3015 | if (hwctx->format[i] != fmt->fallback[i]) { |
| 3016 | av_log(hwfc, AV_LOG_ERROR, "Incompatible Vulkan format given " |
| 3017 | "for the current sw_format %s!\n", |
| 3018 | av_get_pix_fmt_name(hwfc->sw_format)); |
| 3019 | return AVERROR(EINVAL); |
| 3020 | } |
| 3021 | } |
| 3022 | } |
| 3023 | |
| 3024 | /* Check if the sw_format itself is supported */ |
| 3025 | err = vkfmt_from_pixfmt2(hwfc->device_ctx, hwfc->sw_format, |
| 3026 | hwctx->tiling, NULL, |
| 3027 | NULL, NULL, &supported_usage, 0, |
| 3028 | !hwctx->usage || |
| 3029 | (hwctx->usage & VK_IMAGE_USAGE_STORAGE_BIT)); |
| 3030 | if (err < 0) { |
| 3031 | av_log(hwfc, AV_LOG_ERROR, "Unsupported sw format: %s!\n", |
| 3032 | av_get_pix_fmt_name(hwfc->sw_format)); |
| 3033 | return AVERROR(EINVAL); |
| 3034 | } |
| 3035 | } else { |
no test coverage detected