mpv icon indicating copy to clipboard operation
mpv copied to clipboard

wayland: laggy wayland vo

Open axeldavy opened this issue 12 years ago • 10 comments

With --vo=wayland, the video is very laggy, with complaints that the buffers are busy. (Tested with Weston git) With --vo=opengl, there is no such issue.

When looking at the code, I think it's because flip_page doesn't commit the rendered buffers (only frame_handle_redraw will do later), then the previous buffer isn't released.

There was an optimisation when running weston with gl backend, which released the shm buffer immediately (needs however to dispatch events to receive the release). I don't know if it's still present. Anyway it doesn't seem correct for another backend like pixman. One should expect to get the release event when a new buffer was sent, and the screen was redrawn.

vaapi wayland support gives a wl_buffer from a VASurfaceID. So the code done in --vo=wayland could be adapted to handle wl_buffers created with vaapi, instead of wl_buffers coming from shm buffers. That would be great.

EDIT: my hypothesis was wrong (that it was because the commit wasn't just after flip_page). I've tested: . with weston 1.3 . with weston and pixman backend . with ignoring is_busy in the code . with commiting in flip_page

For all of them --vo=wayland was laggy, except pixman backend + ignoring is_busy.

axeldavy avatar Jan 12 '14 08:01 axeldavy

--vo=wayland is pure software rendering. That's why it seems laggy if your CPU is slow. There isn't really anything I could do against it. If we ignroe is_busy and don't commit the buffers in frame_handle_redraw there will be tearing on the video. I don't think tearing is acceptable.

FYI: --vo=wayland isn't really intended to be used for watching videos, I just added it to be a fallback and for testing purposes. Always use --vo=opengl.

giselher avatar Jan 12 '14 12:01 giselher

Thanks for the reply.

I don't have a slow cpu, so I found strange that it was so laggy, and reported the bug. --vo=opengl works well, but has a high cpu comsumption. It would be cool to have a backend with vaapi (vdpau doesn't support Wayland yet).

axeldavy avatar Jan 12 '14 14:01 axeldavy

Someone (is|was) working on a wayland-vaapi. I personally have no way to test vaapi and thus can't write the video output myself.

I will leave this issues open, for others to comment if they have similar problems, because for me the wayland/shm output is as fast as opengl.

Could you also post which formats are supported on your system? There should be some info about which formats are supported if you start mpv with --vo=wayland.

giselher avatar Jan 13 '14 06:01 giselher

Someone (is|was) working on a wayland-vaapi.

That was the user markun on IRC. He tried to add wayland support to vo_vaapi (actually copying vo_vaapi.c and changing the X calls to wayland ones), but scaling and OSD didn't work. If you ask me, this is a one-way road.

Adding vaapi interop support for wayland to vo_opengl would be better IMO. (There is vaapi interop, but it's X/GLX specific - one would probably have to add support for EGL to make it work on wayland.)

Anyway, I can't test this either.

ghost avatar Jan 13 '14 08:01 ghost

PS: you wrote:

vaapi wayland support gives a wl_buffer from a VASurfaceID. So the code done in --vo=wayland could be adapted to handle wl_buffers created with vaapi, instead of wl_buffers coming from shm buffers. That would be great.

I don't know about this - seems like this would provide a 3rd way to use vaapi. I wonder how this would handle OSD, though.

ghost avatar Jan 13 '14 08:01 ghost

About Vaapi support:

It's possible to use opengl to render to the buffer returned by vaapi (import the wl_buffer as EGLImage, import EGLImage as gl texture, rendering to the texture with framebuffer). However the vaapi buffer uses YUV, so rendering to YUV needs to be supported (perhaps it is for intel). And since it is a rather unused path today with YUV, I wouldn't be suprised it would need some Mesa patches to work.

The way to handle OSD is to use Wayland subsurfaces (which were included recently in the core protocol, after having been a weston extension). The Video buffer and the OSD buffer are separated and can be in different formats.

About the bug: I've tested (with Prime) to run mpv with --vo=wayland on an Amd card instead of an Intel one. There was no such slowdown. I assume the bug comes from the Intel driver, Mesa or Kernel.

axeldavy avatar Jan 13 '14 08:01 axeldavy

Oh, and I forgot to mention scaling can be done with the wl_scaler extension, which is a Weston extension for the moment.

axeldavy avatar Jan 13 '14 09:01 axeldavy

I looked libva and I will try what I can do but I can't say how long it will take for me to get something working. I might actually have a PC with an Intel chip that supports vaapi.

giselher avatar Jan 13 '14 10:01 giselher

Since this changed to discussion about vaapi support and there is no way for use to make this faster as it is I will close this issue and redirect the discussion about vaapi support to this issue: #478

giselher avatar Jan 13 '14 10:01 giselher

Also note that weston-terminal can use a LOT of CPU time to draw mpv's status line. Probably the slowest terminal in existence. I got hit by that the first time I tried mpv on wayland :)

ghost avatar Jan 13 '14 10:01 ghost