Lines Matching defs:hwfc
1056 static int create_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd,
1060 AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx;
1061 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
1081 av_log(hwfc, AV_LOG_ERROR, "Command pool creation failure: %s\n",
1095 av_log(hwfc, AV_LOG_ERROR, "Command buffer alloc failure: %s\n",
1114 static void free_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd)
1116 AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx;
1117 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
1151 static VkCommandBuffer get_buf_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd)
1156 static void unref_exec_ctx_deps(AVHWFramesContext *hwfc, VulkanExecCtx *cmd)
1165 static int wait_start_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd)
1168 AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx;
1170 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
1186 av_log(hwfc, AV_LOG_ERROR, "Failed to queue frame fence: %s\n",
1196 unref_exec_ctx_deps(hwfc, cmd);
1200 av_log(hwfc, AV_LOG_ERROR, "Unable to init command buffer: %s\n",
1208 static int add_buf_dep_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd,
1234 unref_exec_ctx_deps(hwfc, cmd);
1238 static int submit_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd,
1243 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
1248 av_log(hwfc, AV_LOG_ERROR, "Unable to finish command buffer: %s\n",
1250 unref_exec_ctx_deps(hwfc, cmd);
1259 av_log(hwfc, AV_LOG_ERROR, "Queue submission failure: %s\n",
1261 unref_exec_ctx_deps(hwfc, cmd);
1272 AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx;
1275 unref_exec_ctx_deps(hwfc, cmd);
1758 AVHWFramesContext *hwfc = opaque;
1759 AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx;
1760 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
1762 int planes = av_pix_fmt_count_planes(hwfc->sw_format);
1779 static int alloc_bind_mem(AVHWFramesContext *hwfc, AVVkFrame *f,
1784 AVHWDeviceContext *ctx = hwfc->device_ctx;
1787 AVVulkanFramesContext *hwfctx = hwfc->hwctx;
1788 const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
1823 av_log(hwfc, AV_LOG_ERROR, "Cannot allocate all planes in a single allocation, "
1830 av_log(hwfc, AV_LOG_ERROR, "The memory requirements differ between plane 0 "
1905 static int prepare_frame(AVHWFramesContext *hwfc, VulkanExecCtx *ectx,
1912 const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
1913 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
1969 if ((err = wait_start_exec_ctx(hwfc, ectx)))
1992 vk->CmdPipelineBarrier(get_buf_exec_ctx(hwfc, ectx),
1997 return submit_exec_ctx(hwfc, ectx, &s_info, frame, 0);
2017 static int create_frame(AVHWFramesContext *hwfc, AVVkFrame **frame,
2023 AVHWDeviceContext *ctx = hwfc->device_ctx;
2027 enum AVPixelFormat format = hwfc->sw_format;
2086 format, hwfc->width, hwfc->height, i);
2118 vulkan_frame_free(hwfc, (uint8_t *)f);
2123 static void try_export_flags(AVHWFramesContext *hwfc,
2129 AVVulkanFramesContext *hwctx = hwfc->hwctx;
2130 AVVulkanDeviceContext *dev_hwctx = hwfc->device_ctx->hwctx;
2131 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
2163 .format = av_vkfmt_from_pixfmt(hwfc->sw_format)[0],
2190 AVHWFramesContext *hwfc = opaque;
2191 AVVulkanFramesContext *hwctx = hwfc->hwctx;
2192 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
2193 VulkanFramesPriv *fp = hwfc->internal->priv;
2204 try_export_flags(hwfc, &eiinfo.handleTypes, &e, IsWindows8OrGreater()
2209 try_export_flags(hwfc, &eiinfo.handleTypes, &e,
2213 try_export_flags(hwfc, &eiinfo.handleTypes, &e,
2217 for (int i = 0; i < av_pix_fmt_count_planes(hwfc->sw_format); i++) {
2223 err = create_frame(hwfc, &f, hwctx->tiling, hwctx->usage,
2228 err = alloc_bind_mem(hwfc, f, eminfo, sizeof(*eminfo));
2232 err = prepare_frame(hwfc, &fp->conv_ctx, f, PREP_MODE_WRITE);
2237 vulkan_frame_free, hwfc, 0);
2244 vulkan_frame_free(hwfc, (uint8_t *)f);
2248 static void vulkan_frames_uninit(AVHWFramesContext *hwfc)
2250 VulkanFramesPriv *fp = hwfc->internal->priv;
2258 free_exec_ctx(hwfc, &fp->conv_ctx);
2259 free_exec_ctx(hwfc, &fp->upload_ctx);
2260 free_exec_ctx(hwfc, &fp->download_ctx);
2263 static int vulkan_frames_init(AVHWFramesContext *hwfc)
2267 AVVulkanFramesContext *hwctx = hwfc->hwctx;
2268 VulkanFramesPriv *fp = hwfc->internal->priv;
2269 AVVulkanDeviceContext *dev_hwctx = hwfc->device_ctx->hwctx;
2270 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
2294 const VkFormat *fmt = av_vkfmt_from_pixfmt(hwfc->sw_format);
2316 av_log(hwfc, AV_LOG_ERROR, "There are no supported modifiers for the given sw_format\n");
2365 av_log(hwfc, AV_LOG_ERROR, "None of the given modifiers supports"
2375 err = create_exec_ctx(hwfc, &fp->conv_ctx,
2381 err = create_exec_ctx(hwfc, &fp->upload_ctx,
2387 err = create_exec_ctx(hwfc, &fp->download_ctx,
2393 err = create_frame(hwfc, &f, hwctx->tiling, hwctx->usage,
2398 vulkan_frame_free(hwfc, (uint8_t *)f);
2400 /* If user did not specify a pool, hwfc->pool will be set to the internal one
2402 if (!hwfc->pool) {
2403 hwfc->internal->pool_internal = av_buffer_pool_init2(sizeof(AVVkFrame),
2404 hwfc, vulkan_pool_alloc,
2406 if (!hwfc->internal->pool_internal)
2413 static int vulkan_get_buffer(AVHWFramesContext *hwfc, AVFrame *frame)
2415 frame->buf[0] = av_buffer_pool_get(hwfc->pool);
2421 frame->width = hwfc->width;
2422 frame->height = hwfc->height;
2427 static int vulkan_transfer_get_formats(AVHWFramesContext *hwfc,
2435 fmts[0] = hwfc->sw_format;
2447 static void vulkan_unmap_frame(AVHWFramesContext *hwfc, HWMapDescriptor *hwmap)
2450 AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx;
2451 const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
2452 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
2470 av_log(hwfc, AV_LOG_ERROR, "Failed to flush memory: %s\n",
2481 static int vulkan_map_frame_to_mem(AVHWFramesContext *hwfc, AVFrame *dst,
2487 AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx;
2488 AVVulkanFramesContext *hwfctx = hwfc->hwctx;
2489 const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
2490 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
2498 av_log(hwfc, AV_LOG_ERROR, "Cannot map from pixel format %s!\n",
2506 av_log(hwfc, AV_LOG_ERROR, "Unable to map frame, not host visible "
2520 av_log(hwfc, AV_LOG_ERROR, "Failed to map image memory: %s\n",
2546 av_log(hwfc, AV_LOG_ERROR, "Failed to invalidate memory: %s\n",
2581 static void vulkan_unmap_from_drm(AVHWFramesContext *hwfc, HWMapDescriptor *hwmap)
2584 AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx;
2585 const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
2586 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
2634 static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **frame,
2641 AVHWDeviceContext *ctx = hwfc->device_ctx;
2645 VulkanFramesPriv *fp = hwfc->internal->priv;
2755 hwfc->sw_format, src->width, src->height, i);
2828 av_log(hwfc, AV_LOG_ERROR, "Failed to get FD properties: %s\n",
2886 err = prepare_frame(hwfc, &fp->conv_ctx, f, PREP_MODE_EXTERNAL_IMPORT);
2907 static int vulkan_map_from_drm(AVHWFramesContext *hwfc, AVFrame *dst,
2913 if ((err = vulkan_map_from_drm_frame_desc(hwfc, &f, src)))
2926 av_log(hwfc, AV_LOG_DEBUG, "Mapped DRM object to Vulkan!\n");
2931 vulkan_frame_free(hwfc->device_ctx->hwctx, (uint8_t *)f);
2973 static int vulkan_export_to_cuda(AVHWFramesContext *hwfc,
2981 AVHWDeviceContext *ctx = hwfc->device_ctx;
2983 const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
2984 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(hwfc->sw_format);
3053 av_log(hwfc, AV_LOG_ERROR, "Unable to export the image as a Win32 Handle: %s!\n",
3081 av_log(hwfc, AV_LOG_ERROR, "Unable to export the image as a FD: %s!\n",
3097 get_plane_wh(&p_w, &p_h, hwfc->sw_format, hwfc->width, hwfc->height, i);
3152 static int vulkan_transfer_data_from_cuda(AVHWFramesContext *hwfc,
3159 VulkanFramesPriv *fp = hwfc->internal->priv;
3160 const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
3161 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(hwfc->sw_format);
3173 err = prepare_frame(hwfc, &fp->upload_ctx, dst_f, PREP_MODE_EXTERNAL_EXPORT);
3181 err = vulkan_export_to_cuda(hwfc, src->hw_frames_ctx, dst);
3211 get_plane_wh(&p_w, &p_h, hwfc->sw_format, hwfc->width, hwfc->height, i);
3231 av_log(hwfc, AV_LOG_VERBOSE, "Transfered CUDA image to Vulkan!\n");
3233 return err = prepare_frame(hwfc, &fp->upload_ctx, dst_f, PREP_MODE_EXTERNAL_IMPORT);
3244 static int vulkan_map_to(AVHWFramesContext *hwfc, AVFrame *dst,
3247 av_unused VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
3254 return vulkan_map_from_vaapi(hwfc, dst, src, flags);
3260 return vulkan_map_from_drm(hwfc, dst, src, flags);
3275 static void vulkan_unmap_to_drm(AVHWFramesContext *hwfc, HWMapDescriptor *hwmap)
3293 static int vulkan_map_to_drm(AVHWFramesContext *hwfc, AVFrame *dst,
3299 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
3301 VulkanFramesPriv *fp = hwfc->internal->priv;
3302 AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx;
3303 AVVulkanFramesContext *hwfctx = hwfc->hwctx;
3304 const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
3318 err = prepare_frame(hwfc, &fp->conv_ctx, f, PREP_MODE_EXTERNAL_EXPORT);
3335 av_log(hwfc, AV_LOG_ERROR, "Failed to retrieve DRM format modifier!\n");
3350 av_log(hwfc, AV_LOG_ERROR, "Unable to export the image as a FD!\n");
3366 VkFormat plane_vkfmt = av_vkfmt_from_pixfmt(hwfc->sw_format)[i];
3372 av_log(hwfc, AV_LOG_ERROR, "Cannot map to DRM layer, unsupported!\n");
3394 av_log(hwfc, AV_LOG_VERBOSE, "Mapped AVVkFrame to a DRM object!\n");
3404 static int vulkan_map_to_vaapi(AVHWFramesContext *hwfc, AVFrame *dst,
3414 err = vulkan_map_to_drm(hwfc, tmp, src, flags);
3431 static int vulkan_map_from(AVHWFramesContext *hwfc, AVFrame *dst,
3434 av_unused VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
3440 return vulkan_map_to_drm(hwfc, dst, src, flags);
3446 return vulkan_map_to_vaapi(hwfc, dst, src, flags);
3452 return vulkan_map_frame_to_mem(hwfc, dst, src, flags);
3684 static int transfer_image_buf(AVHWFramesContext *hwfc, const AVFrame *f,
3691 VulkanFramesPriv *fp = hwfc->internal->priv;
3692 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
3703 VkCommandBuffer cmd_buf = get_buf_exec_ctx(hwfc, ectx);
3728 if ((err = wait_start_exec_ctx(hwfc, ectx)))
3803 if ((err = add_buf_dep_exec_ctx(hwfc, ectx, &f->buf[ref], 1)))
3806 if (ref && (err = add_buf_dep_exec_ctx(hwfc, ectx, bufs, planes)))
3808 return submit_exec_ctx(hwfc, ectx, &s_info, frame, !ref);
3810 return submit_exec_ctx(hwfc, ectx, &s_info, frame, 1);
3814 static int vulkan_transfer_data(AVHWFramesContext *hwfc, const AVFrame *vkf,
3820 AVHWDeviceContext *dev_ctx = hwfc->device_ctx;
3822 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
3836 av_log(hwfc, AV_LOG_ERROR, "Unsupported software frame pixel format!\n");
3840 if (swf->width > hwfc->width || swf->height > hwfc->height)
3851 err = vulkan_map_frame_to_mem(hwfc, map, vkf, AV_HWFRAME_MAP_WRITE);
3940 err = transfer_image_buf(hwfc, vkf, bufs, buf_offsets, tmp.linesize,
3971 static int vulkan_transfer_data_to(AVHWFramesContext *hwfc, AVFrame *dst,
3974 av_unused VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
3986 return vulkan_transfer_data_from_cuda(hwfc, dst, src);
3992 return vulkan_transfer_data(hwfc, dst, src, 0);
3997 static int vulkan_transfer_data_to_cuda(AVHWFramesContext *hwfc, AVFrame *dst,
4004 VulkanFramesPriv *fp = hwfc->internal->priv;
4005 const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
4006 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(hwfc->sw_format);
4018 err = prepare_frame(hwfc, &fp->upload_ctx, dst_f, PREP_MODE_EXTERNAL_EXPORT);
4026 err = vulkan_export_to_cuda(hwfc, dst->hw_frames_ctx, src);
4056 get_plane_wh(&w, &h, hwfc->sw_format, hwfc->width, hwfc->height, i);
4076 av_log(hwfc, AV_LOG_VERBOSE, "Transfered Vulkan image to CUDA!\n");
4078 return prepare_frame(hwfc, &fp->upload_ctx, dst_f, PREP_MODE_EXTERNAL_IMPORT);
4089 static int vulkan_transfer_data_from(AVHWFramesContext *hwfc, AVFrame *dst,
4092 av_unused VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
4104 return vulkan_transfer_data_to_cuda(hwfc, dst, src);
4110 return vulkan_transfer_data(hwfc, src, dst, 1);