Bug 491452

Summary: Color correction (built-in) performance issues
Product: [Plasma] kwin Reporter: Bruno Filipe <bmilreu>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: minor CC: alisson.bwt, nate, xaver.hugl
Priority: NOR    
Version: 6.1.4   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 6.2.0
Sentry Crash Report:

Description Bruno Filipe 2024-08-08 20:26:50 UTC
SUMMARY

When built-in color correction is enabled I see the following performance issues on two systems:
1. At 1440p 180hz running glxgears/vkcube, system with 7950x AMD iGPU get's like +30-50% usage compared to color correction off. 
2. At 1440p 240hz running glxgears/vkcube, system with NVIDIA RTX 3090 gets constant periodic usage spikes (+30%) and stutters (going from P2 to P5), compared to smooth 240hz at P2 with color correction off.

ADDITIONAL INFORMATION

I'm thankful this got implemented, just reporting this as a minor issue as it deserves to get optimized further. There are a few too many wide gamut panels without any form of sRGB emulation, or handicapped ones.
Comment 1 Zamundaaa 2024-08-09 13:32:03 UTC
Git commit 6bd07ad6b30e34f43652934630d30234ad65ac7c by Xaver Hugl.
Committed on 09/08/2024 at 13:18.
Pushed by zamundaaa into branch 'master'.

backends/drm: remove the shadow buffer when possible, and reduce it to 10bpc when not

Using the custom values for min. and max. luminance in transfer functions, we can reduce the
ranges of values in the shadow buffer to be limited to [0, 1], and with that we can switch
from a floating point buffer back to a normalized format. As gamma 2.2 encoding is much more
efficient at storing color values, this also drops the buffer from 16bpc down to 10bpc.

Furthermore, this offloads the gamma 2.2 -> PQ conversion to KMS when possible, and then uses
the scanout buffer with gamma 2.2 encoding directly. This way the shadow buffer gets completely
skipped and performance and efficiency get improved a lot.
Related: bug 477223

M  +7    -7    autotests/test_colorspaces.cpp
M  +7    -10   src/backends/drm/drm_egl_layer.cpp
M  +34   -26   src/backends/drm/drm_egl_layer_surface.cpp
M  +2    -2    src/backends/drm/drm_egl_layer_surface.h
M  +45   -28   src/backends/drm/drm_output.cpp
M  +11   -3    src/backends/drm/drm_output.h
M  +4    -10   src/backends/drm/drm_pipeline.cpp
M  +2    -2    src/backends/x11/standalone/x11_standalone_output.cpp
M  +1    -1    src/compositor_wayland.cpp
M  +3    -3    src/core/colorpipeline.cpp
M  +1    -1    src/core/colorpipeline.h
M  +16   -2    src/core/colorspace.cpp
M  +3    -1    src/core/colorspace.h
M  +2    -2    src/wayland/frog_colormanagement_v1.cpp
M  +1    -1    src/wayland/frog_colormanagement_v1.h
M  +3    -3    src/wayland/xx_colormanagement_v4.cpp

https://invent.kde.org/plasma/kwin/-/commit/6bd07ad6b30e34f43652934630d30234ad65ac7c
Comment 2 cwo 2024-09-14 07:32:08 UTC
*** Bug 492839 has been marked as a duplicate of this bug. ***