Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vo_dmabuf_wayland: wayland VO displaying dmabuf buffers using vaapi or drm hwdec #10533

Merged
merged 6 commits into from Oct 26, 2022

Conversation

boxerab
Copy link
Contributor

@boxerab boxerab commented Aug 15, 2022

Wayland VO that can display images from either vaapi or drm hwdecs.

The PR adds the following changes:

  1. a context_wayland Wayland context with no gl dependencies
  2. no-op ra and dmabuf_interop objects - no-op because there is no need to map/unmap the drmprime buffer, and there is no need to manage any textures.

Tested on both x86_64 and rk3399 AArch64

cc @philipl

@boxerab boxerab force-pushed the vo-dmabuf-wayland branch 2 times, most recently from e3d08bf to dfc3eb0 Compare August 16, 2022 14:53
@boxerab boxerab changed the title WIP: vo_dmabuf_wayland: experimental dmabuf/wayland vo vo_dmabuf_wayland: experimental dmabuf/wayland vo Aug 16, 2022
@CounterPillow
Copy link
Contributor

Tested on an AMD Ryzen 7 Pro 3700U, appears to work (with usual no osc/osd caveats) on Weston aside from fullscreening refusing to cover Weston's launcher bar. KWin seemingly lacks NV12 support. Will test on aarch64 when I get the time.

video/out/context_wayland.c Outdated Show resolved Hide resolved
video/out/vo_dmabuf_wayland.c Outdated Show resolved Hide resolved
video/out/gpu/context.c Outdated Show resolved Hide resolved
video/out/gpu/ra.c Outdated Show resolved Hide resolved
@boxerab boxerab force-pushed the vo-dmabuf-wayland branch 17 times, most recently from 3bf7e74 to 39d11c8 Compare September 10, 2022 14:50
@boxerab
Copy link
Contributor Author

boxerab commented Oct 20, 2022

I wish github would fix their webui spacing. It's really confusing. Feel free to rebase that one.

nods done rebased that one

Copy link
Member

@Dudemanguy Dudemanguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bearing with all this. General VO/wayland code looks good to me. I'll just have @philipl ACK the hwdec stuff real quick.

Copy link
Member

@philipl philipl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have a couple of questions.

And also, what is the mechanism that allows the VO compatibility check to pass when hwupload is deciding what formats should be available? You previously commented all that code out but I don't see anything that will make it work here. That code relies on having supported ra formats being provided and you're not doing that either.

filters/f_autoconvert.c Outdated Show resolved Hide resolved
filters/f_hwtransfer.c Show resolved Hide resolved
@boxerab boxerab force-pushed the vo-dmabuf-wayland branch 2 times, most recently from fd0e5f6 to 123e3cc Compare October 20, 2022 17:46
@Dudemanguy
Copy link
Member

And also, what is the mechanism that allows the VO compatibility check to pass when hwupload is deciding what formats should be available?

I think that's just the query_format? It'll only accept IMGFMT_VAAPI and IMGFMT_DRMPRIME. Unless I'm misunderstanding the question.

@philipl
Copy link
Member

philipl commented Oct 21, 2022

And also, what is the mechanism that allows the VO compatibility check to pass when hwupload is deciding what formats should be available?

I think that's just the query_format? It'll only accept IMGFMT_VAAPI and IMGFMT_DRMPRIME. Unless I'm misunderstanding the question.

https://github.com/mpv-player/mpv/blob/master/filters/f_hwtransfer.c#L377

@Dudemanguy
Copy link
Member

https://github.com/mpv-player/mpv/blob/master/filters/f_hwtransfer.c#L377

Thanks. Is that not taken care of by this part?

case VOCTRL_LOAD_HWDEC_API:
assert(p->hwdec_ctx.ra);
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);
break;

@philipl
Copy link
Member

philipl commented Oct 22, 2022

No. This is the logic that compares sw formats.

I just tested the latest code from this PR and the hwupload formats that it ultimately accepts is weird. It rejects some of the basic ones (like yuv420p which we know works) and accepts weirder ones. The list also doesn't reflect the actual compositor capabilities. ie: GNOME only supports bgra and friends but this weird list we get is the same as I see on weston so it tries to send nv12 and just shows black. If I force a conversion in software to a format that GNOME supports, it will hwupload and display correctly.

This goes back to - in principle, the ra format list needs to reflect the compositor's supported formats for hwupload to work correctly.

@Dudemanguy
Copy link
Member

Oh yeah I'm stupid. This hardcodes the drmplanes no wonder.

@philipl
Copy link
Member

philipl commented Oct 24, 2022

As we discussed, let's not block merging this on the hwupload behaviour, but we do need to fix the lack of error if there are no usable formats in f_autoconvert

@boxerab
Copy link
Contributor Author

boxerab commented Oct 26, 2022

As we discussed, let's not block merging this on the hwupload behaviour, but we do need to fix the lack of error if there are no usable formats in f_autoconvert

I've added this error log.

filters/f_autoconvert.c Outdated Show resolved Hide resolved
boxerab and others added 3 commits October 26, 2022 13:37
Wayland VO that can display images from either vaapi or drm hwdec

The PR adds the following changes:

1. a context_wldmabuf context with no gl dependencies
2. no-op ra_wldmabuf and dmabuf_interop_wldmabuf objects
   no-op because there is no need to map/unmap the drmprime buffer,
    and there is no need to manage any textures.

Tested on both x86_64 and rk3399 AArch64
Pulled from mpv-player#10382

The zwp_linux_dmabuf_v1 protocol version 4 provides a file descriptor
containing both formats and modifiers, which makes it possible for the
compositor to import the buffers onto planes using explicit modifiers.

This is an extremely important efficiency improvement, as the 3D
hardware can be left powered off altogether, the vaapi buffer being sent
directly from the video hardware to the display controller.

It could be possible to support zwp_linux_dmabuf_v1 version 3 as well,
but there is no reason beyond compatibility with old stacks.  I would
recommend to ditch version 2 as well, as modifier-less formats aren’t
very useful nowadays.
@Dudemanguy
Copy link
Member

Thanks for all the work on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants