Bug 450327

Summary: Night Color doesn't work at all on Plasma Wayland with NVIDIA
Product: [Plasma] kwin Reporter: TrueTechie
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: 677ee1vp, andy_morris22, aronkvh, ByteEnable, dcalvino, emelenas, gerrit.huebbers, ict, kde.defiant530, kde, mirh, nate, olib141, psijic, rolodato, summersk, xaver.hugl
Priority: NOR    
Version: 5.24.1   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: Plasma 6.0, or NVidia driver 545+
Sentry Crash Report:

Description TrueTechie 2022-02-15 18:07:12 UTC
SUMMARY
When setting up Night Color on KDE in a Wayland session with the NVIDIA driver, it seems that no reddening color change is applied to the system. On X11 with the exact same system and configuration, this feature works as intended.

STEPS TO REPRODUCE
1.  Login to a Wayland session via SDDM on a machine running the NVIDIA proprietary driver
2.  Open the "Night Color"  tab in the system settings
3. Click "Activate Night Color" and select "Always On" in the activation time drop-down menu. 

OBSERVED RESULT
No color changing effect is applied to the display(s) on hitting "Apply" or on startup.

EXPECTED RESULT
The reddening effect is applied to the displays on hitting "Apply" or on startup.

SOFTWARE/OS VERSIONS
Artix Linux on the Zen Kernel 5.16.8
KDE Plasma Version:  5.24
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Comment 1 Zamundaaa 2022-02-15 19:32:30 UTC
This is because the NVidia driver doesn't support setting gamma ramps. In order for night color to work either NVidia has to implement it or we have to implement a (less efficient) shader based fallback
Comment 2 ByteEnable 2022-11-03 04:51:56 UTC
Worked on Xorg.  Still broken in 5.26.2 and NVidia driver 520.56 with Wayland  Has a bug or feature request been submitted to Nvidia?
Comment 3 andrew morris 2023-01-15 08:57:05 UTC
Bug confirmed on my machine. Works on x11 but not wayland.
Operating System: Fedora Linux 36
KDE Plasma Version: 5.25.4
KDE Frameworks Version: 5.97.0
Qt Version: 5.15.5
Kernel Version: 5.18.18-200.fc36.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-4720HQ CPU @ 2.60GHz
Memory: 15.6 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 980M/PCIe/SSE2
Manufacturer: ASUSTeK COMPUTER INC.
Product Name: G751JY
System Version: 1.0
Relevent packages:
Name         : akmod-nvidia
Version      : 515.65.01
&
Name         : akmods
Version      : 0.5.7
Comment 4 Oliver Beard 2023-02-07 20:22:14 UTC
The specific message logged: kwin_wayland[1069]: kwin_wayland_drm: Failed to create gamma blob! Invalid argument

From: https://forums.developer.nvidia.com/t/wayland-information-for-r515-beta-release/214275
The nvidia-drm module does not support the GAMMA_LUT, DEGAMMA_LUT, CTM, COLOR_ENCODING, or COLOR_RANGE connector properties, which may impact some compositor features related to color correction.
Comment 5 Damian C 2023-04-23 21:23:51 UTC
I want to add that with the Night Color feature enabled, each time the "kwin_wayland_drm: Failed to create gamma blob! Invalid argument" message shows on the logs, the screen freezes (one of them, the other two won't), and it can completely freeze the kwin session.

3 monitors: One Display Port, one HDMI and one DVI.

Operating System: Arch Linux 
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.105.0
Qt Version: 5.15.9
Kernel Version: 6.2.12-zen1-1-zen (64-bit)
Graphics Platform: Wayland
Processors: 12 × Intel® Core™ i7-8700K CPU @ 3.70GHz
Memory: 15.6 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 1070/PCIe/SSE2

Nvidia Drivers: 530.41.03-1

Workaround has been to disable this feature completely.
Comment 6 Zamundaaa 2023-04-24 06:54:44 UTC
Please create a separate bug report for the freeze
Comment 7 Damian C 2023-04-24 09:36:02 UTC
(In reply to Zamundaaa from comment #6)
> Please create a separate bug report for the freeze

Done, https://bugs.kde.org/show_bug.cgi?id=468895

Thank you,
Comment 8 Zamundaaa 2023-05-24 14:18:49 UTC
Git commit cdafbbbd6f80d6ca0639660ed4ec121754553f54 by Xaver Hugl.
Committed on 24/05/2023 at 13:48.
Pushed by zamundaaa into branch 'master'.

backends/drm: always do color management on NVidia GPUs

This comes with a small performance hit but ensures that night color works
Related: bug 468895

M  +1    -1    src/backends/drm/drm_egl_cursor_layer.cpp
M  +1    -1    src/backends/drm/drm_egl_layer.cpp
M  +3    -3    src/backends/drm/drm_egl_layer_surface.cpp
M  +1    -1    src/backends/drm/drm_egl_layer_surface.h
M  +7    -2    src/backends/drm/drm_output.cpp
M  +1    -0    src/backends/drm/drm_output.h

https://invent.kde.org/plasma/kwin/-/commit/cdafbbbd6f80d6ca0639660ed4ec121754553f54
Comment 9 mirh 2023-05-27 11:17:26 UTC
See also https://github.com/NVIDIA/open-gpu-kernel-modules/issues/162
Actual gamma LUT support shouldn't be too far.
Comment 10 Psijic 2023-07-12 18:24:16 UTC
Sure, never worked. Even if current Plasma is 5.27.4
Comment 11 Störm Poorun 2023-11-04 16:22:21 UTC
Nvidia has just released Gamma LUT support!

https://www.nvidia.com/download/driverResults.aspx/214100/en-us/

What changes are required to utilise this rather than the current workaround?
Comment 12 emelenas 2023-11-12 18:01:49 UTC
Nightcolor doesn't work with wayland on
Operating System: Fedora Linux 39
KDE Plasma Version: 5.27.9
KDE Frameworks Version: 5.111.0
Qt Version: 5.15.11
Kernel Version: 6.5.11-300.fc39.x86_64 (64-bit)
Graphics Platform: Wayland
Graphics Processor: NVIDIA GeForce GTX 1050 Ti/PCIe/SSE2

It used to work in X11.

A fix would be greatly appreciated.
Comment 13 emelenas 2023-11-12 18:27:45 UTC
Nightcolor does not work on 
Operating System: Fedora Linux 39
KDE Plasma Version: 5.27.9
KDE Frameworks Version: 5.111.0
Qt Version: 5.15.11
Kernel Version: 6.5.11-300.fc39.x86_64 (64-bit)
Graphics Platform: Wayland
Graphics Processor: NVIDIA GeForce GTX 1050 Ti/PCIe/SSE2

The icon does not even show up in the taskbar. System log shows:

kwin_wayland[8205]: kwin_wayland_drm: Failed to create gamma blob! Invalid argument
Comment 14 Zamundaaa 2023-11-13 14:00:51 UTC
Yes, it's only been fixed for Plasma 6, or NVidia driver 545+
Comment 15 kde.defiant530 2024-05-07 22:22:32 UTC
(In reply to Zamundaaa from comment #14)
> Yes, it's only been fixed for Plasma 6, or NVidia driver 545+

For me, using Fedora 40, Plasma 6.0.4 and nvidia drivers 550.78, this bug is back...
Comment 16 kde.defiant530 2024-05-07 22:26:35 UTC
(In reply to kde.defiant530 from comment #15)
> (In reply to Zamundaaa from comment #14)
> > Yes, it's only been fixed for Plasma 6, or NVidia driver 545+
> 
> For me, using Fedora 40, Plasma 6.0.4 and nvidia drivers 550.78, this bug is
> back...

Sorry for the unnecessary spam, it seems it was my fault that it wasn't working, sorry...