pop-os / cosmic-comp

Compositor for the COSMIC desktop environment
GNU General Public License v3.0
480 stars 86 forks source link

XWayland windows blurry with 2x scaling #370

Closed ids1024 closed 1 month ago

ids1024 commented 6 months ago

This might have been discussed before, but I don't see an issue.

With 2x scaling, XWayland clients like xterm are scaled up 2x by the compositor, but seem blurry. Compared to Sway where the text is much sharper (if worse than hidpi apps).

Maybe an off-by-one error somewhere in the scaling logic, preventing bilinear scaling from producing clean results.

skygrango commented 6 months ago

Is there any chance we can implement "Apply scaling themselves" solution like KDE?

it works very well

note : https://pointieststick.com/2022/06/17/this-week-in-kde-non-blurry-xwayland-apps/

ids1024 commented 6 months ago

Interesting that KDE is considering making that option the default. Ideally it might be per-app, since some X apps might not support scaling natively, and not having scaling with something like a 4k 13 inch laptop is pretty hard on the eyes.

With native Wayland apps this isn't an issue since they can communicate to the server that they're handling scaling. Including fractional scaling with the fractional-scale-v1 protocol.

Anyway, I'm ot sure exactly what's wrong here. render_texture_from_to seems to be passed the correct arguments. I expected changing LINEAR to NEAREST for the min and mag filters to prevent things from looking blurred, but that doesn't seem to?

Drakulix commented 6 months ago

Is there any chance we can implement "Apply scaling themselves" solution like KDE?

it works very well

note : https://pointieststick.com/2022/06/17/this-week-in-kde-non-blurry-xwayland-apps/

Not sure if it will be the default, but this is definitely something we want to implement at some point.

Drakulix commented 6 months ago

Anyway, I'm ot sure exactly what's wrong here. render_texture_from_to seems to be passed the correct arguments. I expected changing LINEAR to NEAREST for the min and mag filters to prevent things from looking blurred, but that doesn't seem to?

OpenGL has fractional coordinates, maybe this is one of the cases, where we need to offset the rendered texture by 0.5?

ids1024 commented 6 months ago

True, it could be off by 0.5. I'm not sure exactly what the nearest-neighbor scaling does with texture coordinates exactly between two pixels. Or it may the be vertex coordinates that are off.

ryanabx commented 5 months ago

So it's not intended for xwayland windows to be blurry with 2x scaling? I thought that was due to the lack of the KDE-like solution from https://pointieststick.com/2022/06/17/this-week-in-kde-non-blurry-xwayland-apps/

Drakulix commented 5 months ago

They are blurrier than they should be given we use NEAREST for filtering basically.

ryanabx commented 5 months ago

Ah I see

ryanabx commented 4 months ago

Thinking about this today -- what are some things I could test to try and fix this issue?

OpenGL has fractional coordinates, maybe this is one of the cases, where we need to offset the rendered texture by 0.5?

True, it could be off by 0.5. I'm not sure exactly what the nearest-neighbor scaling does with texture coordinates exactly between two pixels. Or it may the be vertex coordinates that are off.

Perhaps one of these things?

dvtfl commented 1 month ago

Setting scale by the apps themselves (#779) has been added: https://github.com/pop-os/cosmic-comp/commit/971c28db386df835eb389dad66f4f48b60c88c15 However, there is no GUI setting for this yet (at least, I couldn't find one). You can enable it manually by running:

echo 'true' > ~/.config/cosmic/com.system76.CosmicComp/v1/descale_xwayland
mmstick commented 1 month ago

@dvtfl The GUI setting is in cosmic-settings on the display settings page