1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-22 07:46:55 +00:00

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.
This commit is contained in:
Dudemanguy 2023-07-12 16:04:56 -05:00
parent b57cf110c9
commit 7409f4a6c9

View File

@ -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, &params);
}
}
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")) {