Dota-2
Dota-2 copied to clipboard
Add high-DPI support for Wayland on Linux
Your system information
- System information from steam (
Steam
->Help
->System Information
): N/A - Have you checked for system updates?: Yes
- Are you using the latest stable video driver available for your system? Yes
- Have you verified the game files?: Yes
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).
@vially Interesting ! Have you noticed better performance (more fps, less latency ?) by running Dota2 in "native Wayland" mode, compared to XWayland ?
@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.
@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 ?
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.
Wayland native works in vulkan, but hidpi does not.
What's interesting another source 2 game (cs2) has correct resolutions in wayland-native mode.