Let display scripts write their HDR luminance into the EDID games see (TVs without luminance get 1499 nits)
Feature request
Problem
Many HDR TVs send a CTA-861 HDR Static Metadata Data Block without the optional luminance bytes (DXVK's fallback comment mentions LG OLEDs). My Samsung S95F sends e3 06 0d 01: EOTFs SDR/PQ/HLG, static metadata type 1, no max/max-average/min luminance. It does advertise 2030 cd/m² in its AMD vendor-specific data block, which neither gamescope nor DXVK reads.
In Gaming Mode, Proton reads the EDID gamescope publishes (GAMESCOPE_DISPLAY_EDID_PATH). DXVK then falls back to 1499 / 799 nits (NormalizeDisplayMetadata in src/wsi/wsi_edid.h), and gamescope's own fallback is also 1499 (DRMBackend.cpp#L2806). Every HDR game therefore reports a 1499-nit peak as DXGI_OUTPUT_DESC1::MaxLuminance, whatever the panel can actually do. Mods such as RenoDX use that value as their default peak.
A display script can set the right values (hdr.max_content_light_level / max_frame_average_luminance, DRMBackend.cpp#L2722). Those only reach gamescope's own tonemapping and infoframe, though, not the EDID games read. That EDID is only patched when bAlwaysPatchEdid || IsHDRG22() (backend.h#L142-L145), and bAlwaysPatchEdid is only set by the nested Wayland backend (WaylandBackend.cpp#L1021).
PatchEdid() on this EDID
Even with patching forced on, PatchEdid() can't handle this TV's EDID. Running src/edid.cpp standalone on the EDID below (not inside a full gamescope build) shows:
- The EDID has 4 blocks, but byte
0x7Eis 1 (HDMI 2.1 HF-EEODB, which declares 3 extensions).assert(ext_count == edid[0x7E])fails (edid.cpp#L152). - CTA byte 3 is
0xf0(underscan, basic audio, YCbCr 4:4:4 / 4:2:2), so the block is skipped as "non-zero CTA flags" (edid.cpp#L170-L173). Most TVs set these flags. - The existing HDR block is too short to patch in place (edid.cpp#L199), so a second HDR block is inserted. DXVK (via libdisplay-info) reads the first one, which is still empty.
- The insert path moves only 7 bytes of the DTDs (
memmove(dtd + 7, dtd, 7), edid.cpp#L224), which corrupts the DTD area. It also doesn't check for free space and carries on after "Giving up patching".
These paths probably haven't come up so far because patching only runs for Deck-style panels.
Proposal
An opt-in display-script field, e.g. hdr.patch_edid = true. When a script sets it and exposes HDR, gamescope writes the script's luminance into the EDID it publishes. Existing scripts and devices would behave exactly as before. The PatchEdid() fixes needed for TVs can be limited to the opt-in path, so the existing G22 path stays byte-for-byte the same.
Would something like that be acceptable?
System
- gamescope 3.17.0-ogc1 (Bazzite); the code references above are upstream
masterat309eee74 - AMD RX 9070 XT, Samsung S95F (65") on HDMI-A-1
edid-decode of the S95F (raw hex + decoded)
Serial number zeroed (base block checksum adjusted); the extension blocks are unchanged.
00 ff ff ff ff ff ff 00 4c 2d b3 78 00 00 00 00
01 23 01 03 80 8e 50 78 0a 95 c1 b4 4b 3d bb 24
0b 50 54 bd ef 80 71 4f 81 c0 81 00 81 80 95 00
a9 c0 b3 00 d1 c0 08 e8 00 30 f2 70 5a 80 b0 58
8a 00 50 1d 74 00 00 1e 6f c2 00 a0 a0 a0 55 50
30 20 35 00 50 1d 74 00 00 1a 00 00 00 fd 00 18
a5 0f ff 9b 00 0a 20 20 20 20 20 20 00 00 00 fc
00 53 39 35 46 0a 20 20 20 20 20 20 20 20 01 eb
02 03 6a f0 e2 78 03 5d 61 60 65 66 75 76 da db
10 1f 22 3f 40 03 04 05 12 13 14 20 21 5a 5c 5d
5e 5f 62 63 64 2f 0d 57 07 09 07 07 15 07 50 57
07 01 67 54 07 83 0f 00 00 e2 00 4f e3 05 c3 01
6e 03 0c 00 10 00 b8 44 28 00 80 01 02 03 04 6d
d8 5d c4 01 78 80 5b 02 30 a5 c3 34 05 e3 06 0d
01 e2 0f ff e5 01 8b 84 90 91 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa
02 03 0d f0 e8 2a 00 00 ff 0e 3f 06 77 cf cb 00
80 f5 40 3a 60 20 a0 3a 50 00 00 00 00 00 1c 1a
68 00 a0 f0 38 1f 40 30 20 3a 00 00 00 00 00 00
1a 74 d6 00 a0 f0 38 40 40 30 20 3a 00 00 00 00
00 00 1a 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51
02 03 34 f0 fa 2a 00 00 ff 0e 6f 08 a4 01 ff 09
37 04 a4 01 ff 0e 3f 06 a4 00 ff 0e 37 04 a4 74
1a 00 00 03 07 30 a5 00 a0 ab 02 60 02 a5 00 00
00 00 00 00 a4 9c 80 a0 70 38 59 40 30 20 35 00
00 00 00 00 00 1a 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 bf
Relevant decoded parts (edid-decode 1.32.0):
Block 1, CTA-861 Extension Block:
Revision: 3
Underscans IT Video Formats by default
Basic audio support
Supports YCbCr 4:4:4
Supports YCbCr 4:2:2
Native detailed modes: 0
HDMI Forum EDID Extension Override Data Block:
EDID Extension Block Count: 3
...
HDR Static Metadata Data Block:
Electro optical transfer functions:
Traditional gamma - SDR luminance range
SMPTE ST2084
Hybrid Log-Gamma
Supported static metadata descriptors:
Static metadata type 1
...
Vendor-Specific Video Data Block (HDR10+), OUI 90-84-8B:
Application Version: 1
Full Frame Peak Luminance Index: 0
Peak Luminance Index: 9
Block 3, CTA-861 Extension Block:
Vendor-Specific Data Block (AMD), OUI 00-00-1A:
Version: 3
...
Maximum luminance: 171 (2030.482 cd/m^2)
Minimum luminance: 2 (0.001 cd/m^2)