Bug 422285

Summary: Incorrect colors when capturing screens with depth 30 (10-bit per color)
Product: [Applications] Spectacle Reporter: Bernie Innocenti <bernie>
Component: GeneralAssignee: Boudhayan Gupta <me>
Status: RESOLVED FIXED    
Severity: normal CC: daniel, hi, kde, nate
Priority: NOR    
Version: 20.04.1   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=423014
Latest Commit: Version Fixed In: 21.12
Attachments: Screenshot demonstrating the issue

Description Bernie Innocenti 2020-05-31 08:31:11 UTC
Created attachment 128947 [details]
Screenshot demonstrating the issue

I turned on depth 30 with amdgpu on Xorg. Everything works correctly, except Spectacle screen captures have incorrect colors, as shown in the attachment.

SOFTWARE/OS VERSIONS
Linux kernel: 5.6.15-arch1-1
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.70.0-1
Qt Version: 5.15.0-1
Comment 1 Bernie Innocenti 2020-05-31 08:31:27 UTC
You can configure this mode as follows:

Section "Device"
        Identifier "AMD"
        Driver "amdgpu"
        Option "VariableRefresh" "true"
EndSection

Section "Screen"
        Identifier "default"
        DefaultDepth 30
EndSection
Comment 2 2wxsy58236r3 2020-05-31 11:57:00 UTC
It seems that the Red and Blue color channels in the screenshot are swapped.

You can do the following in GIMP to see the correct colors:
1. Go to Colors -> Components -> Channel Mixer
2. Set Red in Red channel to 0
3. Set Blue in Red channel to 1
4. Set Red in Blue channel to 1
5. Set Blue in Blue channel to 0
Comment 3 Nate Graham 2020-06-10 22:41:46 UTC
Can you turn on 10-bit without using amdgpu (i.e if you only have a 10-bit screen but an Intel GPU)? If so I can test and investigate.
Comment 4 Bernie Innocenti 2020-06-14 20:24:27 UTC
(In reply to Nate Graham from comment #3)
> Can you turn on 10-bit without using amdgpu (i.e if you only have a 10-bit
> screen but an Intel GPU)? If so I can test and investigate.

Add this to /etc/X11/xorg.conf/d/20-defaultdepth.conf:

  Section "Screen"
          Identifier "default"
          DefaultDepth 30
  EndSection

On Fedora 32, this led to a black screen until I disabled compositing in kwin with Alt + Shift + F12 (might not be the default). After this, window decorations were all purple.

I might need an updated versions of mesa or libdri, ymmv.
Comment 5 Bernie Innocenti 2020-06-14 20:39:48 UTC
The GNOME3 X11 session works just fine in 30bpp, so it might be a bug in kwin.

Anyway, I tested Spectacle under GNOME3 in 30bpp, and it still captures wrong colors.
I tried gnome-screenshot, and it works fine.
Comment 6 Bernie Innocenti 2020-07-14 14:47:38 UTC
Proposed fix here:
https://invent.kde.org/graphics/spectacle/-/merge_requests/10/diffs
Comment 7 raymo 2021-10-15 19:30:15 UTC
Can confirm this is still an issue. I agree with Bernie that it should either be wrong on both or right on both, we shouldn't have different behavior for 24 bpc and 30 bpc.
Comment 8 Nate Graham 2021-10-15 20:41:13 UTC
Git commit e6d64481699c5bfac8d552455c0ffc2a8ac68f4f by Nate Graham, on behalf of Bernie Innocenti.
Committed on 15/10/2021 at 20:40.
Pushed by ngraham into branch 'master'.

Fix capturing from depth 30 screens (10bpc)

The color order was incorrect, or rather, not matching the screen
created by the amdgpu DDX driver.

There's probably a better and more portable way to create a compatible
QImage for an XCB image, but I don't know what it is. At least now the
color order for 30bpp matches 24bpp, so on a given platform it should be
either always correct or always wrong.

M  +1    -1    src/Platforms/PlatformXcb.cpp

https://invent.kde.org/graphics/spectacle/commit/e6d64481699c5bfac8d552455c0ffc2a8ac68f4f