gamescope
gamescope copied to clipboard
wlserver: Fix overzealous HDR metadata validation
The validation added in 22618ea is a bit overzealous and discards HDR metadata that simply lacks MaxCLL or MaxFALL values. Valid HDR10 content can lack MaxCLL or MaxFALL values, particularly in cases where it's broadcast or rendered in real-time (as called out in the footnotes of CTA-861-G §6.9.1).
While CTA-861-G §6.9.1 explicitly states that an all-zero or partial-zero HDR infoframe is okay for cases where some/all metadata values are unknown, I've left some basic validation in place to hopefully avoid the issue that 22618ea was trying to fix without throwing away good HDR metadata that has both mastering display luminance range and color primary information.
There are a bunch of displays that completely break if you send them 0s here on the wire. They start to tonemap super aggressively, etc.
Knowing the mastering display metadata isn't particularly useful as they don't refer to the content, and thus cannot be used for gamut mapping or tonemapping (and if a display did, that would be incredibly broken).
I've not seen a game that actually provides valid mastering metadata here anyway.
If I am honest, I am almost tempted to avoid sending HDR metadata to the display at all and only use it to inform our own decisions/mapping given how unreliable it is...
+1 for not sending any of the HDR metadata to the display. SpecialK does offer that option and it "just works".
If the consensus is to avoid sending it to the display, that works for me. FWIW, I have been sending HDR metadata with only the mastering display metadata via both HDR_OUTPUT_METADATA
properties and IDXGISwapChain4::SetHDRMetaData()
without any reported issues.
That said, Microsoft now also advises not to rely on it since many HDR10 displays in the wild don't use it (treating all HDR10 content as PQ10 instead). Since the onus is now on the application rather than the display for tonemapping, it would be nice to expose the display's HDR metadata from the EDID to allow applications to tonemap appropriately for the luminance range of the display.