Bug 472340 - OLED subpixel rendering support
Summary: OLED subpixel rendering support
Status: REPORTED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 474890 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-07-18 00:55 UTC by Álvaro M.
Modified: 2024-04-07 15:01 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
OLED font rendering, notice the borders (2.84 MB, image/jpeg)
2023-07-18 00:55 UTC, Álvaro M.
Details
Same text rendered in an LCD screen. (692.99 KB, image/jpeg)
2023-07-18 00:58 UTC, Álvaro M.
Details
Firefox favicon rendered in an OLED monitor (344.79 KB, image/jpeg)
2023-07-18 00:59 UTC, Álvaro M.
Details
Same favicon rendered in an LCD monitor (359.51 KB, image/jpeg)
2023-07-18 00:59 UTC, Álvaro M.
Details
This is an option from the KDE Settings window in an LED screen, no issues. (496.34 KB, image/jpeg)
2023-08-07 18:22 UTC, Álvaro M.
Details
This is an option from the KDE Settings window in an OLED screen, notice the extra pixel rendering to the left side (455.14 KB, image/jpeg)
2023-08-07 18:23 UTC, Álvaro M.
Details
This is a button from the KDE Settings window in an LED screen, no issues. (547.53 KB, image/jpeg)
2023-08-07 18:23 UTC, Álvaro M.
Details
This is a button from the KDE Settings window in an OLED screen, notice the extra pixels to the left (460.48 KB, image/jpeg)
2023-08-07 18:24 UTC, Álvaro M.
Details
OLED EDID (384 bytes, application/octet-stream)
2023-08-08 13:08 UTC, Álvaro M.
Details
OLED EDID (from Windows, using CRU) (384 bytes, application/octet-stream)
2023-08-09 15:50 UTC, Álvaro M.
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Álvaro M. 2023-07-18 00:55:07 UTC
Created attachment 160343 [details]
OLED font rendering, notice the borders

New OLED monitors don’t have either RGB nor RBG pixel settings. Right now, to give you an example, LG OLED gaming monitors have RWBG settings. This botched the way fonts are rendered on screen. See https://github.com/bp2008/BetterClearTypeTuner#issue-785450772 and https://github.com/microsoft/PowerToys/issues/25595#issue-1672314603 to see how people are trying to fix this in other platforms. 

And it seems it’s not only the font rendering, since images, vectors, and desktop components are rendered this way, too. 

STEPS TO REPRODUCE
1. Buy an LG OLED Gaming monitor
2. Cry

OBSERVED RESULT
Fonts are rendered uglier than in LCD monitors. Some color contrasts present some unexpected colors (yellow/orange over grey/black)

EXPECTED RESULT
Rendering should be akin to LCD monitors

SOFTWARE/OS VERSIONS
Windows: 11 (yes, it happens there too)
Linux/KDE Plasma: latest in Arch
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Álvaro M. 2023-07-18 00:58:11 UTC
Created attachment 160344 [details]
Same text rendered in an LCD screen.
Comment 2 Álvaro M. 2023-07-18 00:59:00 UTC
Created attachment 160345 [details]
Firefox favicon rendered in an OLED monitor
Comment 3 Álvaro M. 2023-07-18 00:59:35 UTC
Created attachment 160346 [details]
Same favicon rendered in an LCD monitor
Comment 4 Zamundaaa 2023-08-07 11:55:18 UTC
KWin doesn't deal with font or icon rendering. Please redirect this feature request to FreeType and Firefox respectively
Comment 5 Álvaro M. 2023-08-07 18:18:51 UTC
(In reply to Zamundaaa from comment #4)
> KWin doesn't deal with font or icon rendering. Please redirect this feature
> request to FreeType and Firefox respectively

Regarding fonts: I agree, will talk with freetype and fontconfig.

Regarding colors: I disagree, since this not only happens in firefox, but the whole desktop's colors. I've uploaded the same issue in the KDE settings window, to give you an example.
Comment 6 Álvaro M. 2023-08-07 18:22:26 UTC
Created attachment 160803 [details]
This is an option from the KDE Settings window in an LED screen, no issues.
Comment 7 Álvaro M. 2023-08-07 18:23:19 UTC
Created attachment 160804 [details]
This is an option from the KDE Settings window in an OLED screen, notice the extra pixel rendering to the left side
Comment 8 Álvaro M. 2023-08-07 18:23:51 UTC
Created attachment 160805 [details]
This is a button from the KDE Settings window in an LED screen, no issues.
Comment 9 Álvaro M. 2023-08-07 18:24:35 UTC
Created attachment 160806 [details]
This is a button from the KDE Settings window in an OLED screen, notice the extra pixels to the left
Comment 10 Zamundaaa 2023-08-07 21:51:57 UTC
KWin still doesn't render icons... It doesn't render anything in the windows you see.

There are some necessary changes to allow apps to handle this properly though. Here's a list of what needs to happen for this to be potentially supported:
- the kernel needs some way of identifying displays with these special subpixel layouts, and it needs to pass that information to userspace
- libdrm should be updated to add a value to the currently broken subpixel enum (https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/317)
- Wayland needs to be updated to add a value to its subpixel enum
- KWin needs to be updated to pass the subpixel enum from the kernel along to clients

That's all the things that are relevant for KWin. If you want icons to be rendered with the subpixel layout in mind (idk if that's even a thing right now), then you also need to get Qt, GTK, Firefox, Chromium and whatever toolkit/application you're using to handle that. And for fonts ofc, FreeType as well as the projects using it need to be adjusted to support the subpixel layout.
Comment 11 Bug Janitor Service 2023-08-07 22:07:40 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4303
Comment 12 Álvaro M. 2023-08-07 22:19:50 UTC
(In reply to Zamundaaa from comment #10)
> KWin still doesn't render icons... It doesn't render anything in the windows
> you see.
> 
> There are some necessary changes to allow apps to handle this properly
> though. Here's a list of what needs to happen for this to be potentially
> supported:
> - the kernel needs some way of identifying displays with these special
> subpixel layouts, and it needs to pass that information to userspace
> - libdrm should be updated to add a value to the currently broken subpixel
> enum (https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/317)
> - Wayland needs to be updated to add a value to its subpixel enum
> - KWin needs to be updated to pass the subpixel enum from the kernel along
> to clients
> 
> That's all the things that are relevant for KWin. If you want icons to be
> rendered with the subpixel layout in mind (idk if that's even a thing right
> now), then you also need to get Qt, GTK, Firefox, Chromium and whatever
> toolkit/application you're using to handle that. And for fonts ofc, FreeType
> as well as the projects using it need to be adjusted to support the subpixel
> layout.

Thanks for such a detailed answer! I'll close the ticket, then.(In reply to Zamundaaa from comment #10)
> KWin still doesn't render icons... It doesn't render anything in the windows
> you see.
> 
> There are some necessary changes to allow apps to handle this properly
> though. Here's a list of what needs to happen for this to be potentially
> supported:
> - the kernel needs some way of identifying displays with these special
> subpixel layouts, and it needs to pass that information to userspace
> - libdrm should be updated to add a value to the currently broken subpixel
> enum (https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/317)
> - Wayland needs to be updated to add a value to its subpixel enum
> - KWin needs to be updated to pass the subpixel enum from the kernel along
> to clients
> 
> That's all the things that are relevant for KWin. If you want icons to be
> rendered with the subpixel layout in mind (idk if that's even a thing right
> now), then you also need to get Qt, GTK, Firefox, Chromium and whatever
> toolkit/application you're using to handle that. And for fonts ofc, FreeType
> as well as the projects using it need to be adjusted to support the subpixel
> layout.

Thank you for such a detailed answer. It's really overwhelming how many factors are involved for rendering into a monitor!

I'll close the ticket, then. Or should I move/open it somewhere else?
Comment 13 Nate Graham 2023-08-07 22:50:28 UTC
(In reply to Álvaro M. from comment #12)
> Thank you for such a detailed answer. It's really overwhelming how many
> factors are involved for rendering into a monitor!
You said it. Frankly I find it amazing that anything ever works at all.
Comment 14 Zamundaaa 2023-08-08 09:25:57 UTC
Git commit 2541e3fbe07e74d7bae1b614f13579e9735b58f1 by Xaver Hugl.
Committed on 08/08/2023 at 11:12.
Pushed by zamundaaa into branch 'master'.

backends/drm: don't assume we never get new subpixel types

M  +3    -3    src/backends/drm/drm_connector.cpp

https://invent.kde.org/plasma/kwin/-/commit/2541e3fbe07e74d7bae1b614f13579e9735b58f1
Comment 15 Bug Janitor Service 2023-08-08 10:24:04 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4305
Comment 16 Zamundaaa 2023-08-08 10:38:28 UTC
Git commit e4b2811f78691c2b727cdb61d533a29ddd802028 by Xaver Hugl.
Committed on 08/08/2023 at 12:23.
Pushed by zamundaaa into branch 'Plasma/5.27'.

backends/drm: don't assume we never get new subpixel types


(cherry picked from commit 2541e3fbe07e74d7bae1b614f13579e9735b58f1)

M  +3    -3    src/backends/drm/drm_connector.cpp

https://invent.kde.org/plasma/kwin/-/commit/e4b2811f78691c2b727cdb61d533a29ddd802028
Comment 17 Zamundaaa 2023-08-08 11:35:53 UTC
> I'll close the ticket, then. Or should I move/open it somewhere else?

I think it would be reasonable to keep this open until the part that needs changing in KWin is done.

Could you please attach the edid of your monitor here? You should be able to fetch it with something like
cat /sys/class/drm/card0/card0-DP-1/edid > edid.bin
(card number and connector name may need adjusting)
Comment 18 Álvaro M. 2023-08-08 13:08:12 UTC
Created attachment 160830 [details]
OLED EDID
Comment 19 Zamundaaa 2023-08-09 12:43:44 UTC
Looks like your monitor doesn't actually say anything about the subpixel layout, which slightly complicates the issue
Comment 20 Álvaro M. 2023-08-09 15:50:57 UTC
Created attachment 160870 [details]
OLED EDID (from Windows, using CRU)
Comment 21 Álvaro M. 2023-08-09 15:52:54 UTC
(In reply to Zamundaaa from comment #19)
> Looks like your monitor doesn't actually say anything about the subpixel
> layout, which slightly complicates the issue

I got into windows and dumped the EDID (uploaded to the ticket), which seems to be parseable using https://people.freedesktop.org/~imirkin/edid-decode/

I think this also doesn't say it's RWBG (WOLED)?
Comment 22 Zamundaaa 2023-08-09 17:08:03 UTC
Indeed. I know that Windows drivers already have data bases for other missing information in EDIDs, so presumably they "fix" the problem for subpixel layouts with that too... I guess we have one more reason to make such a data base ourselves as well.
Comment 23 Zamundaaa 2023-09-26 12:08:37 UTC
*** Bug 474890 has been marked as a duplicate of this bug. ***