Bug 495111 - Screenshots of HDR content are overbright
Summary: Screenshots of HDR content are overbright
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: colour-management (show other bugs)
Version: 6.2.1
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-20 20:35 UTC by Oleg
Modified: 2025-03-19 20:23 UTC (History)
6 users (show)

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


Attachments
Overbright HDR screenshot (2.78 MB, image/png)
2024-10-20 20:35 UTC, Oleg
Details
Lutris log (11.03 KB, text/x-log)
2024-10-21 15:19 UTC, Oleg
Details
Screenshot of a screen (2.30 MB, image/png)
2024-10-21 15:20 UTC, Oleg
Details
Screenshot of a window (2.82 MB, image/png)
2024-10-21 15:21 UTC, Oleg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg 2024-10-20 20:35:27 UTC
Created attachment 175066 [details]
Overbright HDR screenshot

SUMMARY
When you take a screenshot of HDR window it turns out overbright.

STEPS TO REPRODUCE
1. Run an HDR application
2. Make a screenshot 

OBSERVED RESULT
Screenshot turns out overbright

EXPECTED RESULT
It should be tonemapped to SDR correctly.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.2.1
KDE Frameworks Version: 6.7.0
Qt Version: 6.8.0
Kernel Version: 6.11.4-4-cachyos (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-7700K CPU @ 4.20GHz
Memory: 15.6 ГиБ of RAM
Graphics Processor: AMD Radeon RX 6700 XT
Comment 1 Noah Davis 2024-10-21 13:23:39 UTC
Moved to KWin since that's where the screenshots come from on Plasma with KWin.
KWin and Spectacle do not support HDR screenshots right now, but that could be fixed.
Comment 2 Zamundaaa 2024-10-21 13:31:33 UTC
HDR content is already tone mapped to SDR, but it depends on the application providing HDR metadata to match the content.

Please check the command line output from running the game, and attach the HDR metadata that gamescope prints into the output here
Comment 3 Noah Davis 2024-10-21 13:48:55 UTC
(In reply to Zamundaaa from comment #2)
> Please check the command line output from running the game, and attach the
> HDR metadata that gamescope prints into the output here

Isn't gamescope a Steam Deck thing? I don't think the reporter is using a Steam Deck. They seem to be using a desktop computer.
Comment 4 Oleg 2024-10-21 15:19:40 UTC
Created attachment 175085 [details]
Lutris log

Here's a log from Lutris. I've observed one thing that I'll describe in the next attachments.
Comment 5 Oleg 2024-10-21 15:20:31 UTC
Created attachment 175086 [details]
Screenshot of a screen

When I take screenshot from screen it is actually tone mapped correctly.
Comment 6 Oleg 2024-10-21 15:21:12 UTC
Created attachment 175087 [details]
Screenshot of a window

But when I try to take a screenshot of a window this is where things go wrong.
Comment 7 Zamundaaa 2024-10-23 12:33:23 UTC
(In reply to Noah Davis from comment #3)
> Isn't gamescope a Steam Deck thing? I don't think the reporter is using a
> Steam Deck. They seem to be using a desktop computer.
No, it's the only way (outside of Quake II RTX) to get games working with HDR on the desktop too.

(In reply to Oleg from comment #4)
> Created attachment 175085 [details]
> Lutris log
> 
> Here's a log from Lutris. I've observed one thing that I'll describe in the
> next attachments.
There's this in the log:
> [HDR Layer] wayland compositor lacking frog color management protocol..
You shouldn't use my Vulkan layer with gamescope, at best it does nothing, but it can cause problems.

Other than that I just see absolutely nothing in the log. This suggests that the game just doesn't set any HDR metadata whatsoever, making this rather hard to deal with. Maybe we could just assume the game's configured to work well with your screen's metadata, or that it's configured for HGIG recommendations, but that could still mess things up.

Aside from just supporting HDR screenshots properly, the only proper-ish thing I can think of here is to analyze the image before tone mapping, to figure out the maximum luminance and use that for tone mapping.

(In reply to Oleg from comment #5)
> When I take screenshot from screen it is actually tone mapped correctly.
Yes, but that's more of a bug than intentional. When you take a "screen"shot, KWin takes the HDR metadata of the screen, instead of the content that's currently shown on it.
Comment 8 Oleg 2024-10-23 17:34:52 UTC
Yeah, I guess that's a bug in Lutris where it sets the wrong environment variable and doesn't set the right one. https://github.com/lutris/lutris/blob/c32e2562b6083d18eb513ac186693062c4a4149c/lutris/runner_interpreter.py#L85
Still, after setting everything right (no HDR WSI layer and DXVK_HDR=1) screenshots are still overbright.
Comment 9 Oleg 2025-03-19 20:23:54 UTC
Screenshots of HDR content are now tonemapped correctly.