From 7409f4a6c97c80e35dfc3055ec8cb9c29ab9b092 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Wed, 12 Jul 2023 16:04:56 -0500 Subject: vo_dmabuf_wayland: stop lazy loading hwdec The implementation was copied from vo_gpu/vo_gpu_next but fundamentally it doesn't make sense for this VO. Hardware decoding is not optional in vo_dmabuf_wayland. We should be sure to request and load all supported formats in the preinit and fail if there are any problems. There should be no functional change from before, but it's more conceptually correct this way. --- video/out/vo_dmabuf_wayland.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'video') diff --git a/video/out/vo_dmabuf_wayland.c b/video/out/vo_dmabuf_wayland.c index e4c3bf3768..46fe3571a3 100644 --- a/video/out/vo_dmabuf_wayland.c +++ b/video/out/vo_dmabuf_wayland.c @@ -601,13 +601,6 @@ static int reconfig(struct vo *vo, struct mp_image_params *params) return 0; } -static void call_request_hwdec_api(void *ctx, struct hwdec_imgfmt_request *params) -{ - // Roundabout way to run hwdec loading on the VO thread. - // Redirects to request_hwdec_api(). - vo_control(ctx, VOCTRL_LOAD_HWDEC_API, params); -} - static int control(struct vo *vo, uint32_t request, void *data) { struct priv *p = vo->priv; @@ -615,13 +608,6 @@ static int control(struct vo *vo, uint32_t request, void *data) int ret; switch (request) { - case VOCTRL_LOAD_HWDEC_API: - assert(p->hwdec_ctx.ra_ctx); - struct hwdec_imgfmt_request* req = (struct hwdec_imgfmt_request*)data; - if (!is_supported_fmt(req->imgfmt)) - return 0; - ra_hwdec_ctx_load_fmt(&p->hwdec_ctx, vo->hwdec_devs, req); - return (p->hwdec_ctx.num_hwdecs > 0); case VOCTRL_RESET: p->destroy_buffers = true; return VO_TRUE; @@ -725,16 +711,25 @@ static int preinit(struct vo *vo) wl_surface_attach(vo->wl->surface, p->solid_buffer, 0, 0); vo->hwdec_devs = hwdec_devices_create(); - hwdec_devices_set_loader(vo->hwdec_devs, call_request_hwdec_api, vo); - assert(!p->hwdec_ctx.ra_ctx); p->hwdec_ctx = (struct ra_hwdec_ctx) { .log = p->log, .global = p->global, .ra_ctx = p->ctx, }; - ra_hwdec_ctx_init(&p->hwdec_ctx, vo->hwdec_devs, NULL, true); + // Loop through hardware accelerated formats and only request known + // supported formats. + for (int i = IMGFMT_VDPAU_OUTPUT; i < IMGFMT_AVPIXFMT_START; ++i) { + if (is_supported_fmt(i)) { + struct hwdec_imgfmt_request params = { + .imgfmt = i, + .probing = false, + }; + ra_hwdec_ctx_load_fmt(&p->hwdec_ctx, vo->hwdec_devs, ¶ms); + } + } + for (int i = 0; i < p->hwdec_ctx.num_hwdecs; i++) { struct ra_hwdec *hw = p->hwdec_ctx.hwdecs[i]; if (ra_get_native_resource(p->ctx->ra, "VADisplay")) { -- cgit v1.2.3