vo_gpu_next: implement target_csp for wayland and automatic color space switching
This patch allows vo_gpu_next to automatically switch to the preferred primaries and transfer function of the current output without the user having to specify them on the command line.
Without this patch, libplacebo will always pick an HDR color space that will require the compositor to perform tone and gamut mapping on SDR outputs. This will likely be of lower quality than what libplacebo can achieve when it instead picks an SDR color space.
I've tested this in Jay and KDE with https://4kmedia.org/lg-new-york-hdr-uhd-4k-demo. Jay currently does not do any tone mapping but even the tone mapping on KDE is not as good as libplacebo. At the start of the video, you can see the clouds getting blown out without this patch. With this patch, the clouds look good.
When moving the window between outputs with different color spaces, you should see logs similar to
[vo/gpu-next/wayland] Surface entered output BNQ BenQ GW2480 (0x3b), scale = 1.000000, refresh rate = 60.000000 Hz
[vo/gpu-next/libplacebo] Picked surface configuration 1: VK_FORMAT_R16G16B16A16_UNORM + VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
[vo/gpu-next/wayland] Surface entered output AOC 24G4 (0x37), scale = 1.000000, refresh rate = 120.000000 Hz
[vo/gpu-next/libplacebo] Picked surface configuration 121: VK_FORMAT_R16G16B16A16_UNORM + VK_COLOR_SPACE_HDR10_ST2084_EXT
Fixes: https://github.com/mpv-player/mpv/issues/16305
Download the artifacts for this pull request:
Windows
So sorry for leaving it not merged for so long. I have taken a look at the topic and if you don't mind I follow up on this in #16512. With the new option, some more docs and support for Vulkan on Windows. I've cherry-picked your Wayland changes. Renamed commit message and skipped gpu-next changes, because I did it differently with the new option.
Sorry on my end for not ever getting around to looking at it as well...
Merged as https://github.com/mpv-player/mpv/commit/39c9d1acb498b9ea5db2bd862cb0411c96979e14 and other vo_gpu_next changes. Should be fine now, we target prefered color space by default, if possible, i.e. if there is compatible surface format. Can be controlled with target-colorspace-hint-mode, see documentation for more info.
Thank you for contribution. Hopefully now most of those things work out of the box.