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
471 stars 38 forks source link

Dota on wayland with SDL_VIDEO_DRIVER=wayland #999

Open konstantinblaesi opened 8 years ago

konstantinblaesi commented 8 years ago

Is it possible to run dota natively on wayland by exporting SDL_VIDEODRIVER=wayland ? I get these errors and the game doesn't start:

Unable to create dummy window for GLMDisplayDB.gl/togl/glmdisplaydb.cpp 792 InitializeDisplayDB(): Unable to create dummy window for GLMDisplayDB.

gdrewb-valve commented 8 years ago

It doesn't look like that works, but assigning to the SDL dev.

konstantinblaesi commented 8 years ago

@rcgordon Is it possible? Are there plans to make it possible in the near future?

Tele42 commented 8 years ago

From what I can gather over at the togl repo, togl assumes it can enumerate displays with glx stuff, but glx is not implicitly available with wayland, since it's using egl instead of glx for those kind of things. I could be wildly wrong here as the referenced function does not exist on github, but that's the general feel of what is there.

gdrewb-valve commented 8 years ago

The particular call failing here is SDL_CreateWindow so the failure is inside of SDL. I believe the issue is that the SDL shipped with Dota doesn't have Wayland support but I'm not sure if that's an oversight or a limitation of the Steam runtime, thus this is assigned to the SDL dev to work out.

Tele42 commented 8 years ago

@gdrewb-valve, thanks for the insight. With that information, I got the game running in weston (with SDL_VIDEODRIVER=wayland).

I had to remove the game-bundled libSDL2 and built libSDL2-2.0.4 with wayland and gles among the other common build options. As always, I'm using Gentoo linux w/o the steam runtime.

This confirms your hypothesis that the steam runtime and/or .../common/dota 2 beta/game/bin/linuxsteamrt64/libSDL2-2.0.so.0 is missing wayland support.

As a side note, my wayland test hardware is hopelessly underpowered for this task and I can not do a comprehensive test, but the main menu and watching a match work.

Plagman commented 8 years ago

Togl isn't used in Reborn, btw.

Tele42 commented 8 years ago

@Plagman, right, I had momentarily forgotten, then was mislead by this part of the terminal output:

gl/togl/glmdisplaydb.cpp 792 InitializeDisplayDB():
konstantinblaesi commented 8 years ago

@Tele42 is STEAM_RUNTIME=0 required? If yes, can you explain how to do this on gentoo? I use gentoo as well, but with STEAM_RUNTIME=0 steam crashes because of missing libraries. If you have a list of libraries that need abi_x86_32 USE that would be nice.

Tele42 commented 8 years ago

@elxa, STEAM_RUNTIME=0 is most likely is not required, but loading a version of libSDL2-2.0.so.0 that has wayland support built into it is required.

If you want to use steam without the steam runtime on Gentoo, set USE="-steamruntime" in the various packages from the overlay. If that is not available, switch to the steam-overlay package overlay. This will pull in the needed dependencies. NOTE: Using steam without the steam runtime means that all dependency issues have to be handled by the package maintainer, not valve.

konstantinblaesi commented 8 years ago

@Tele42 how do you load that library? I was already using the steam-overlay and just rebuilt with USE=-steamruntime, but that didn't make a difference. In ~/steam/steamapps/common/dota 2 beta/game/bin/linuxsteamrt64 I created this symlink:

libSDL2-2.0.so.0 -> /usr/lib64/libSDL2-2.0.so.0

Do you LD_PRELOAD it ?

media-libs/libsdl2-2.0.4::gentoo was built with the following:
USE="X dbus gles joystick opengl pulseaudio sound threads udev video wayland xinerama -alsa (-altivec) (-custom-cflags) (-fusionsound) -haptic -nas -oss -static-libs -tslib -xscreensaver" ABI_X86="32 64 -x32" CPU_FLAGS_X86="mmx sse sse2 -3dnow"
CFLAGS="-pipe -march=native -O2"
CXXFLAGS="-pipe -march=native -O2"

I am still getting the same error from the first post. Do you think me using gnome 3 instead of pure wayland might complicate things?

Tele42 commented 8 years ago

@elxa, on my wayland test system, the system libSDL2-2.0.so.0 is the only one available on that system, so the dynamic loader only had one choice to pick from.

What do you mean by "using gnome 3 instead of pure wayland?" There is no such thing as "pure wayland" as it is a protocol spec, there is no centralized required wayland server software. If the Gnome 3 session is running as a wayland compositor, then it should not be a complication. If the Gnome 3 session is running as the common X11 compositor, then there's nothing for libSDL's wayland backend to talk to.

konstantinblaesi commented 8 years ago

@Tele42 I am running a wayland gnome (3.20) session and was wondering if Xwayland could confuse dota. I added LD_DEBUG=libs to dotas startup options and despite steam saying

STEAM_RUNTIME is disabled by the user

dota seems to load the libSDL from the runtime directory?

      5723: find library=libSDL2-2.0.so.0 [0]; searching
      5723:  search path=/home/konstantin/steam/steamapps/common/dota 2 beta/game/bin/linuxsteamrt64        (RPATH from file /home/konstantin/steam/steamapps/common/dota 2 beta/game/bin/linuxsteamrt64/dota2)
      5723:   trying file=/home/konstantin/steam/steamapps/common/dota 2 beta/game/bin/linuxsteamrt64/libSDL2-2.0.so.0

I created this symlink though, so it shouldn't matter?

/home/konstantin/steam/steamapps/common/dota 2 beta/game/bin/linuxsteamrt64/libSDL2-2.0.so.0' -> /usr/lib64/libSDL2-2.0.so.0
konstantinblaesi commented 8 years ago

@Tele42 I just made tests from weston/wayland instead of gnome/wayland and it worked! All I needed (as you discovered already) was to swap the libSDL2 build bundled with the game (libSDL2-2.0.so.0 in .../steamapps/common/dota 2 beta/game/bin/linuxsteamrt64 ) against my system libSDL2, which was built as mentioned in https://github.com/ValveSoftware/Dota-2/issues/999#issuecomment-244499081 . When running in gnome/wayland the same steps that work in weston/wayland produce the error message mentioned in https://github.com/ValveSoftware/Dota-2/issues/999#issue-172321163 and a popup with the same error message as displayed in the terminal (The game doesn't start). Until now I was running dota with my IGPU (i7-6700K, Intel® HD Graphics 530, Skylake), but I have an AMD RX 480 waiting to get tested, too. On my IGPU I get stable 59fps (I set "fps_max 60") with gnome/X11. On weston/wayland I got only 30-50fps with and without SDL_VIDEODRIVER=wayland . Now I wonder

BernardoGO commented 8 years ago

Are you guys starting a session using weston or using it trough gnome?

konstantinblaesi commented 8 years ago

Anything wayland wise started via gdm didn't let me run dota.

mastercoms commented 7 years ago

I tried with the latest GNOME 3.23 release and it is working. However, fonts don't load properly and use a fallback font.

konstantinblaesi commented 6 years ago

Finally got it working on Fedora 28 From a terminal execute as the user running your steam games:

# Backup the libSDL shipped by steam
mv ~/.steam/root/steamapps/common/dota\ 2\ beta/game/bin/linuxsteamrt64/libSDL2-2.0.so.0 ~/.steam/root/steamapps/common/dota\ 2\ beta/game/bin/linuxsteamrt64/libSDL2-2.0.so.0.backup
# Symlink dota 2 libSDL to the system level libSDL
ln -s /lib64/libSDL2-2.0.so.0 ~/.steam/root/steamapps/common/dota\ 2\ beta/game/bin/linuxsteamrt64/libSDL2-2.0.so.0

In the steam client set launch options to SDL_VIDEODRIVER=wayland %command%

Question to dota 2 devs: Can you enable wayland support in the shipped libSDL ?

konstantinblaesi commented 6 years ago

Another Fedora 28 user reported that he didn't have to do any of the above steps to make it work. I am now wondering whether libSDL wasn't updated by the steam client on my machine?

konstantinblaesi commented 6 years ago

On Fedora 28 using Gnome 3.28: When using Alt + Tab to switch focus to another window I cannot get the focus back to Dota 2. When Dota 2 is focused I hear the In-Game sounds, but I don't see anything visually from the client.

konstantinblaesi commented 6 years ago

It looks like the Desktop-friendly Fullscreen mode doesn't work. Borderless Window mode doesn't have this issue.

konstantinblaesi commented 6 years ago

After switching modes and restarting the dota 2 client the issue disappeared. Not sure why and how long this will last...

konstantinblaesi commented 6 years ago

When will you start shipping libSDL with wayland support enabled? A recent dota update once again killed my symlink to the Fedora 29 system level libSDL which has wayland support :( I have been playing using native wayland (no xwayland) without issues for months now. The only thing that's messed up is the steam overlay, but I can (mostly) live with that.

nanonyme commented 6 years ago

I'm to be honest wondering whether Steam overlay even can work with Wayland. With Wayland there's afaik stricter ownership of surfaces and I wouldn't take it for granted Steam can draw on top of fullscreen apps

nanonyme commented 6 years ago

@konstantinblaesi does LD_PRELOAD=/path/to/libSDL help as a workaround or do you really need to replace that file?

konstantinblaesi commented 6 years ago

@nanonyme LD_PRELOAD=/lib64/libSDL2-2.0.so.0 works, too. I've updated my dota 2 start options to LD_PRELOAD=/lib64/libSDL2-2.0.so.0 SDL_VIDEODRIVER=wayland DRI_PRIME=1 %command% (intel iGPU + amd dGPU)

simvux commented 5 years ago

I'm having this issue despite preloading the required libSDL2 system library, not sure why my issue was closed since the issue is referenced here as "use this workaround" when i explicitly pointed out that the workaround did not work.

konstantinblaesi commented 5 years ago

@AlmightyFloppyFish Unlikely, but what if your distributions libSDL is compiled without wayland support? Probably not the right way to check but does the command strings /lib/libSDL2-2.0.so.0 | grep SDL_VIDEODRIVER have a non empty result? I am using Fedora 29 with wayland and dota 2 still works perfectly.

simvux commented 5 years ago

strings /lib64/libSDL2-2.0.so.0 | grep SDL_VIDEODRIVER results in the output SDL_VIDEODRIVER

You sure this is sufficent to check? SDL2 also has Mir support iirc which would probably include that string even if i wasnt compiled with wayland support.

konstantinblaesi commented 5 years ago

No I don't know a proper way to check, but I get the same output as you.

simvux commented 5 years ago

I remembered that I myself have written some SDL2 applications but in Rust, tried to run them and got: thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "wayland not available"

So it does appear that my libSDL2 wasn't packaged with wayland support... Gonna try to manually compile it when i get the time, i'll update once i have in case others run into the same issue.

konstantinblaesi commented 5 years ago

You can check whether you have a wayland session with loginctl show-session $(loginctl | grep $(whoami) | awk '{print $1}') -p Type

Source https://unix.stackexchange.com/a/371164

simvux commented 5 years ago

That's not the issue here, I clearly have a wayland session considering I'm running sway, and as viewed in the steam information dump steam is running on xwlc which indicates xwayland (since the steam client does not run natively).

edit: also your command shows "type=tty", probably because I'm not using loginctl but rather runit+elogind and launch sway session from tty. (atleast i think that's how that works).

simvux commented 5 years ago

Manually compiling did not help, but i have discovered some weird behavior. Looking in steam log if i have /lib/libSDL2-2.0.so.0 preloaded, i get ERROR: ld.so: object '/lib/libSDL2-2.0.so.0' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored. and if i preload /lib32/libSDL2-2.0.so.0, i get ERROR: ld.so: object '/lib32/libSDL2-2.0.so.0' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.

So both 64 bit and 32 bit is wrong and therefore both get ignored? I'm unsure how to progress from here.

simvux commented 5 years ago

Not sure if anyone else is as interested as i am but a bit of an update,

Why manually compiling with Wayland support didn't work was because i only compiled for 64bit, but i needed to compile for both 64 bit and cross-compile it for 32 bit and then LD_PRELOADing just the name of the shared library instead of the full path for it to pick up both.

I'll be trying this when I get the time

nanonyme commented 5 years ago

Yeah, I think Valve pins their own libSDL2 with LD_LIBRARY_PATH, hence why you need LD_PRELOAD. I'm not sure if the pinning makes sense but there's a comment in the steam.sh that it was some bug fix.

romulasry commented 3 years ago

Update? Wayland should be able to work without LD_LIBRARY_PATH tomfoolery.

alexeysvrv commented 1 year ago

@kisak-valve @Plagman @gdrewb-valve Any update maybe? How is wayland support in the game? Are there any progress?

icculus commented 1 year ago

DOTA2 uses SDL3 now, shipped with the game, for those attempting to replace it.

alexeysvrv commented 1 year ago

@icculus So Dota 2 comes with sdl, which is in development? That is, you can say one of the last commits of the source code? It turns out that Wayland has support?

konstantinblaesi commented 1 year ago

I don't know if wayland is working for everyone, but on fedora 38 with gnome 3 it works fine. I use these start commands to run it on the dGPU SDL_VIDEODRIVER=wayland DRI_PRIME=1 %command% and according to dota it always uses vulkan.

icculus commented 1 year ago

@icculus So Dota 2 comes with sdl, which is in development? That is, you can say one of the last commits of the source code? It turns out that Wayland has support?

Historically the problem has been that the Steam Runtime doesn't have Wayland support, so when they build SDL against it, it builds without the Wayland backend, so I assume that is happening here too, but I have not checked if this is still true in recent times.

In theory you could replace the libSDL3.so.0 in DOTA2 with one you built from the latest commit to SDL's revision control, but please don't report bugs if doing so causes problems, especially now when SDL3's interfaces are still changing.

icculus commented 1 year ago

SDL_VIDEODRIVER=wayland DRI_PRIME=1 %command%

It's SDL_VIDEO_DRIVER (extra underscore) in SDL3; it likely ignored SDL_VIDEODRIVER and ran under XWayland.

konstantinblaesi commented 1 year ago

ok with SDL_VIDEO_DRIVER=wayland it still fails

alexeysvrv commented 1 year ago

@kisak-valve @gdrewb-valve @Plagman Any update? Will be support of Steam, Dota 2 of native Wayland? Is there work going on in this direction? What exactly is the problem with adding native support?

alexeysvrv commented 1 year ago

The problem was solved by the developers, using a few small lines of text in an executable bash startup script. Namely, by adding a hardcoded variable SDL_VIDEO_DRIVER=x11. You can see for yourself. Therefore, the variable in the game launch parameters will simply be ignored. I think that as a short-term solution, it is quite reasonable. But I would like not to use crutches, but full-fledged Wayland support. Let the stable branch of the game and the engine be on X for now, and the one being developed can already be transferred to Wayland and provided for testing to ordinary users. It would be just great! Please, let's develop also in technical terms, and not only in gameplay изображение

konstantinblaesi commented 1 year ago

Since dota 2 seems to ship libSDL3 (which doesn't seem to be released yet?), maybe they are waiting for that and possibly other developments?

alexeysvrv commented 9 months ago

It seems that after a long wait, we have been heard! Added tacit support for Wayland! Simply set the variable in the startup file(dota2.sh) as SDL_VIDEO_DRIVER=wayland and the game will work! (To confirm this, the wayland icon is shown on the icon of the Dota window in the taskbars) I ask you to test it and write here about the results Although the variable is still set to x11 by default

Update from 02/16/2024. After today's patch, the game does not launch on Wayland. It's just that nothing appears after launch. Previously, the game was launched, albeit with some nuances:

  1. When the window initially appears, it is a quarter of the screen, and then it expands to full screen. This is how it works if you don't touch the mouse. If you do anything, you crash.
  2. The game has black and white faded tsaeta. It is solved by minimizing the game window and maximizing it again.
  3. Steam overlay doesn't work
  4. When trying to view the names of heroes on the minimap by pressing the alt key, nothing happens(settings correct) @danginsburg
konstantinblaesi commented 5 months ago

Fedora 40 using SDL_VIDEO_DRIVER=wayland DRI_PRIME=1 %command% works fine! (only steam client has a habit of freezing and suspend to RAM ruins graphics quality and performance)

Fell commented 5 months ago

Fedora 40 using SDL_VIDEO_DRIVER=wayland DRI_PRIME=1 %command% works fine! (only steam client has a habit of freezing and suspend to RAM ruins graphics quality and performance)

Setting SDL_VIDEO_DRIVER=wayland is pointless because it will be reset back to x11 in game/dota.sh:

# Remove when Source 2 supports Wayland
if [ "$UNAME" == "Linux" ]; then
   export SDL_VIDEO_DRIVER=x11
fi

You can, however, edit that file to enforce the use of Wayland. Which - last time I checked - simply crashes the game.

Elandig commented 5 months ago

Replying to https://github.com/ValveSoftware/Dota-2/issues/999#issuecomment-2135325101

I modified the script and swaymsg confirmed that it indeed was able to run with Wayland. Didn't encounter any crashes during the game.

With edited dota.sh:

#296: con "Dota 2" (xdg_shell, pid: 1484955, app_id: "dota2")

Without:

#297: con "Dota 2" (xwayland, pid: 1499822, instance: "dota2", class: "dota2", X11 window: 0x6E00238)