https://bugs.kde.org/show_bug.cgi?id=528542
Bug ID: 528542
Summary: Fullscreen game rendered on another GPU only gets ~80
Hz with an ICC profile; with color pipelines enabled,
the GAMMA_LUT blob changes every frame
Classification: Plasma
Product: kwin
Version First 6.8.2
Reported In:
Platform: Arch Linux
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: platform-drm
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Target Milestone: ---
Created attachment 198227
--> https://bugs.kde.org/attachment.cgi?id=198227&action=edit
file used in testing
SUMMARY
On a hybrid laptop (game rendered on the NVIDIA dGPU, monitor connected to the
AMD iGPU), a fullscreen game that renders ~140 fps gets a far lower refresh
rate on a VRR monitor as soon as an ICC profile is set on the output (see
below). With "sRGB" as the color profile or rather no color profile issue
doesn't mafifests.
I've seen this in two configurations. The causes appear to be different, and
I've only found and fixed the second one:
A. Kernel 6.18 (no DRM plane COLOR_PIPELINE API), KWin 6.8.2 with default
settings: up to ~80 Hz, ~100 Hz with the iGPU forced to its highest clocks, as
read from the monitor's OSD. Cause not investigated. Going by the code, 6.8.x
takes the same path on any kernel as long as KWIN_DRM_USE_COLOR_PIPELINE isn't
set, since color pipelines are disabled by default on the Plasma/6.8 branch. I
haven't measured that on a newer kernel, though.
B. Kernel 7.2 with KWIN_DRM_USE_COLOR_PIPELINE=1: ~80 page flips per second,
measured with libdrm, confirmed with montor's OSD, iGPU clocks make no
difference. The GAMMA_LUT blob id changes on every page flip, although the LUT
content stays identical. The cause is that the post-blend offload is retried
and reverted on every frame (analysis and patch below). Patch below are
applicable only to this configuration, should work with kernel 6.19 and above.
B looks like a remaining variant of bug 527628: commit 283c0c1 fixed the case
where color pipelines aren't supported, but the same churn still happens when
they are supported and direct scanout fails for another reason. Since color
pipelines are enabled by default there, B would affect such setups on new
kernels without any environment variable.
STEPS TO REPRODUCE
1. Hybrid laptop with an external VRR monitor (MSI MAG274QRF) connected to the
AMD iGPU (USB-C DP alt mode); game (Counter-Strike 2, tested with
SDL_VIDEO_DRIVER=wayland) renders on the NVIDIA dGPU.
2. Set an ICC profile on the output (matrix/shaper + vcgt, v2.4), leave color
power preference "prefer efficiency" because why not.
3. Start a fullscreen game on the dGPU with the cursor hidden (Counter-Strike
2, native, SDL_VIDEO_DRIVER=wayland), VRR on, game vsync off.
For A: kernel 6.18, KWin 6.8.2 defaults.
For B: a kernel and driver exposing the plane COLOR_PIPELINE API (Linux 6.19+,
amdgpu DCN 3.0+; here 7.2), plus KWIN_DRM_USE_COLOR_PIPELINE=1 on 6.8.x (not
needed on master).
OBSERVED RESULT
Common to A and B:
- The game renders ~140 fps (MangoHud, in-game fps counter), but the refresh
rate stays far below that.
- The game is always composited, since KWin doesn't allow direct scanout of a
buffer from another GPU.
A (6.18):
- Raising the iGPU clocks (power_dpm_force_performance_level=high) raises the
refresh rate from up to ~80 Hz to ~100 Hz.
- kwin_wayland CPU with the iGPU forced high: with ICC ~55 % of a core in the
main thread plus ~26 % in the DP-2 thread; after switching to sRGB ~14 % and ~1
%.
B (7.2 with color pipelines):
- With "sRGB" as the color profile source instead of ICC, the refresh rate
follows the game.
- The scanned-out buffer is KWin's own (AR30, AMD tiled modifier).
- Polling the primary plane FB_ID and the CRTC GAMMA_LUT property with libdrm
for 25 s during gameplay: ~80 flips/s (briefly down to 68) and exactly as many
GAMMA_LUT changes per second. Three blob ids alternate, all with the same
content hash. The plane COLOR_PIPELINE property is 0.
- Forcing the iGPU to its highest clocks makes no difference (~80 flips/s).
- kwin_wayland CPU: ~33 % in the main thread plus ~10 % in the DP-2 thread.
- With vkcube on the dGPU in fullscreen, the same churn shows up during the
first second (94 flips, 63 GAMMA_LUT changes), then it stops and vkcube runs at
165 Hz with ICC. Presumably the visible cursor adds a second layer there, so
the offload is no longer attempted; I haven't verified that.
EXPECTED RESULT
The refresh rate follows the game's frame rate with the ICC profile active, as
it does with sRGB.
ANALYSIS OF B
In Compositor::setupLayers, with a single direct scanout layer,
setPostBlendPipeline() offloads the post-blend part of the color pipeline to
the CRTC (the test commit succeeds). prepareDirectScanout() then fails, because
the client buffer comes from another GPU. composite() falls back to
compositing, and setupLayers resets the post-blend pipeline. On the next frame,
the same thing happens again.
So the CRTC color pipeline switches between the offloaded and the base pipeline
on every frame. DrmAbstractColorOp only caches the last matched pipeline, so
each switch back to the base pipeline creates a new GAMMA_LUT blob, and every
real commit carries a new blob id. The "steady state" shortcut in
DrmOutput::setPostBlendPipeline is never reached, because
resetPostBlendPipeline clears m_appliedPostBlendPipeline each frame.
Without color pipeline support, DrmOutput::setPostBlendPipeline returns early
(since 283c0c1), so this mechanism can't explain A.
>From reading the code (not verified at runtime), B should also be reproducible
on a single GPU with KWIN_DRM_NO_DIRECT_SCANOUT=1: neither the offload
condition in setupLayers nor DrmOutput::setPostBlendPipeline checks it, while
EglGbmLayer::earlyScanoutChecks does, so the offload is attempted and then
fails on every frame. Bug 527915 describes exactly that on 6.8.0, where color
pipelines were still enabled by default: frame drops in fullscreen while the
cursor is hidden, with KWIN_DRM_NO_DIRECT_SCANOUT=1. It was closed as fixed on
2026-10-30 without a comment, presumably by 283c0c1, which doesn't cover that
case.
PATCH (FOR B)
Attached: 0001-compositor-don-t-retry-a-failed-post-blend-offload-e.patch
(against master 29ea63b; compiled there).
It remembers the surface for which the offload didn't lead to a working
configuration (prepareDirectScanout or testPresentation failed) and doesn't
attempt the offload again until the scanout candidate changes.
I've run the same change on 6.8.2 on this machine
(kwin-6.8.2-tested-build.patch). Kernel 7.2, KWIN_DRM_USE_COLOR_PIPELINE=1, ICC
profile active, during gameplay:
| | 6.8.2 | 6.8.2 + patch |
|---|---|---|
| GAMMA_LUT changes per second | ~80 | 0 |
| page flips per second | ~80 | ~142 (= game fps, MangoHud 137-147) |
| frame intervals over 10 s | irrelevant | 1442 frames, median 7.1 ms, p99 10.6
ms, max 13.2 ms |
| kwin_wayland main thread CPU | ~33 % | ~15 % |
| DP-2 commit thread CPU | ~10 % | ~3 % |
The patch doesn't change anything on kernel 6.18 or with color pipelines
disabled (case A).
Known limitation of this approach: if the offload fails once for a transient
reason (e.g. a pending modeset), it isn't retried for that surface until the
candidate changes, which could keep a single-GPU setup on the composited path
longer than needed. Alternatives that might fit better:
- clear the remembered failure when the output state or the candidate's buffer
attributes (device, format, modifier) change;
- check the cheap direct scanout preconditions (buffer device, format/modifier)
before attempting the offload;
- let DrmAbstractColorOp cache more than one pipeline, so that switching back
reuses the base blob (this avoids the GAMMA_LUT changes, though not the
per-frame test commit).
SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux, kernel 6.18.50-xanmod1 (A) and 7.2.15-xanmod1 (B)
KDE Plasma Version: 6.8.2
KDE Frameworks Version: 6.31.0
Qt Version: 6.12.0
Graphics Platform: Wayland
Mesa: 26.2
NVIDIA driver: 595.71.05 (A), 615.78.08 (B, because 595.71.05 isn't supported
on a new kernel), open kernel modules
ADDITIONAL INFORMATION
Hardware: Lenovo IdeaPad Gaming 3 15ARH7, AMD Ryzen 5 6600H (Radeon 660M, DCN
3.1.2), NVIDIA GeForce RTX 3050 Laptop GPU.
Monitor: MSI MAG274QRF-QD, 2560x1440 @ 164.83 Hz, VRR (48-165 Hz), connected
via USB-C to the iGPU.
Related: bug 527628, bug 527915, commit 283c0c1.
--
You are receiving this mail because:
You are watching all bug changes.