Bug 483697

Summary: Cannot enable HDR when display is on Game Mode (Nvidia over HDMI 2.1)
Product: [Plasma] kwin Reporter: zaphiromail
Component: colour-managementAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: normal CC: asubstanced, kde, kodatarule, xaver.hugl
Priority: NOR Keywords: qt6
Version: 6.0.2   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Recording of the steps

Description zaphiromail 2024-03-15 17:15:59 UTC
Created attachment 167278 [details]
Recording of the steps

SUMMARY
I'm unable to enable HDR on Nvidia. Checking the box and saving doesn't do anything.
Using an HDMI 2.1 cable on a Samsung QN90 TV which supports up to hdr10+, the setting works when tv's game mode is disabled, but it should also be supported when it's not.

Relevant output from journalctl --user-unit plasma-kwin_wayland --boot 0
mar 15 09:50:56 desktop kwin_wayland[2992]: kwin_scene_opengl: 0x502: GL_INVALID_OPERATION error generated. <image> and <target> are incompatible
mar 15 09:50:56 desktop kwin_wayland[2992]: kwin_scene_opengl: Invalid framebuffer status:  "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"
mar 15 09:50:56 desktop kwin_wayland[2992]: kwin_wayland_drm: Checking test buffer failed!

STEPS TO REPRODUCE
1. Open Settings
2. Go to Display & Monitor
3. Enable HDR and save

OBSERVED RESULT
No changes happen when saving. The checkbox status isn't kept when returning to the Display settings

EXPECTED RESULT
HDR is enabled and the setting is kept

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Nobara Linux 39 (Fedora 39 based)
Kernel: 6.7.6-201.fsync.fc39.x86_64 (64-bit)
Nvidia Driver Version: 550.54.14
HDMI Version: 2.1
KDE Plasma Version: 6.0.2
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Comment 1 kodatarule 2024-04-02 17:11:50 UTC
Just to update on this, I am able to enable HDR both through Display Port and HDMI using nvidia card on my monitors (Asus XG27WQ), but my Samsung TV just freezes the desktop and reverts to non HDR after a while as described here: https://bugs.kde.org/show_bug.cgi?id=483761
Comment 2 kodatarule 2024-04-02 17:12:09 UTC
*** Bug 483761 has been marked as a duplicate of this bug. ***
Comment 3 Gianandrea 2024-04-07 11:55:27 UTC
I can confirm the exact same behaviour using an RTX 2080. Around KDE6 Beta 1 I did not have this problem, though I do not know if the HDR settings were really being set at in that version.
Comment 4 Gianandrea 2024-04-07 13:54:00 UTC
Some additional observations. If I switch over the mode of the hdmi to console and leave game mode on it appears to work. I can then switch back to pc mode and the screen will go black as its switching over. After that as long as I leave the resolution at native the HDR is still engaged, however if I set the screen to an ultrawide resolution the HDR then cannot be enabled again.
Comment 5 kodatarule 2024-04-27 10:06:25 UTC
I tried to reproduce Gianandrea's observation, but unfortunately for me it sitll gives the same error as before from kwin.
Comment 6 Gianandrea 2024-04-27 11:46:41 UTC
Just to say, my observations are more as clues rather than as a point of resolution. I would need to re test the procedure and properly observe that the TV thought it was in HDR mode, logs for kwin etc. If there is any further testing  or feedback requested I will do my best to help.
Comment 7 zaphiromail 2024-04-27 19:59:41 UTC
I don't have the issue if I connect my thinkpad to the display (Ryzen 7840u, Radeon 780m igpu), so it seems to be a combination of Nvidia GPUs and Samsung TVs
Comment 8 kodatarule 2024-05-01 07:50:17 UTC
(In reply to zaphiromail from comment #7)
> I don't have the issue if I connect my thinkpad to the display (Ryzen 7840u,
> Radeon 780m igpu), so it seems to be a combination of Nvidia GPUs and
> Samsung TVs

On my Lenovo Legion 5(Ryzn 7 6800H, radeon 680m drives displays/ nvidia only does heavy lifting) same issue is observed with same error message in journalctl
Comment 9 Gianandrea 2024-05-28 06:16:57 UTC
KDE Plasma Version: 6.0.5
Kernel Version 6.8.7.201-fsync-fc39
Graphics Platform Wayland
Nvidia Drivers: 555.42.02 (beta)

Since update to Nvidia 555 Beta driver series I can now enable HDR in the menu without it being disabled. The screen becomes super saturated so it is engaging on a system level. So seems like it was an Nvidia handshake issue. I turned on and off a number of times and switched fine.

One thing to note, if I did not click the 'keep' text box after changing to SDR, so it switched back  to HDR, then the HDR tick box would be empty even though I was in HDR mode. If I changed menu and then went back to display Configuration it was ticked as expected.

I can't get it to look reasonable, and checking the TV menu it still is seeing the SDR Colour Spaces, and not the HDR ones. I would guess this relates to this known issue in the Nvidia driver:

"the Colorspace property implementations from Intel and NVidia cause washed out colors on many displays, because the API requires the compositor to change the property value depending on whether or not communication with the display uses RGB or YUV encoding… which the compositor doesn’t actually know anything about. The AMD implementation works around this by translating the property to the correct value in the kernel" - https://zamundaaa.github.io/wayland/2024/05/11/more-hdr-and-color.html
Comment 10 Gianandrea 2024-05-30 07:55:00 UTC
So with a RTX 3080, still on 555 Beta, using HDM2.1 I am able to enable HDR and the colour space is being set correctly. TV reports ST.2084 and HDR is reported as on in the 'Game Menu'. 

Things still look over brightened, but that may be a config thing, and does not relate to this case specifically.
Comment 11 kodatarule 2024-06-08 11:10:52 UTC
Can confirm that with the latest nvidia driver 555 HDR seems to work now correctly!
Comment 12 Zamundaaa 2024-06-12 23:47:29 UTC
Great!