mpv icon indicating copy to clipboard operation
mpv copied to clipboard

vo_dmabuf_wayland: reject formats not supported by the gpu

Open Dudemanguy opened this issue 2 years ago • 5 comments

The best way to test is to have trash hardware that doesn't support NV12 (yes really).

We probe compositor-supported formats for dmabuf_wayland but we do not check what the gpu supports. If the gpu doesn't support the format, then we should reject it as well. This is still a WIP in progress because although mpv's auto converter does work with this, I have to specify --hwdec otherwise it will fail. Looks like it tries to go directly to yuv420p -> vaapi[bgr0] instead of the two step process of yuv420p -> bgr0 then brg0 -> vaapi[bgr0].

Dudemanguy avatar Feb 17 '24 22:02 Dudemanguy

Are you sure that looking at the planes is the correct way to go about this? I would assume that the number of formats that are supported for direct scanout are only a subset of the formats that the GPU can sample and render. E.g. on my GPU DRM_FORMAT_XRGB1555 is supported by the GPU but not for scanout.

You would also have to make sure that the plane you're looking at is a primary plane.

mahkoh avatar Feb 19 '24 12:02 mahkoh

Are you sure that looking at the planes is the correct way to go about this?

Does libdrm have anything better for seeing what formats are supported? I've always looked at planes.

You would also have to make sure that the plane you're looking at is a primary plane.

Good point, thanks.

Dudemanguy avatar Feb 19 '24 14:02 Dudemanguy

Does libdrm have anything better for seeing what formats are supported? I've always looked at planes.

I expect the supported formats to depend on the API that you're actually using. If you want to attach a framebuffer to a plane, then the IN_FORMATS drm property is what you want to look at. But this would only apply if mpv is using modesetting directly (i.e. mpv was started from a VT) and this MR sounds like there is a wayland compositor in between.

egl and vulkan have APIs to query the supported formats+modifiers. These are what I'm using in my compositor to get the list of available formats. I assume vaapi has something similar.

mahkoh avatar Feb 19 '24 14:02 mahkoh

I assume vaapi has something similar.

Hmm I wouldn't be too sure about that but I'll take a look.

Dudemanguy avatar Feb 19 '24 14:02 Dudemanguy

Yeah tbh I'm not familiar with vaapi. I just assumed that at some point you would have to tell it the output format you want and that would either have to be trial and error or it would have to give you a list of supported formats.

mahkoh avatar Feb 19 '24 16:02 mahkoh

vaapi won't help here because vaapi output formats don't have to be directly displayable.

philipl avatar Feb 19 '24 22:02 philipl

Well for now I made it grab the first primary plane we find. I also just realized that the main device can change at anytime meaning that you could in theory lose the supported formats in the middle of playback. Not sure how exactly I want to handle that yet.

Dudemanguy avatar Feb 19 '24 23:02 Dudemanguy

Download the artifacts for this pull request:

Windows

github-actions[bot] avatar Feb 19 '24 23:02 github-actions[bot]