9

wrong colors & cursor gamma vs. modesetting/Wayland on RDNA2

 9 months ago
source link: https://gitlab.freedesktop.org/drm/amd/-/issues/1513
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

wrong colors & cursor gamma vs. modesetting/Wayland on RDNA2

Closed Issue created 2 years ago by aufkrawall @aufkrawall

Since I've swapped my RX 5700 XT with an RX 6800, some colors are very noticeably off with xf86-video-amdgpu. It is very noticeable with the top blue bar on GitHub where the last commit and the total number of commits are listed (Example site: https://github.com/torvalds/linux ) . With xf86-video-amdgpu, the top bar's blue color is rather turquoise instead of the regular colder blue tone. This can't be captured in screenshots. When opening such a screenshot with xf86-video-amdgpu, it's still turquoise, whereas with modesetting DDX (or Wayland) it's the regular blue tone. For testing reasons, I forcefully deleted colord so no color adjustments could take place, but the issue was unchanged. It happens also in every browser and also with color calibration turned off (e.g. gfx.color_management.mode = 0 in Firefox).

Perhaps another aspect of the same issue: There seems to be a too dark gamma applied to the hardware cursor. This is not visible with many typical desktop cursor themes which are either black or white, but e.g. when games change the cursor theme this gets apparent. This also only occurs with xf86-video-amdgpu and only since the RDNA2 card is installed.

Tested with Linux 5.11 and 5.12-rc1* (*should not be used with swap). I've also tested without any kernel command line argument like custom EDID. Arch Linux, Xorg 1.20.10, xf86-video-amdgpu 19.1 & git-master.

Xorg.0.log

Activity

    • If it doesn't happen with older GPUs, it's more likely a kernel driver issue.

      Does hacking drmmode_cm_enabled to return FALSE avoid the problem?

    • This needs to be forced in amdgpu DDX? If so, could you provide a patch?

    • Before you try this, run xrandr --prop | grep LUT_SIZE and let us know the value of the (DE)GAMMA_LUT_SIZE properties.

    • Both color and cursor look correct with the patch applied.

    • Thanks for confirming. Since the LUT size is 4096 as well with an RX 5500 XT here, it's hard to imagine how this could be an xf86-video-amdgpu issue, moving to the kernel driver.

    • As I pointed out in my recent comment (two years later :-)), the GAMMA_LUT_SIZE value seems to stay the same, however the GAMMA_LUT does not.

      It is at 117 when the cursor is correct and changes to 123 when the issue happens.

    • Please register or sign in to reply
    • Thanks, I've applied both patches to linux 5.12-rc3 and indeed the GitHub blue is once again blue instead of turquoise. However, the hardware cursor still has a too dark gamma.

    • Please register or sign in to reply
  • Hardware cursor still has wrong (too dark) gamma with xf86-video-amdgpu and linux 5.12-rc8.

    This is the Oxygen Black cursor theme during regular desktop usage (no Wine fullscreen etc.):

    xf86-video-amdgpu:

    modesetting:

    The picture with modesetting only looks too bright due to camera sensor exposure time, but actually it's the correct one (unlike with xf86-video-amdgpu).

    Edited 1 year ago by aufkrawall
  • Still broken with amd-drm-next-5.14-2021-05-12 tag.

  • @daenzer I have a Radeon 6700XT and also experience this issue on X11 using either the modesetting driver or amdgpu. As an example, the KDE Breeze default cursor should appear grey-ish - but it instead appears black and washed out. Just like the pictures aufkrawall posted previously.

    The cursor appears normal if I switch over to Wayland.

    As a workaround, using the modesetting driver and setting the option "UseGammaLUT" to false on the latest Xorg release makes the cursor appear normal.

    Specs:

    • Kernel: 5.15.7-arch1-1
    • Distro: Arch Linux
    • Graphics: AMD Radeon 6700XT (reference card)
    • Desktop: KDE Plasma 5.23.4
    Edited 2 years ago by trilantis
  • I think Plasma Wayland doesn't expose this issue in 5.23 because they were still using a limited gamma range. I switched over to git master to take a look at an issue I was having, and noticed that the cursor corruption is now present in Wayland as well. They recently committed a few changes to expose the full gamma range from the KMS driver, which would explain it.

    • We did indeed only use "limited" (legacy) gamma before, now with atomic gamma the cursor is a lot darker than it should be.

    • Any workaround for us folks using the Plasma Wayland session?

    • Please register or sign in to reply
  • Cursor is still too dark with kernel 5.16.0 on Arch Linux. Had the same issue on Solus. Using an RX 6600 XT.

  • I have the same card as @trilantis and experience the same issue on X11, the cursor's color is not correct.

    Patching xf86-video-amdgpu with @daenzer 's patch resolves the issue.

    Specs:

    • Kernel: 5.16.11-arch1-1
    • Distro: Arch Linux
    • Graphics: AMD Radeon 6700 XT (Powercolor Red Devil)
    • Desktop: KDE Plasma 5.24.2
  • I have an RX 6800 and I have the same issue. I'm on Manjaro KDE using Wayland and I can also confirm Plasma 5.23 did not expose this issue, but Plasma 5.24 does. X11 exposed the issue in both versions. Is there a known work around for this on Wayland?

    • Is there a workaround for people using the Plasma Wayland session? Would it be feasible to alter the gamma on the cursor files to compensate for this bug?

      Is there no way to achieve a software cursor on Wayland, or any other workaround?

      The mouse cursor looks horrible on these graphics cards but I would hate to have to return my card just because of a buggy cursor.

      Edited 1 year ago by Nuno Pereira
    • You can use KWIN_DRM_NO_AMS=1 to force the legacy driver API to be used, which makes KWin fall back to legacy gamma ramps

    • That fixed it! Many thanks @Zamundaaa. Any thing important I'll be losing by using that setting?

      I also posted this workaround on the issue on the KDE Bugtracking.

      Edited 1 year ago by Nuno Pereira
    • As a complete noob in this context, could you please let me know where I should update this value? And could you confirm whether or not it would also work on an Xorg session? Many thanks.

    • @saluki You can place it anywhere that loads environment variables. On Arch, I've set it on /etc/environment to make it global, for example. Not sure about other distros.

      Doesn't seem to work on Xorg for me. Alternatively, as a workaround on Xorg, you can set your AMD GPU to use a software cursor until this is fixed.

    • Thanks for the reply! And sorry to bother you again, but could you point me towards getting my GPU to use a software cursor?

    • Please register or sign in to reply
    • I have this issue as well.

      System info:

      Adding KWIN_DRM_NO_AMS=1 to /etc/environment and logging out and back in fixed it. However the issue seems to still be in SDDM.

      Update for KDE users:

      Use KWIN_FORCE_SW_CURSOR=1 environment variable for fixing this temporarily: KWIN_DRM_NO_AMS may cause other issues with the cursor.

      Edited 1 year ago by Akseli
    • I confirm this also fixes it for me.

      KWIN_DRM_NO_AMS may cause other issues with the cursor.
      What issues in particular?

    • I think non-atomic modesetting is unsupported-ish by recent Wayland compositers, imho don't go there for a cosmetic issue.

      Still it would be nice if this got fixed in amdgpu, a patch fixing this might be just a few lines of code (uneducated guess)...

    • @aufkrawall Unfortunately this bug and this other bug forces us to to use KWIN_DRM_NO_AMS. It's pretty bad that these bugs are still present on RDNA 2 cards. I wonder if the new RDNA 3 will suffer from the same fate.

      EDIT: The other bug I mentioned is related to this instead.

      Edited 1 year ago by Nuno Pereira
    • Please register or sign in to reply
  • Still broken and needs a workaround on kernel 6.1 and mesa 22.3.0.

    • The workarounds listed here are for Xorg or Plasma Wayland. I'm using the sway Wayland compositor, is there anything that can be done against the darkened cursors in this case?

    • Please register or sign in to reply
    • Coming in from closed issue #2459 (closed) and I'm noticing some fixes but I can't seem to apply them because I do not know how to. I'm using Plasma X11 and GNOME X11 with an 6800 XT Red Dragon (Powercooler) some people have mentioned something about modesetting? How would I move to that?

    • Create a file in /etc/X11/xorg.conf.d/ with these contents:

      The filename has to end in ".conf". Name the file for example 20-modesetting.conf.

      The line about "Identifier" is to help with searching in the Xorg log file. You can search for the identifier text in the log file to check for messages about your config.

      The line about "Driver" forces the use of the "modesetting" Xorg module that you heard about.

      The line with the "UseGammaLUT" option is what fixes the wrong color of the cursor.

      You might want to add other options to this file. You can find the available options in man modesetting. There's for example "VariableRefresh" to enable FreeSync support.

      Edited 9 months ago by Harald Weissmueller
    • That did it, thank you so much! This has been driving me nuts for a really long time and I thought it was just a me issue. Hope to see this permanently resolved someday.

    • What would be the configuration for kwin-wayland?

    • Please register or sign in to reply
    • I can also confirm that this is still an issue with an RX 7900 XTX on Linux 6.3.0 (Plasma/X11); and that it did NOT affect an RX 5700 XT on a similar system.

      Things look sane if I apply the hack from #1513 (comment 826647)

    • I guess this is not an RDNA 2 exclusive issue then. Maybe the title should be changed then.

    • As of Fedora 38 this issue is still appearing, although it no longer occurs in SDDM with the default settings.

    • Please register or sign in to reply
  • This can be reproduced with any wayland compositor using the atomic API, but not with the legacy API. Or not using hardware cursor planes with the atomic API. I have a 6600 XT, are there logs I can provide or some patches I could try to help solve this bug?

    Edited 7 months ago by llyyr
  • Coming from an AMD RX 590 where I have had no problems, I encountered this yesterday when I installed my new RX 6800 XT. As a temporary fix I set Option "SWCursor" "True" in the X11 config, but ideal would of course be if this bug could be resolved.

    For info: using KDE Plasma 5.27.4 in X11 on Linux 6.1.25

  • This is happening to me as well, I have a 6700 XT, and can say that it's most likely something to do with atomic mode setting as turning it off using KWIN_DRM_NO_AMS fixes the issue although causes other issues. I would be happy to try out any patches or provide logs.

    System Info:

    Edited 6 months ago by Toby
  • Same problem here on an RX 6600. Operating System: Gentoo Linux 2.13

    KDE Plasma Version: 5.27.5

    KDE Frameworks Version: 5.106.0

    Qt Version: 5.15.9

    Kernel Version: 6.3.6-tkg-cfs-llvm (64-bit)

    Mesa Version: 23.1.1

    Graphics Platform: Wayland

    Processors: 12 × AMD Ryzen 5 5600G with Radeon Graphics

    Memory: 15.4 GiB of RAM

    Graphics Processor: AMD Radeon RX 6600

    Edited 6 months ago by Avraham Hollander
    • I've done some experimenting on GNOME as some users reported not experiencing this issue on RNDA2 when they are on GNOME and I can consistently get the cursor to display correctly but when you cause the screen to flicker by changing resolution or refresh rate the cursor gets the wrong gamma. A reboot will get the cursor to display correctly again.

      Edited 6 months ago by Toby
    • Can you run drm_info while GNOME is displaying the cursor correctly, and attach the output here?

    • Thanks for providing the file. Did you also have the intermittent issue or is it just working constantly?

      And I haven't noticed it render properly since that message, so unfortunately I haven't been able to generate my own DRM info yet.

    • I haven't used it long enough to figure out whether it was intermittent or not.

    • AFAICT the HW cursor isn't being used, which would explain why the cursor looks correct.

      There may be a message from mutter in the journal about why it fell back to SW cursor.

    • I wasn't able to find anything in the journal myself, is there something specific I need to run?

      Edited 6 months ago by Toby
    • or just

      and search for messages from gnome-shell.

    • This is what I got from restarting and then causing it to back to the hardware cursor. Also now that you've mentioned it I can feel that it is a software cursor.

      Edited 6 months ago by Toby
    • Maybe the cursor was just hidden when drm_info ran, e.g. because the terminal hid the cursor while typing.

    • Please register or sign in to reply
    • Are there any known workarounds for this issue with GNOME/Mutter? I'm using Fedora Workstation with Wayland and setting the KWIN_DRM_NO_AMS=1 variable seems to work sometimes (although I doubt it is actually causes the cursor to render correctly, as it is a KWIN variable).

      Edited 6 months ago by Seth MB
    • Try MUTTER_DEBUG_FORCE_KMS_MODE=simple or MUTTER_DEBUG_ENABLE_ATOMIC_KMS=0

    • Thanks for the suggestions. I tried both of these variables separately, to no luck (or change).

    • Please register or sign in to reply
    • The same issue with cursor shape/colors changing also started happening on my desktop computer (running GNOME Wayland session with AMD RX 6600 XT GPU) since upgrading to Fedora 38. I have originally reported it here. It happens almost every time after user login and sometimes even directly in GDM. When this happens, the incorrect cursor stays the same between logins and the only way to get rid of it is a reboot.

      Here is how the bad mouse pointer theme looks like:

      I apologize for the bad quality, however I had to take an actual screen shot (with my phone :-)), because it is not possible to capture the incorrect cursor using software screenshot tools (it shows as a correct one). You can however still see the missing color gradient, bigger aliasing on the edges and a slightly different shape than the correct cursor.

      Here are drm_info outputs from two sessions with bad cursor and two sessions with the correct one:

      drm_info_bad_cursor

      drm_info_bad_cursor2

      drm_info_correct_cursor

      drm_info_correct_cursor2

      When doing diff between these logs, I have noticed that the GAMMA_LUT value is always different between bad and correct sessions, but stays the same when comparing two correct or two bad sessions.

      bad cursor session:

      correct cursor session:

      It is always at 123 when the cursor is bad and at 117 when the cursor is correct.

      Here is my system hardware configuration:

      hwinfo.txt

      dmidecode.txt

      I have also noticed that the same issue happens when booting a live Fedora 38 iso on this machine (but does not happen on my other machines with Intel and NVIDIA GPUs), so it is not a problem related to my local system/software configuration.

      Here is a complete journal boot log from the Fedora 38 live system with the cursor bug also reproduced:

      log.txt

      Edited 5 months ago by AsciiWolf
    • I have already mentioned that the bad cursor is not present on screenshots. I forgot to add that when recording a screencast using the integrated GNOME screencast tool, the cursor also changes to a correct one and changes back to the incorrect one after the recording gets stopped. When selecting not the whole screen, but only a screen area for the recording, it gets even more interesting: The cursor inside this area is a correct one, but changes to a wrong one when exiting the area. I have made a recording using my phone camera:

      cursor

      It is not a very good quality recording, however there is clearly visible how the cursor changes on its edges + there was a moment or two when there actually were two cursors displayed for a short time.

      Edited 5 months ago by AsciiWolf
    • AFAIK this is because mutter uses SW cursor during screen grabbing.

    • I have also noticed that if I turn off my monitor for an extended period of time (for example overnight), the cursor also often changes to an incorrect one.

    • Please register or sign in to reply
    • Two years on and this is still an issue. 7900XTX.

      Very annoying, happens with any wlroots based compositor. The only fix is to force software cursors which is a workaround not a proper solution.

      I will note that in addition, the image is scaled very poorly and looks very aliased compared to rendering it in software.

    • Yeah, this has existed for way too long. Is AMD directly responsible for fixing this? I might get in touch with someone over there.

    • Since software cursors fix it and hardware cursors are handled by the GPU I can't see it being able to be fixed by anyone else.

      edit: And there is a patch that looks like it works here: #1513 (comment 826647) it just hasn't been applied

      Edited 5 months ago by Tom Butler
    • Is the issue really two years old? It did not happen for me on older Fedora releases, but started happening since Fedora 38. But yeah, this bug sadly is extremely annoying especially since it happens randomly, but really often, and usually requires several system reboots to disappear.

      Edited 4 months ago by AsciiWolf
    • this issue was created in March 2021 so over 2 years 😞

      Even a hacky kernel parameter to force the patch above would be better than nothing.

    • Ah, you are right about the ticket creation date. I wonder why it did not happen on my AMD system when using Fedora 37 or older. Maybe it also depends on an AMD GPU binary firmware version (shipped in Fedora as part of linux-firmware) or other system package that used to stay on older version before Fedora 38? But this is just a pure speculation.

    • I also wasn't running into it only on Fedora 37, all other distros i've tested were affected, but Fedora somehow wasn't, even with the same package versions and all that. I had checked the mutter patches that Fedora carries, but didn't notice anything interesting. So I am really not sure what has changed. Maybe something between Mutter (GNOME's compositor) v43 and v44?

      It can be worked around by setting the MUTTER_DEBUG_FORCE_KMS_MODE=simple env variable in /etc/environment and rebooting.

    • This issue isn't present with legacy gamma ramps, so perhaps mutter changed something between 43 and 44. While there may be dirty hacks compositors can apply to work around this issue, this still needs to be fixed in amdgpu itself.

      Just as a note, my patch in #2186 which uses the legacy API for setting the cursor, along with another patch that uses the legacy API for setting gamma does not fix this issue. So it probably isn't related to the API.

      Edited 5 months ago by llyyr
    • Any chance you could mention this also in the original GNOME ticket? Thanks!

    • I do not use GNOME so that would be irresponsible to do so since I can't verify it myself, I'm just repeating what has been said earlier by a KDE dev in this issue already and my own findings playing around with wlroots.

    • I've been seeing this since the very first day I installed my RX 6600 XT as an upgrade from an RX 580, which was on Solus Budgie in August 2021 - the bug continued to happen when I switched to Arch Budgie. It also happens on my Ryzen 5 6650U laptop, running EndeavourOS Budgie, and on my partner's Steam Deck in desktop mode, and my research project wlroots compositor. So yes, it's been happening for two years, and it's still happening on both X and Wayland on seemingly all RDNA2 and RDNA3 cards.

      Edited 5 months ago by Campbell Jones
    • As an addendum to the above, I've heard through the grapevine that this was also an issue with RDNA2 cards on Windows at some point before being resolved. That implies that this is a hardware quirk that requires special handling. I don't have any evidence for this, though - it's just hearsay.

    • It can be worked around by setting the MUTTER_DEBUG_FORCE_KMS_MODE=simple env variable in /etc/environment and rebooting.

      That's only helpful if you're on mutter, it looks like WLR_DRM_NO_ATOMIC=1 should work for wlroots based compositors but it's not for me on Wayfire.

    • It looks like that adding MUTTER_DEBUG_FORCE_KMS_MODE=simple to /etc/environment did work around the issue on my Fedora Workstation 38 (GNOME Wayland) system. Thanks a lot! :-)

    • Does MUTTER_DEBUG_FORCE_KMS_MODE=simple cause issues like KWIN_DRM_NO_AMS does on KDE?

    • @tobyg I've seen people mentioning issues with KWIN_DRM_NO_AMS but no one ever gave me examples of those issues. Are you aware of any in particular?

    • Please register or sign in to reply
    • If it's of any use, this is the hardware cursor on Steam Deck. You can try each cursor by hovering over it in the cursor appearance settings dialog. The dark cursor is hardware, the preview behind it shows the correct colors/gamma you would see in software mode:

    • That is pretty insane that this is also affecting the Steam Deck, I wonder if talking to Valve could get someone to look into this as I know that they contract developers to work the AMDgpu driver.

    • @tobyg Yeah, that's a good idea. If enough people complain there, they might get someone to look into it.

    • It seems we need to change the base for DGM/RGM in the atomic gamma of the kernel-driver. Can you compile/install a custom kernel and test the change suggested by this patch:0001-drm-amd-display-set-SRGB-as-a-base-to-avoid-too-dark.patch?

    • @mwen Hey, thanks for the patch, it seems to make the Breeze cursor gray (as it should be) on KDE Wayland without having to use legacy modesetting or a software cursor.

      This is on a desktop with an RX 6800, but i'd imagine it would also solve it for the Steam Deck, considering it also has an RDNA2 GPU.

      Edited 4 months ago by Kostadin
    • @kostadinsh are you sure you tested correctly? It doesn't seem to fix the issue for me on 6600 XT, which is also an RDNA2 gpu :(

      edit: apparently after this patch, the issue is only reproducible on wlroots-based compositors. no idea why

      Edited 4 months ago by llyyr
    • @llyyr The patch doesn't work on GNOME Wayland either, I believe I applied the patch correctly so not sure why.

      To add I'm using a 6700 XT.

      edit: Tested it on KDE Wayland and cursor appears as it should.

      Edited 4 months ago by Toby
    • @mwen's patch did the trick for me on KDE/X11, FWIW; thanks!

    • Great news that this seems to be working to some people. Any hopes of this being merged? Is it a proper fix, or a hack?

    • So, is this fix only for KDE or does it also work on other DEs including GNOME?

    • From reports, it seems to only address the issue for KDE.

      It's not the proper fix yet, I'm still investigating. Thanks.

      Edited 4 months ago by Melissa Wen
    • Very likely this is the proper fix: 0001-drm-amd-display-set-cursor-degamma-on-DCN3-only-if-i.patch

      Let me know the result on your desktop environment (don't forget to discard the previous patch). Thanks.

      Edited 4 months ago by Melissa Wen
    • @mwen: Yup, that one also works over here! (KDE/X11 on a 7900 XTX)

    • @mwen Thanks! that fixes it for me on RDNA2 on wlroots-based compositors

    • @mwen Works on both KDE and GNOME Wayland, thanks!

    • Hi all, this patch was accepted and applied to AMD and stable trees. Can we close this issue?

    • That's great news! :-) Thanks a much for your great work Melissa and other folks from Igalia!

    • Thank you Melissa - great work!

    • Just upgraded to 6.4.11, and my cursor gamma is fixed on Budgie (X11)! Thanks Melissa 😄

    • I now seem to have a very strange, opposite issue on my Fedora 38 system. My mouse pointer (on GNOME Wayland) looks too bright after updating to kernel 6.4.11. :-)

      (Sorry for the bad quality. It is an actual photo since the cursor looks correct on a screenshot.)

      Here is a drm_info output: drm_info_bright_cursor

      Both the GAMMA_LUT and GAMMA_LUT_SIZE values seem to be correct, so I am not sure what is wrong.

      Anyway, it is not annoying like the previous issue and seems to stay the same between reboots (unlike the previous issue), so I consider it a minor issue when compared to the original one. :-)

    • ugh 😞 I have an idea of what is the missing part: I guess the sRGB degamma in the legacy mode doesn't apply to cursor (only to other planes) and I need to enable cursor degamma separately for the legacy case. But let me examine the legacy path a little more to have a better idea that it's not just a workaround.

      Thanks @asciiwolf and @Zamundaaa for reporting.

    • FWIW, I'm continuing this discussion at #2803 (closed)

    • Please register or sign in to reply
Please register or sign in to reply
Assignee
Milestone
Due date
Time tracking
No estimate or time spent
Confidentiality
Not confidential
40 Participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK