Bug 494502 - HDR does not work correctly anymore in buggy apps that mis-report brightness with kwin 6.2
Summary: HDR does not work correctly anymore in buggy apps that mis-report brightness ...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 6.2.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2024-10-11 05:09 UTC by bugreports61
Modified: 2024-10-16 15:31 UTC (History)
3 users (show)

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


Attachments
kwin62 hdr laayer (3.04 KB, text/x-log)
2024-10-12 06:38 UTC, bugreports61
Details
gears 5 hdr layer output (2.25 KB, text/plain)
2024-10-15 18:35 UTC, bugreports61
Details
ghostwire tokyo hdr layer output (2.59 KB, text/x-log)
2024-10-15 18:36 UTC, bugreports61
Details
halo infinite hdr layer output (2.71 KB, text/plain)
2024-10-15 18:36 UTC, bugreports61
Details
the last of us hdr layer output (2.69 KB, text/x-log)
2024-10-15 18:36 UTC, bugreports61
Details
tina tinas wonderland (2.59 KB, text/x-log)
2024-10-15 19:17 UTC, bugreports61
Details
attachment-506707-0.html (2.85 KB, text/html)
2024-10-15 20:48 UTC, bugreports61
Details
gears 5 hdr gamescope (2.46 KB, text/plain)
2024-10-16 05:34 UTC, bugreports61
Details
tiny tinas wonderland gamescope (2.37 KB, text/x-log)
2024-10-16 05:35 UTC, bugreports61
Details
doom eternal gamescope log (5.39 KB, text/x-log)
2024-10-16 05:35 UTC, bugreports61
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bugreports61 2024-10-11 05:09:43 UTC
SUMMARY

I am using the vk hdr layer and wine wayland to play games in HDR, e.g. Dead Island 2. After installting kde 6.2 with kwin 6.2 hdr does not work as expected anymore in Dead Island 2.  The whites don't get bright anymore (super visible in the games hdr settings page where you e.g. set the max nits of your display)

STEPS TO REPRODUCE
1. Enable hdr
2. Play a game with hdr (vk hdr layer + wine wayland)
3. HDR looks incorrect

OBSERVED RESULT
HDR looks incorrect

EXPECTED RESULT
HDR looks fine like it does in 6.1.5.2

SOFTWARE/OS VERSIONS
Operating System: EndeavourOS 
KDE Plasma Version: 6.2.0
KDE Frameworks Version: 6.6.0
Qt Version: 6.7.3
Kernel Version: 6.11.2-273-tkg-eevdf (64-bit)
Graphics Platform: Wayland
Processors: 32 × AMD Ryzen 9 5950X 16-Core Processor
Memory: 31.3 GiB of RAM
Graphics Processor: AMD Radeon RX 6900 XT


ADDITIONAL INFORMATION
Moving back from kwin 6.2.0 to kwin 6.1.5.2 fixes the issue.

In addition something seems to have changed for the sdr brightness part when operating in hdr mode. I have to somehow double the brightness of the sdr part to reach what i got before.

Thx !
Comment 1 Zamundaaa 2024-10-12 04:35:50 UTC
Please attach the command line output of when you run the game with the Vulkan layer. It should contain some information about the colorspace and HDR metadata (grep for [HDR Layer])
Comment 2 bugreports61 2024-10-12 06:36:21 UTC
(In reply to Zamundaaa from comment #1)
> Please attach the command line output of when you run the game with the
> Vulkan layer. It should contain some information about the colorspace and
> HDR metadata (grep for [HDR Layer])

I did, please find attached the logs.
Comment 3 bugreports61 2024-10-12 06:38:25 UTC
Created attachment 174723 [details]
kwin62 hdr laayer
Comment 4 bugreports61 2024-10-13 09:18:28 UTC
Hi,

btw, the issue is not limited to Dead Island 2, it affects multiple games. Same issue in e.g Gears 5, where you easily can spot it already at the loading screen of the game.

I also tested with gamescope instead of the hdr layer + wine wayland and hdr seems to work there.
So it is the combination of the HDR Layer + wine wayland which does not work anymore with kwin 6.2 but works fine with kwin 6.1.5.

Hope that helps finding the rootcause of the issue.

Br !
Pingubot
Comment 5 Zamundaaa 2024-10-13 09:46:43 UTC
> max 10000000.000000 nits
Heh, I'm not surprised that causes issues! I'll look into adding some sanity checks to HDR metadata...
Comment 6 bugreports61 2024-10-13 17:11:50 UTC
(In reply to Zamundaaa from comment #5)
> > max 10000000.000000 nits
> Heh, I'm not surprised that causes issues! I'll look into adding some sanity
> checks to HDR metadata...

Cool, thy, great that you found the issue. 

Is that something you need to fix in kwin or your vulkan hdr layer ?
And why did it work  in 6.1.5 and not in 6.2 anymore ?
Comment 7 Bug Janitor Service 2024-10-15 12:45:10 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6626
Comment 8 Zamundaaa 2024-10-15 12:49:16 UTC
(In reply to bugreports61 from comment #6)
> Is that something you need to fix in kwin or your vulkan hdr layer ?
The Vulkan layer is doing everything correctly, the only real place to fix it would be the game that provides wrong data. We can detect this obvious nonsense in KWin though and ignore it.

> And why did it work  in 6.1.5 and not in 6.2 anymore ?
In 6.1, HDR metadata was completely ignored, in 6.2 it's used to adapt the image to the capabilities of your screen.
Comment 9 Zamundaaa 2024-10-15 13:34:36 UTC
Git commit 03b4da31c0a774d38c2d3cca6f131e4dcd270311 by Xaver Hugl.
Committed on 15/10/2024 at 12:44.
Pushed by vladz into branch 'master'.

wayland/color management: ignore obviously wrong HDR metadata

Some applications provide truly nonsensical luminance values, like 10 million nits.
This adds a basic sanity check to not use that for tone mapping

M  +20   -15   src/wayland/frog_colormanagement_v1.cpp
M  +12   -2    src/wayland/xx_colormanagement_v4.cpp

https://invent.kde.org/plasma/kwin/-/commit/03b4da31c0a774d38c2d3cca6f131e4dcd270311
Comment 10 bugreports61 2024-10-15 18:35:00 UTC
(In reply to Zamundaaa from comment #8)
> (In reply to bugreports61 from comment #6)
> > Is that something you need to fix in kwin or your vulkan hdr layer ?
> The Vulkan layer is doing everything correctly, the only real place to fix
> it would be the game that provides wrong data. We can detect this obvious
> nonsense in KWin though and ignore it.
> 
> > And why did it work  in 6.1.5 and not in 6.2 anymore ?
> In 6.1, HDR metadata was completely ignored, in 6.2 it's used to adapt the
> image to the capabilities of your screen.

Hi,

many thx for the information.
I was taking a look at the HDR Layer output of some other games in HDR. Those which do not have metadata in the log seem to work. Others like Gears 5 and Ghostwire Tokyo which have metadata in the log show the same mastering luminance of 10 million nits, for whatever reason.

I attaches some logs for the games i have taken a look at.

Br
Comment 11 bugreports61 2024-10-15 18:35:36 UTC
Created attachment 174852 [details]
gears 5 hdr layer output
Comment 12 bugreports61 2024-10-15 18:36:00 UTC
Created attachment 174853 [details]
ghostwire tokyo hdr layer output
Comment 13 bugreports61 2024-10-15 18:36:23 UTC
Created attachment 174854 [details]
halo infinite hdr layer output
Comment 14 bugreports61 2024-10-15 18:36:43 UTC
Created attachment 174855 [details]
the last of us hdr layer output
Comment 15 bugreports61 2024-10-15 19:17:20 UTC
Created attachment 174857 [details]
tina tinas wonderland

Also 10 million max nits mastering luminance
Comment 16 bugreports61 2024-10-15 19:18:35 UTC
(In reply to Zamundaaa from comment #8)
> (In reply to bugreports61 from comment #6)
> > Is that something you need to fix in kwin or your vulkan hdr layer ?
> The Vulkan layer is doing everything correctly, the only real place to fix
> it would be the game that provides wrong data. We can detect this obvious
> nonsense in KWin though and ignore it.
> 
> > And why did it work  in 6.1.5 and not in 6.2 anymore ?
> In 6.1, HDR metadata was completely ignored, in 6.2 it's used to adapt the
> image to the capabilities of your screen.

One note in addition, for ghostwire tokyo i had even set the ingame option for max luminance to 1000 nits.
Uploaded tiny tinas wonderlond in addition,same 10mil thing.
Comment 17 Zamundaaa 2024-10-15 20:11:54 UTC
(In reply to bugreports61 from comment #16)
> One note in addition, for ghostwire tokyo i had even set the ingame option
> for max luminance to 1000 nits.
> Uploaded tiny tinas wonderlond in addition,same 10mil thing.
I wouldn't trust most games to actually pass through the HDR metadata that you set up. Still, this is pretty odd.

Do you have a guide on how to set up Wine Wayland for a game on Steam? I know that Doom Eternal sets proper HDR metadata in gamescope:
[Gamescope WSI] VkHdrMetadataEXT: display primaries:
                                      r: 0.708 0.292
                                      g: 0.17 0.797
                                      b: 0.131 0.046
                                      w: 0.3127 0.329
                                  mastering luminance: min 1 nits, max 1000 nits
                                  maxContentLightLevel: 1000 nits
                                  maxFrameAverageLightLevel: 500 nits

so I'd like to test that and debug if it also reports nonsense with that. Maybe there's still something broken in the Vulkan layer.
Comment 18 bugreports61 2024-10-15 20:48:06 UTC
Created attachment 174861 [details]
attachment-506707-0.html

Hi,

Sadly doom eternal is one of the rare games which do not work with wine
Wayland. Overall I am using proton Tkg . You can use wine as a base for
that proton version and enable the Wayland backend. It has a very nice
build script which takes care about everything.

I have gamescpe installed and did test gears 5 with it which has working
HDR with gamescope + wine (x11) but not with wine Wayland and the layer .

I will start the game tomorrow morning with gamescope. Do I need to do
anything special or is the metadata simply displayed on the terminal with
gamescpe ?

Can do the same for tiny Tina and other games if needed.

Br

Zamundaaa <bugzilla_noreply@kde.org> schrieb am Di., 15. Okt. 2024, 22:11:

> https://bugs.kde.org/show_bug.cgi?id=494502
>
> --- Comment #17 from Zamundaaa <xaver.hugl@gmail.com> ---
> (In reply to bugreports61 from comment #16)
> > One note in addition, for ghostwire tokyo i had even set the ingame
> option
> > for max luminance to 1000 nits.
> > Uploaded tiny tinas wonderlond in addition,same 10mil thing.
> I wouldn't trust most games to actually pass through the HDR metadata that
> you
> set up. Still, this is pretty odd.
>
> Do you have a guide on how to set up Wine Wayland for a game on Steam? I
> know
> that Doom Eternal sets proper HDR metadata in gamescope:
> [Gamescope WSI] VkHdrMetadataEXT: display primaries:
>                                       r: 0.708 0.292
>                                       g: 0.17 0.797
>                                       b: 0.131 0.046
>                                       w: 0.3127 0.329
>                                   mastering luminance: min 1 nits, max 1000
> nits
>                                   maxContentLightLevel: 1000 nits
>                                   maxFrameAverageLightLevel: 500 nits
>
> so I'd like to test that and debug if it also reports nonsense with that.
> Maybe
> there's still something broken in the Vulkan layer.
>
> --
> You are receiving this mail because:
> You reported the bug.
Comment 19 bugreports61 2024-10-16 05:34:31 UTC
(In reply to Zamundaaa from comment #17)
> (In reply to bugreports61 from comment #16)
> > One note in addition, for ghostwire tokyo i had even set the ingame option
> > for max luminance to 1000 nits.
> > Uploaded tiny tinas wonderlond in addition,same 10mil thing.
> I wouldn't trust most games to actually pass through the HDR metadata that
> you set up. Still, this is pretty odd.
> 
> Do you have a guide on how to set up Wine Wayland for a game on Steam? I
> know that Doom Eternal sets proper HDR metadata in gamescope:
> [Gamescope WSI] VkHdrMetadataEXT: display primaries:
>                                       r: 0.708 0.292
>                                       g: 0.17 0.797
>                                       b: 0.131 0.046
>                                       w: 0.3127 0.329
>                                   mastering luminance: min 1 nits, max 1000
> nits
>                                   maxContentLightLevel: 1000 nits
>                                   maxFrameAverageLightLevel: 500 nits
> 
> so I'd like to test that and debug if it also reports nonsense with that.
> Maybe there's still something broken in the Vulkan layer.

Good morning,

as promised i did some quick tests, find logfiles for the games for gamescope attached (gears5, tiny tina and doom et).
In addition here is the link for wine/proton-tkg: https://github.com/Frogging-Family/wine-tkg-git.
It is super handy to create your own proton and wine builds.

Br
Comment 20 bugreports61 2024-10-16 05:34:55 UTC
Created attachment 174870 [details]
gears 5 hdr gamescope
Comment 21 bugreports61 2024-10-16 05:35:16 UTC
Created attachment 174871 [details]
tiny tinas wonderland gamescope
Comment 22 bugreports61 2024-10-16 05:35:41 UTC
Created attachment 174872 [details]
doom eternal gamescope log
Comment 23 bugreports61 2024-10-16 11:34:22 UTC
@Zamundaaa:

I just retested with:

Repositorium             : extra
Name                     : kwin
Version                  : 6.2.1-1
Beschreibung             : An easy to use, but flexible, composited Window Manager
Architektur              : x86_64
URL                      : https://kde.org/plasma-desktop/
Erstellt am              : Di 15 Okt 2024 20:55:14 CEST
Verifiziert durch        : SHA-256-Summe  Signatur

And it still does not work. So for me it is not fixed in 6.2.1.

Br
Comment 24 Zamundaaa 2024-10-16 14:03:29 UTC
(In reply to bugreports61 from comment #19)
> Good morning,
> 
> as promised i did some quick tests, find logfiles for the games for
> gamescope attached (gears5, tiny tina and doom et).
Great, that shows the same metadata - it's the games doing dumb things.

(In reply to bugreports61 from comment #23)
> And it still does not work. So for me it is not fixed in 6.2.1.
Does it work if you set KWIN_DISABLE_TONEMAPPING=1 for KWin?
Comment 25 bugreports61 2024-10-16 14:59:31 UTC
(In reply to Zamundaaa from comment #24)
> (In reply to bugreports61 from comment #19)
> > Good morning,
> > 
> > as promised i did some quick tests, find logfiles for the games for
> > gamescope attached (gears5, tiny tina and doom et).
> Great, that shows the same metadata - it's the games doing dumb things.
> 
> (In reply to bugreports61 from comment #23)
> > And it still does not work. So for me it is not fixed in 6.2.1.
> Does it work if you set KWIN_DISABLE_TONEMAPPING=1 for KWin?

Yeah, and thinking about it, afaik all the games are UE4 games.

Does it work if you set KWIN_DISABLE_TONEMAPPING=1 for KWin?

-> Yes, using that variable it works fine again.


One side question which i noticed with 6.2:
Using 40% display brightness on my display control is 100 nits. Using the same setting in the display system settings for sdr in hdr mode gives me a way less bright image, its roughly the same if i switch to 200 nits in the settings. I don't remember seeing this in plasma 6.1 . Should i open another issue for that ? In addition it looks like the screen brightness in SDR gets raised shortly after login without me doing anything (i only use my monitor menu to adjust brightness).
Comment 26 Zamundaaa 2024-10-16 15:17:11 UTC
oh, the commit for this just so didn't get into 6.2.1. It should work in the next bugfix release.

> Using 40% display brightness on my display control is 100 nits. Using the same setting in the display system settings for sdr in hdr mode gives me a way less bright image, its roughly the same if i switch to 200 nits in the settings. I don't remember seeing this in plasma 6.1 . Should i open another issue for that ?
Not sure what could be causing that, I don't see it happening here, but probably worth opening a bug report for, yes.

> In addition it looks like the screen brightness in SDR gets raised shortly after login without me doing anything (i only use my monitor menu to adjust brightness).
Yes, powerdevil sets the brightness setting of your screen; if you don't want that, you can disable it with the POWERDEVIL_NO_DDCUTIL=1 environment variable.
Comment 27 bugreports61 2024-10-16 15:31:50 UTC
(In reply to Zamundaaa from comment #26)
> oh, the commit for this just so didn't get into 6.2.1. It should work in the
> next bugfix release.
> 
> > Using 40% display brightness on my display control is 100 nits. Using the same setting in the display system settings for sdr in hdr mode gives me a way less bright image, its roughly the same if i switch to 200 nits in the settings. I don't remember seeing this in plasma 6.1 . Should i open another issue for that ?
> Not sure what could be causing that, I don't see it happening here, but
> probably worth opening a bug report for, yes.
> 
> > In addition it looks like the screen brightness in SDR gets raised shortly after login without me doing anything (i only use my monitor menu to adjust brightness).
> Yes, powerdevil sets the brightness setting of your screen; if you don't
> want that, you can disable it with the POWERDEVIL_NO_DDCUTIL=1 environment
> variable.

Ahhh, ok, if its not in that explains things :).
Will open another bug report for the hdr/sdr brightness thing.

For the powerdevil part, i tried that variable in different spots also following the readme for powerdevil (even verified if the variable shows up in the environment for the process) but the monitor brightness applet still is showing up and changing the brightness there has an visible brightness impact.