From 8c28e24c89855e3d200e679e9985ea9e24f855e4 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Thu, 10 Apr 2025 15:44:55 -0500 Subject: [PATCH] vo_dmabuf_wayland: set hwdec_type in reconfig based off of imgfmt The old way of setting it during init isn't really accurate. It's possible for a VADisplay to exist, but for some other hwdec to be desired (e.g. like vulkan). It mostly worked OK because vaapi and drmprime are generally exclusive but to be more correct we can simply check the imgfmt in reconfig instead to correctly determine the type. --- video/out/vo_dmabuf_wayland.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/video/out/vo_dmabuf_wayland.c b/video/out/vo_dmabuf_wayland.c index 6b38175a83..19144a77fb 100644 --- a/video/out/vo_dmabuf_wayland.c +++ b/video/out/vo_dmabuf_wayland.c @@ -689,6 +689,23 @@ static int reconfig(struct vo *vo, struct mp_image *img) { struct priv *p = vo->priv; + switch (img->imgfmt) { + case IMGFMT_VAAPI: + p->hwdec_type = HWDEC_VAAPI; + break; + case IMGFMT_DRMPRIME: + p->hwdec_type = HWDEC_DRMPRIME; + break; + default: + p->hwdec_type = HWDEC_NONE; + } + + if (p->hwdec_type == HWDEC_NONE) { + MP_ERR(vo, "Format '%s' is not a valid hardware accelerated format!\n", + mp_imgfmt_to_name(img->imgfmt)); + return VO_ERROR; + } + if (img->params.force_window) { p->force_window = true; goto done; @@ -841,20 +858,6 @@ static int preinit(struct vo *vo) ra_hwdec_ctx_init(&p->hwdec_ctx, vo->hwdec_devs, "vaapi", false); ra_hwdec_ctx_init(&p->hwdec_ctx, vo->hwdec_devs, "drmprime", false); - 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")) { - p->hwdec_type = HWDEC_VAAPI; - } else if (strcmp(hw->driver->name, "drmprime") == 0) { - p->hwdec_type = HWDEC_DRMPRIME; - } - } - - if (p->hwdec_type == HWDEC_NONE) { - MP_ERR(vo, "No valid hardware decoding driver could be loaded!\n"); - goto err; - } - p->src = (struct mp_rect){0, 0, 0, 0}; return 0;