ValveSoftware / csgo-osx-linux

Counter-Strike: Global Offensive
http://counter-strike.net
775 stars 69 forks source link

Wayland support (GNU/Linux) #1470

Open DmitryHetman opened 7 years ago

DmitryHetman commented 7 years ago

Your system information

Gentoo GNU/Linux nomultilib, Weston (uses Wayland Display Server Protocol), no xwayland.

  1. Install any distro and any Wayland compositor
  2. Install Steam
  3. Try to launch steam or any game with Source engine Wayland support is very important, wayland gives opportunity to not use user-space driver, improves performance significantly, saves energy.
DmitryHetman commented 7 years ago

https://wayland.freedesktop.org/ https://en.wikipedia.org/wiki/Wayland_(display_server_protocol) https://jan.newmarch.name/Wayland/ProgrammingClient/

mellowagain commented 7 years ago

Yea +1 for Wayland support pls add mr. lead csgo-linux-dev kisak-volvo.

I thought Steam OS is also using Gnome which is supporting Wayland, so give this high priority

roge commented 7 years ago

Doesn't CS:GO use SDL on Linux? SDL's support for Wayland is still in early experimental stages, it's probably best just to use XWayland for now.

ghost commented 7 years ago

With XWayland I have poor result. High FPS (140+fps@1440p) but input have issue : huge lag input like 15-20 FPS. I read somewhere XWayland fullscreen in gnome is not unredirected.

I use fedora 26 and I relog on Xorg for CSGO.

SethDusek commented 6 years ago

If CS:GO uses sdl2 then all valve has to do is update the sdl library that they provide with steam. However I think it's not easy for the steam client itself to support wayland unless they're fine with using native desktop notifications for their "is now playing" or "x sent you a message" notifications, and it probably won't support inhome streaming to another machine either

AlynxZhou commented 6 years ago

Wayland support needed +1, XWayland hurts performent a lot, how long will it take for sdl support wayland?

tdaniel22 commented 6 years ago

When launching CSGO with SDL_VIDEODRIVER=wayland, a popup gives me an SDL error message: SDL_Init(SDL_INIT_VIDEO) failed: wayland not available.

Given that SDL2 has support for Wayland, I assume the SDL version used for CSGO is outdated. Wouldn't updating it fix this issue? I understand this might not be as simple because it could introduce new bugs, but Wayland is becoming the default display system on Linux, and XWayland really isn't appropriate for fast-paced games.

bool3max commented 5 years ago

You can get native-Wayland support by preloading CSGO with a newer version of SDL2 that was compiled with Wayland support, running Steam w/ native libraries, and using SDL_VIDEODRIVER=wayland.

However, even then, the performance isn't up to par with the Xorg version. Actually, based on my testing, it's even worse than running it with XWayland. There are some graphical bugs and a lot of FPS drops. I've tested this with sway 1.0.

SimplyCorbett commented 3 years ago

I can confirm LD_PRELOAD for libsdl2 and the SDL_VIDEODRIVER wayland method works for dota2.

I can't get it to work for CSGO.

I don't use arch - are there any other libraries that need to be preloaded for csgo to run under wayland?

Mershl commented 3 years ago

Xwayland introduces a noticable input lag on mutter (GNOMEs wm) which can be fixed when running the game with an SDL version that supports wayland. Is an SDL update planned/possible in the near future?

Mershl commented 3 years ago

Thank you very much for updating the SDL library with todays/yesterdays update. The updated library does unfortunatly not have Wayland support enabled. When trying to start using SDL_VIDEODRIVER=wayland the error SDL_Init(SDL_INIT_VIDEO) failed: wayland not available is shown on Fedora 33.

7RST1 commented 3 years ago

Does "starting with SDL_VIDEODRIVER=wayland" mean in the launch options? I tried that and got pretty good performance on Pop OS.

Edit: Nope, did it the right way: SDL_VIDEODRIVER=wayland %command%(and then -nojoy) and got the same error. Was I too using XWayland? Is there a way to check that in-game?

SethDusek commented 3 years ago

I don't think you can check from ingame, however if you run "~xinfo~ xprop" in the terminal, and hover over the CSGO window, if the cursor changes then it implies it's an Xwayland window. If it doesn't then it's Wayland.

AlynxZhou commented 3 years ago

I don't think you can check from ingame, however if you run "~xinfo~ xprop" in the terminal, and hover over the CSGO window, if the cursor changes then it implies it's an Xwayland window. If it doesn't then it's Wayland.

A simple alternative: xlsclients

Mershl commented 3 years ago

If you're on GNOME 3 you can use looking glass to check if a window is using XWayland or Wayland.

Press ALT+F2 for the GNOME command prompt. Type "lg". Select "windows" on the top right. A list of your currently open windows is shown. Selecting a window will expose their parent object (first line of the display). "MetaWindowWayland" is a Wayland native window. "MetaWindowXwayland" is passed through Xwayland.

UltimateNyn commented 3 years ago

I recently tried running CS-GO native with wayland too, but it isn't working currently. I'm using Archlinux with sway. There was a guide, but it's currently not working. There is a Segfault:

/mnt/ssdlinux/SteamLibrary/steamapps/common/Counter-Strike Global Offensive/csgo.sh: line 88: 67918 Segmentation fault      (core dumped) ${DEBUGGER} "${GAMEROOT}"/${GAMEEXE} "$@"

To get SDL using wayland, I added SDL_VIDEODRIVER=wayland", but since the bundled SDL-Lib doesn't support wayland and you get SDL_Init(SDL_INIT_VIDEO) failed: wayland not available (as @Mershl already mentioned). To circumvent using the old SDL-Lib you can add LD_PRELOAD="/usr/lib/libSDL2-2.0.so:/usr/lib32/libSDL2-2.0.so", but this results in a Segfault...

I would really appreciate it, if Valve would try to get the game working with current SDL-Librarys too.

Another tip for testing, if a window is in wayland: You can start xeyes and the eyes will only be able to follow your cursor in Xorg-windows.

Mershl commented 3 years ago

I would really appreciate it, if Valve would try to get the game working with current SDL-Librarys too.

Xwayland shows major regressions for CS:GO. As of today it is not possible to set the brightness of Xwayland windows (the gamma slider in CS:GO has no effect) and the game has a serious input bug where frames are dropped on mouse input (this is only shown on Xwayland and does not affect Xorg and we assume native Wayland). The later bug is crucial and renders the game on Xwayland unplayable. It has now been hunted for more than 7 months (https://gitlab.gnome.org/GNOME/mutter/-/issues/1455#note_1121504) and there's no solution from Xwayland side.

Considering that KDE and Nvidia have recently been pushing Wayland this will trigger more and more distros to enable Wayland by default. Steam users will then run into this issue and have to enable a Legacy Desktop Mode (if available) to play CS:GO.

I can only again ask Valve to update the SDL lib to support Wayland and especially the later mentioned issue would be solved in an instant.

EDIT: Can a KDE wayland user confirm the input issue also affects KWin's implementation?

SimplyCorbett commented 3 years ago

It would be nice to have updated SDL libraries so it can run on wayland.

I'm curious on how the big push into wayland is going to affect proton and native games. Will valve adopt the WIP wayland wine version over at https://github.com/varmd/wine-wayland for proton? But now I'm going off topic. :)

tfaller commented 3 years ago

@Plagman confirmed that the Steam Deck will use Wayland for games (https://twitter.com/Plagman2/status/1418701862484594691) by utilizing gamescope ... so maybe there is a chance that CS:GO finally gets an updated SDL version.

MordragT commented 3 years ago

I hope so Manjaro recently switched to wayland as far as i can tell. Many major distributions have already switched and it is really a suboptimal experience for newcomers out of the box.

robertswiecki commented 3 years ago

csgo for wayland works pretty well, however the following are required.

  1. Prepare a strstr.so library - when using wayland at some point strstr() is called with one argument as type-casted -1 or so. This rightfully crashes the glibc's implementation, but we need to patch it
$ cat strstr.c 
#define _GNU_SOURCE
#include <string.h>
#include <dlfcn.h>
#include <stdint.h>
#include <inttypes.h>

char *strstr(const char *haystack, const char *needle) {
    if ((uintptr_t)haystack > (uintptr_t)0xFFFFFFFF00000000) {
        return NULL;
    }

    char* (*p)(const char *haystack, const char *needle) = dlsym(RTLD_NEXT, "strstr");
    return p(haystack, needle);
}
$ gcc -shared -o strstr.so strstr.c
  1. Run with your own libSDL
SDL_VIDEODRIVER=wayland LD_PRELOAD=<path_to>/strstr.so:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.14.0 steam

Voila!

jakobkukla commented 3 years ago

@robertswiecki your workaround doesn't work for me. csgo just fails to start without error message.

nvm it's working :)

7RST1 commented 2 years ago

I tried your solution, but the game won't start. It opens as a black window for ca. 10 seconds before closing.

I tried both with and without specifying a libsdl2 in lib32, didn't really make a difference. The log is with lib32/libSDL2 specified and using SDL_VIDEODRIVER=wayland LD_PRELOAD=/home/syvers/libstrstr/strstr.so:/usr/lib/libSDL2-2.0.so:/usr/lib32/libSDL2-2.0.so steam and SDL_VIDEODRIVER=wayland %command%

steamCSGO.log

EDIT: "Segmentation fault" in logs took me to #2651, but it has no concrete solution. Are anyone else having the same issue with this patch?

robertswiecki commented 2 years ago

Yeah, it's crashing for me too now. It's crashing in some process exit procedure, so it's maybe not that relevant. What is problematic is that the new reason for the csgo_linux64 process exiting:

SDL_Init(SDL_INIT_VIDEO) failed: No available video device

So, maybe it's something with new SDL, or maybe csgo linux devs changed something. I'll give it a try, and do some shallow debugging, though I was hoping that with the Steam Deck coming, the devs would make it work better under wayland.

PS: It started working again after I installed supertux for SDL/wayland testing. Of course, supertux itself doesn't help here, but IIRC it also forced libSDL-image to be installed, so maybe that's it.

7RST1 commented 2 years ago

I fixed it with this fix posted in another issue, so it seems that the fact it didn't start wasn't relevant to this issue.

None the less, seems like CS:GO works very well now, running on Wayland.

CrumblyLiquid commented 2 years ago

I'm using Manjaro Linux with KDE Plasma and Wayland - all packages updated My setup for reference:

System:    Host: crumbly-pc Kernel: 5.15.2-2-MANJARO x86_64 bits: 64 Desktop: KDE Plasma 5.23.3 Distro: Manjaro Linux
CPU:       Info: 6-Core model: AMD Ryzen 5 5600G with Radeon Graphics bits: 64 type: MT MCP cache: L2: 3 MiB
           Speed: 2729 MHz min/max: 1400/3900 MHz Core speeds (MHz): 1: 2729 2: 2501 3: 2404 4: 1978 5: 2686 6: 2449 7: 2147
           8: 1875 9: 2551 10: 2298 11: 2536 12: 2778
Graphics:  Device-1: Advanced Micro Devices [AMD/ATI] Cezanne driver: amdgpu v: kernel
           Display: wayland server: X.Org 1.21.1.3 driver: loaded: amdgpu,ati unloaded: modesetting resolution: 2560x1440~60Hz
           OpenGL: renderer: AMD RENOIR (DRM 3.42.0 5.15.2-2-MANJARO LLVM 13.0.0) v: 4.6 Mesa 21.2.5

I went through the following steps:

  1. Install the sdl2 package (sdl2 2.0.16-4)
  2. Compile the patch for strstr as shown here
  3. Rename the videos/ folder to videos.bak in /home/$HOME/.steam/steam/steamapps/common/Counter-Strike Global Offensive/csgo/panorama following this comment
  4. Run steam-native with env LD_PRELOAD="$HOME/Games/Steam/CounterStrike/strstr/strstr.so:/usr/lib/libSDL2-2.0.so.0.16.0:/usr/lib32/libSDL2-2.0.so.0.16.0" SDL_VIDEODRIVER=wayland steam-native
  5. Run CS:GO through Steam with these launch options: SDL_VIDEODRIVER=wayland %command% -novid -nojoy +exec autoexec.cfg

Now this get's the game running but it's not really playable. Even though net_graph 1 shows 80-100 FPS it looks more like 50, console is unusable (you can copy, paste and delete but you can't write into the console - when I'm in game it uses a different cursor so there might be a link here?), alt-tabbing works but is really funky (sometimes the window is partly out of my screen, sometimes it's really small, ...) and also colours look weird but I can tweak my monitor settings so that's not that big of a problem.

Do you guys have any ideas as to what I might be doing wrong?

7RST1 commented 2 years ago

The Wayland fix used to work for a while, but now I get jagged* mouse movement with Raw Input activated micro-jolting my view back and fourth. Has anyone encountered this issue and know how to fix it?

Edit: Seems like the view fails to follow mouse sometimes. It's very apparent when moving the mouse slowly, as the view won't pan at all, as seen at the start of the video below.

https://user-images.githubusercontent.com/16783057/175095747-3668acf6-1441-41c8-ba1e-9cb13114420e.mp4
CrumblyLiquid commented 2 years ago

@7RST1 No issues for me on Plasma 5.25.1 (KWin) (latest packages, 5.18.5-arch1-1). What compositor are you running? Note: I'm running CS:GO with these launch options: %command% -vulkan -novid

7RST1 commented 2 years ago

No issues for me on Plasma 5.25.1 (KWin) (latest packages, 5.18.5-arch1-1). What compositor are you running? Note: I'm running CS:GO with these launch options: %command% -vulkan -novid

@CrumblyLiquid Normally I use SDL_VIDEODRIVER=wayland gamemoderun %command% -vulkan -novid -nojoy +fps_max 0 -refresh 144, but it also happens after reducing it to SDL_VIDEODRIVER=wayland %command% -vulkan -novid. I'm using Gnome on Manjaro with mutter v42.2-1

EDIT: Just tried on another computer with Nvidia graphics instead of my previous AMD system. Seems like common denominator is only Manjaro Gnome (unstable). Is it anyone who specifically has Manjaro Gnome on any branch, who can confirm this issue?

hasoart commented 2 years ago

The Wayland fix used to work for a while, but now I get jagged* mouse movement with Raw Input activated micro-jolting my view back and fourth. Has anyone encountered this issue and know how to fix it?

@7RST1 I have the same issue when using the Wayland fix on Plasma 5.25.2 (KWin). Seems that performance is better, but mouse jagging makes it unplayable. I'm using arch (5.18.9-arch1-1) with AMD Vega.

@CrumblyLiquid using %command% -vulkan -novid and not SDL_VIDEODRIVER=wayland %command% -vulkan -novid runs csgo on XWayland and not Wayland, so could you please try it on Wayland and repport if you face the same issue?

CrumblyLiquid commented 2 years ago

@CrumblyLiquid using %command% -vulkan -novid and not SDL_VIDEODRIVER=wayland %command% -vulkan -novid runs csgo on XWayland and not Wayland, so could you please try it on Wayland and repport if you face the same issue?

My bad, thanks for catching my mistake @hasoart! Running it with the SDL_VIDEODRIVER=wayland variable set sadly produces the same issue as @7RST1 described.

adamnejm commented 2 years ago

I've had success opening CS:GO as a native Wayland application on Gnome 42.4 with proprietary Nvidia 515.65 by simply doing the following:

  1. LD_PRELOAD="/usr/lib/libSDL2-2.0.so:/usr/lib32/libSDL2-2.0.so" steam-native
  2. SDL_VIDEODRIVER=wayland %command% -novid -nojoy -fullscreen -vulkan

Running it on Vulkan seems to be required, otherwise it segfaults.
Using steam instead of steam-native also works(?).

daxcore commented 1 year ago
LD_PRELOAD="/usr/lib/libSDL2-2.0.so:/usr/lib32/libSDL2-2.0.so" steam-native
Failed to load steamui.so - dlerror(): /home/<user>/.local/share/Steam/ubuntu12_32/steamui.so: undefined symbol: SDL_GetJoystickGUIDInfo

UPDATE: this is fixed now. steam starts. CS:GO works also with wayland+vulkan.

ghost commented 1 year ago

now its crashing again

daxcore commented 1 year ago

with last steam-update (maybe just steam beta client, which i'm using) it is working again.

ghost commented 1 year ago

How can enable the variables in steam flatpak?

VitalyAnkh commented 1 year ago

Now it's crashing again

VitalyAnkh commented 1 year ago

With SDL_DYNAMIC_API=/usr/lib/libSDL2.so %command% -novid -nojoy -fullscreen -vulkan, CS:GO runs under Wayland smoothly (360+ fps). But the font is blurry, which I believe is an issue from SDL2. Maybe the sdl_ttf version 3 will fix the blurry font problem. 录屏 2023-06-09 23-43-59.webm

NNxCLUTCHERxCPP commented 1 year ago

How can enable the variables in steam flatpak?

NOT needed for Flatpak version of Steam: LD_PRELOAD="/usr/lib/libSDL2-2.0.so:/usr/lib32/libSDL2-2.0.so" steam-native

I replaced the libSDL2.so.0 file in /home/YOUR_USER/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/Counter-Strike Global Offensive/bin

&

/home/YOUR_USER/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/Counter-Strike Global Offensive/bin/linux64

with this file (you may have another version installed) /usr/lib64/libSDL2-2.0.so.0.2800.0 | COPY this to the above mentioned directories and rename them to libSDL2.so.0

launchoptions of CSGO: SDL_VIDEODRIVER=wayland %command% -vulkan

ErikReider commented 1 year ago

These fixes actually solve all of my frame pacing issues!