You are not logged in.

#1 2022-08-29 21:33:36

erganemic
Member
Registered: 2022-08-29
Posts: 1

Is it possible to have a mixed DPI setup on X without blurriness?

Has anyone solved the problem of anti-aliasing/blurriness (especially on text) for the upscaled monitor in a mixed DPI setup?

Putting specs up front:
3840x2160, ~162 DPI monitor on the right (DVI-D-0)
1920x1080, ~92 DPI monitor on the left (HDMI-0)
Kernel Version 5.15.61-1-lts
Nvidia driver version 515.65.01 with a GeForce GTX 1070

I recently got a UHD monitor as part of a remote work package from the company I work for. Once I set all the relevant scaling factors (GDK_SCALE=2, GDK_DPI_SCALE=0.5, Xft.dpi set appropriately, etc), all the UI elements on the 4k display were super crisp and at a comfortable scale (a little too big maybe, but not so annoying I was going to mess around with fractional scaling).

Of course, this meant the UI scale was way too big on the 1920x1080 display. I started looking into how people deal with this and reading the HiDPI wiki page, and eventually came up with this command (which is very explicit, for clarity):

xrandr --fb 7680x2160 --output HDMI-0 --scale 2 --mode 1920x1080 --pos 0x0 --output DVI-D-0 --mode 3840x2160 --pos 3840x0

Explaining this, so someone can correct me if I'm wrong, this:

  • Sets a virtual framebuffer of size 7680x2160, so X renders things like it's going to output to a native 7680x2160 display

  • Uses a scale factor of 2 for HDMI-0, so that although the portion of the virtual framebuffer that the left screen is responsible for is 3840x2160 pixels, this information is "scaled down", so that the output to HDMI-0 fits on a 1920x1080 monitor

  • However, since the "scaling" of xrandr takes place after the calculations have already been done to draw applications at the scale they'd be at on a 3840x2160 screen, the scale of the UI on the left FHD monitor is the same as it is on the right UHD monitor.

This works, and everything is the right size, but on the left FHD monitor, text appears blurry. As far as I understand, this is due to the fact that when graphics are rendered at 3840x2160 and then scaled down, this might not always be done perfectly: for example, if a font is 31px high at 3840x2160 (for some reason), it isn't possible to scale that to 15.5px at 1920x1080. This introduces antialiasing problems and a general loss of crispness.

Is there a way to fix this? This StackExchange post seemed like it had some good suggestions, giving variations of the above command that used `panning` in combination with `scale`, or used `transform` in its place--the latter of which specifically called out the problem I'm seeing, and claimed to fix it. However, both of those produce seemingly identical results to my original command. What's more, a further-down answer claims that mixed DPI isn't possible at all on X without some compromise. Does anyone know of a fix, or is this just not possible due to the nature of bitmap graphics? At this point, I might just end up running both monitors at 1920x1080.

Last edited by erganemic (2022-08-29 21:36:01)

Offline

#2 2022-08-30 02:13:20

miliarch
Member
Registered: 2022-08-30
Posts: 1

Re: Is it possible to have a mixed DPI setup on X without blurriness?

If I understand the problem correctly, it's that the smaller display (1920x1080), when downscaled by 2x, has blurry text. Now, I'm not sure whether my blurry text acceptance threshold matches yours, but I've found a solution that I find acceptable (though certainly not perfect) in my similar environment that I'm happy to share.

Environment:
- Left monitor: 3840x2160 (28")
- Right monitor: 1920x1080 (24")
- Window manager: awesomewm
- Greeter: lightdm

Script:

#!/bin/bash
#https://www.reddit.com/r/awesomewm/comments/i8le9t/how_do_i_configure_scaling_in_a_multimonitor/
xrandr --dpi 144
xrandr --output DisplayPort-1 --mode 3840x2160 --pos 0x0 --scale 1x1
xrandr --output DisplayPort-0 --mode 1920x1080 --pos 3840x270 --scale 1.33x1.33

There's great information about what each of those parameters do, and why to use them, in the commented reddit thread.

The main difference I see between what I use, and what you shared, is that scale factor is much lower in my setup (1.33x scale instead of 2x), resulting in a downscaled resolution of ~2554x1436 as opposed to 3840x2160. I use that value because to scale higher makes text and UI components much too small for me to read and use effectively, and it seems to provide a good middle-ground of image quality and screen-space. I do notice more blurring in general as scale factor increases. Being locked to a single DPI across both displays is the real kicker here.

I also define Xft.dpi to the same value in ~/.Xresources.

I'm not using the GDK_SCALE or GDK_DPI_SCALE variables generally. I have used GDK_SCALE in the past with steam, as the client has scaling issues - but only when launching that program.

I previously launched the script in my awesome/rc.lua, but have since moved to doing that init work with lightdm greeter (display-setup-script option), and only doing an xrdb -merge ~/.Xresources in awesome/rc.lua. I'm not sure if any of that will be applicable to your window manager/greeter, but hopefully some extra info on implementation helps.

Good luck to you in your search for an acceptable configuration, and thanks for giving me a reason to register and post! I've been dealing with mixed scaling of my displays for quite a while, and even with acceptable solutions at my disposal, I sure would rather be able to run both displays at native scale.

Edit: For what it's worth, I prefer the result I get with my Arch installation to both my Windows and macOS installations with this same display set. There is at least one quality trade-off or mixed resolution/scaling UI behavior quirk in each case.

Edit 2: upscaled -> downscaled - thanks, seth!

Last edited by miliarch (2022-08-31 00:49:53)

Offline

#3 2022-08-30 06:04:43

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,491

Re: Is it possible to have a mixed DPI setup on X without blurriness?

You can try passing "--filter nearest" to the scale, no idea whether that's beneficial when *down*scaling, though.
ftr, "--scale" is just a simplification of "--transform" that operates on a factor instead of a matrix.

Offline

Board footer

Powered by FluxBB