Bug 502202 - HDR with VRR causing Gama/brightness flicker
Summary: HDR with VRR causing Gama/brightness flicker
Status: RESOLVED UPSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: platform-drm (show other bugs)
Version: 6.3.3
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-30 13:17 UTC by Seimus
Modified: 2025-03-31 19:42 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Seimus 2025-03-30 13:17:53 UTC
***
Hello all,

I am seeing  a weird issue, not sure if this is due to HDR not being yet enough mature. Or this is the classic VRR gamma flicker issue (which I dont think cause I see the problem happening on stable Frame-rate and Frametimes). However;

When Running HDR with VRR enabled (Helldivers 2) via Gamescope, I can see a persistent strong Gamma/Brightness flicker. This flicker is seen even on a stale image, meaning no movement with mouse or camera. I tried to CAP the framerate using for example mangohud or ingame frame limiter but the issue is still happening.

For example if I CAP the game at 90FPS the flickering is more and strongly present while the FPS is kept at stable 90FPS.

The only way how to get rid of this is either:
1. Completely disable HDR for the game, meaning removing the steam launch command. If the command is kept, but instead HDR is disabled in game the flickering is still present.

2. Disable VRR for the game while HDR is enabled

***

STEPS TO REPRODUCE
1. Enable HDR in KDE

2. Enable HDR for the game
gamescope --force-grab-cursor -w 3440 -h 1440 -f -r 165 --hdr-enabled --hdr-debug-force-output --xwayland-count 2 -- env STEAM_MULTIPLE_XWAYLANDS=1 DXVK_HDR=1 ENABLE_HDR_WSI=1  %command%

3. CAP the Framerate to 90FPS to see the flickering be more frequent and present

OBSERVED RESULT
HDR + VRR create an excessive amount of Gamma/Brightness flicker at a stable framerate

EXPECTED RESULT
At a stable Framerate flickering should not occur. 

If only HDR or VRR is enabled this is not occurring. When Both are running together flickering start to appear.

SOFTWARE/OS VERSIONS
Operating System: Garuda Linux (Arch)
KDE Plasma Version: 6.3.3
KDE Frameworks Version: 6.12.0
Qt Version: 6.8.3
Kernel Version: 6.13.8-zen1-1-zen (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 9800X3D 8-Core Processor
Memory: 30,4 GiB of RAM
Graphics Processor 1: AMD Radeon Graphics (9070XT)
Graphics Processor 2: AMD Radeon Graphics (iGPU)
GPU Driver: Mesa 25.0.2-arch1.2 (amdgpu)
Manufacturer: Micro-Star International Co., Ltd.
Product Name: MS-7E51
System Version: 1.0


ADDITIONAL INFORMATION
Monitor: 
AW3423DWF variable refresh rate with a 48-165Hz range

Steam launch command: 
gamescope --force-grab-cursor -w 3440 -h 1440 -f -r 165 --hdr-enabled --hdr-debug-force-output --xwayland-count 2 -- env STEAM_MULTIPLE_XWAYLANDS=1 DXVK_HDR=1 ENABLE_HDR_WSI=1  %command%
Comment 1 Zamundaaa 2025-03-31 13:29:57 UTC
> Completely disable HDR for the game, meaning removing the steam launch command
Sounds like it's possibly not related to HDR itself, but to gamescope being used. What if you use gamescope without --hdr-enabled?

Also, FYI, --hdr-debug-force-output and DXVK_HDR=1 are not needed, and ENABLE_HDR_WSI=1 should not be used within gamescope.
Comment 2 Seimus 2025-03-31 14:24:08 UTC
Hello Zamundaaa,

First of all many thanks for your input.

I tried to run it as you requested, removed the obsolete parameters:
gamescope --force-grab-cursor -w 3440 -h 1440 -f -r 165 --xwayland-count 2 -- env STEAM_MULTIPLE_XWAYLANDS=1 %command%

I tried as well run it as:
gamescope -w 3440 -h 1440 -f -r 165  --  %command%

In both cases ~ With this the HDR in game is disabled (E.g HDR toggle is greyed out), but the flickering is present. 

So I guess this points to be a Gamescope issues?
Comment 3 Seimus 2025-03-31 16:40:36 UTC
I looked around gamescome git repo and found
https://github.com/ValveSoftware/gamescope/issues/1617
https://github.com/ValveSoftware/gamescope/issues/1724

Which after reading looks like gamescope can introduce VRR flicker due to nesting. I turned on my monitor's built-in refresh rate OSD, and per it the Frame rates were all over the place even tho in game they were stable 90.

However matte-schwartz pointed out one interesting parameter --adaptive-sync
I checked the gamescope help
--adaptive-sync                Enable adaptive sync if available (variable rate refresh)

I set the parameter:
gamescope -w 3440 -h 1440 -f -r 165 --adaptive-sync --hdr-enabled --  %command%

= No flicker

I tried as well same parameter with using gooverlay:
gamescope -w 3440 -h 1440 -f -r 165 --adaptive-sync --hdr-enabled --  %command%

= No flicker

I tried as well to set mangoapp as a parameter
gamescope -w 3440 -h 1440 -f -r 165 --adaptive-sync --hdr-enabled --mangoapp --  %command%

= No flicker

And the flickering is gone. So looks like in my case this was a user mistake. If gamesscope is used with a VRR monitor e.g Adaptive sync is turned on, gamescope has to have this parameter explicitly set otherwise VRR is broken and causes insane flicker bellow 100FPS.


@Zamundaaa
Many thanks to pointing me to the correct direction. HDR and VRR are working now properly and I can enjoy both of worlds. Also great work on the HDR! I like to read your blogposts its so exiting having HDR on Linux.
Comment 4 Zamundaaa 2025-03-31 19:04:25 UTC
hmm, that default should probably be changed in gamescope, at least for windowed mode.
Comment 5 Seimus 2025-03-31 19:42:37 UTC
Well wouldn't be more useful to have to changed for full-screen?

As many people (mainly gamers) run VRR in KDE e.g Adaptive sync in Automatic mode which is turned on only for Full screen apps.

Anyway I did as well update the gamescope git ticket, hopefully this will help further down the pipe(upstream)