ValveSoftware / Dota-2

Tracker for issues specific to Linux and Mac in the Reborn client. If you have a general issue or non-system-specific feature request please go to dev.dota2.com
470 stars 38 forks source link

Add high-DPI support for Wayland on Linux #2008

Open vially opened 2 years ago

vially commented 2 years ago

Your system information

Please describe your issue in as much detail as possible:

Dota 2 does not officially support native Wayland currently (https://github.com/ValveSoftware/Dota-2/issues/999). However, it's fairly easy to get it working by either symlinking or using LD_PRELOAD to force the game to use a more recent version of libSDL.so which has native Wayland support.

Using either one of these two approaches (and setting the game launch options to SDL_VIDEODRIVER=wayland %command% -gl) succesfully starts the game natively under Wayland. However, this does not support high-DPI resolutions and the window is blurry as a result (see left-side screenshot in this comparison).

macOS already supports high-DPI resolutions by using the -highdpi command line option, but this argument doesn't seem to make any difference on Wayland/Linux.

This feature request is about enabling proper high-DPI support for Wayland on Linux. Ideally this should "just work" out-of-the box, or it could be hidden behind the -highdpi flag, similar to how it works on macOS.

For what it's worth, I did manage to make high-DPI work as expected on Wayland by patching SDL to fool Dota 2 into scaling the underlying buffer size correctly. The patch itself is pretty small but, obvioulsy, this is just a hack meant only as a proof-of-concept. However, this makes it look like it should be relatively straight forward to fix this properly from the Dota side.

This link shows a comparison of running Dota 2 natively under Wayland using upstream SDL on the left side and the hacked SDL on the right side (the slider is interactive and can be moved left and right to see the full images). Both screenshots were taken on the same 4k screen with an output scale factor equal to 2 (configured in the Wayland compositor).

Saroumane commented 2 years ago

@vially Interesting ! Have you noticed better performance (more fps, less latency ?) by running Dota2 in "native Wayland" mode, compared to XWayland ?

vially commented 2 years ago

@Saroumane I haven't noticed any difference in performance between native Wayland and XWayland but I haven't run any benchmarks to measure it either. For what it's worth I've been running it at 4k@120 Hz for a while now and I didn't notice any issues (except some bugs that also happened on X11/XWayland).

My main motivation for getting it working on Wayland (by patching SDL as mentioned above) was due to various issues related to high-DPI scaling on XWayland rather than performance.

Saroumane commented 2 years ago

@vially

Using either one of these two approaches (and setting the game launch options to SDL_VIDEODRIVER=wayland %command% -gl) succesfully starts the game natively under Wayland. However, this does not support high-DPI resolutions and the window is blurry as a result (see left-side screenshot in this comparison).

By the way, why do you use OpenGL instead of Vulkan ?

vially commented 2 years ago

By the way, why do you use OpenGL instead of Vulkan?

There is currently a bug which prevents Dota 2 from launching on Wayland when using Vulkan: https://github.com/ValveSoftware/Dota-2-Vulkan/issues/282. Hopefully it will get fixed at some point but it has been reported a while ago and it hasn't seen any activity yet.

SopaDeMacaco-UmaDelicia commented 6 months ago

Wayland native works in vulkan, but hidpi does not.

What's interesting another source 2 game (cs2) has correct resolutions in wayland-native mode.