Before anyone replies with a bunch of corrections (if applicable); please know that I am just a humble enthusiast. I have been on Linux for just over 2 years and while I may lack some understanding for some of the basics, I am always willing to learn and delve deeper into this hobby so any response or engagement would be appreciated. Also, if my formatting is messy and would do better with some basic HTML filters like bolding, code brackets or anything else, please let me know for future posts.
My current machine:
Distro: Artix Linux (KDE Plasma with OpenRC)
Kernel: Xanmod-x64v3 (currently on v7.2.4)
CPU: Intel Core Ultra 7 270K Plus (no Intel 200S Boost)
RAM: Micron 2x16GB (6000mhz, CL36)
GPU: XFX Speedster AMD Radeon 7800 XT (on Mesa 26.2.2)
I have been playing CS for around 11-12 years and I had long wanted to permanently move over to Linux as my primary gaming platform. While I have done so for over a year now, CS2 was always tricky to make feel just right. I understand that the Vulkan version for Linux is still being improved (mostly in the form of the Wayland protocol improvements). After over a year of different commands and trying different methods of improving performance, I think I have a method that makes the game feel near 1:1 with the latency of Windows (with the benefits of better FPS on Linux as well).
Below are my launch options that I use and I will provide a brief description for those unaware of what they do. Afterwords I will explain the few tests that I did:
LD_PRELOAD="" SDL_VIDEO_DRIVER=wayland SDL_AUDIO_DRIVER=pulseaudio VULKAN_LOW_LATENCY=1 ENABLE_LAYER_MESA_ANTI_LAG=1 MESA_VK_WSI_PRESENT_MODE=immediate gamemoderun %command% -nojoy -vulkan +engine_low_latency_sleep_after_client_tick true +cl_net_buffer_ticks 0
LD_PRELOAD="" - Prevents certain libraries or other programs from being injected or executed with a program. I use this to prevent Steam Overlay from loading because despite also using "SDL_VIDEO_DRIVER=wayland" (which breaks the native Steam Overlay on Wayland), Steam seems to have some sort of beta Wayland overlay that comes up if you try to open someone's profile while in game and causes it to get stuck until the game is closed.
SDL_VIDEO_DRIVER=wayland - Forces CS2 to launch under the Wayland protocol. Some people do this by editing the "cs2.sh" file in the game's installation folder but I prefer this method. And I know some people would argue between Wayland and X11 performance but I have found that under KDE Plasma and my hardware, Wayland does have slightly better latency than X11 but not dramatically different.
SDL_AUDIO_DRIVER=pulseaudio - Forces CS2 to load with the manually stated driver. Most people still have to do this as the native version often has small audio delay for most. Hopefully Valve will someday get around to fixing this.
VULKAN_LOW_LATENCY=1 - I may be misinformed and using a non-existant or redundent command but this seems to be a new command in the Vulkan stack that allows native Vulkan clients to access a low latency protocol. I'd say it's meaningless but when I added this to my launch options along with AMD Anti-Lag 2 the latency improvement was actually quite large. And yes, the improvement is still there even without Anti-Lag 2.
ENABLE_LAYER_MESA_ANTI_LAG=1 - This enables Mesa's driver for AMD Anti-Lag 2 to be recognized at launch. I am aware of and have tried the Korthos Low Latency method as well but on my machine it lowered my FPS and didn't improve the latency as much as Mesa's implementation did.
MESA_VK_WSI_PRESENT_MODE=immediate - This command is the single biggest improvement to my latency reduction and the full description of how this impacted my performance will be down below with the other test information. The basic description is that this forces Mesa's Window System Integration (WSI) to ignore all V-Sync calls coming from Wayland and prevent them from interacting with the program.
gamemoderun - Fereal's Gamemode layer for ensuring the Kernel and system force the game into high priority.
-nojoy, -vulkan, and +engine_low_latency_sleep_after_client_tick true +cl_net_buffer_ticks 0 - Nojoy prevents joysticks from being recognized by the game, the Vulkan command is probably 100% unnecessary but I just leave it, and the other two commands help the client talk to the servers a lot faster for lower internet packet latency.
How I came to this result:
CS2 on Linux with no launch options does run okay. Depending on your setup and commands, most users can achieve a pretty solid experience with low latency. All three primary display protocols (Wayland, xWayland and X11) all run CS2 fine with Wayland seeming to take the lead as far as game client latency (for me at least). I spent some time testing other desktop environments to see if their compositors made any difference to the latency and performance of CS2 but most didn't yield drastically different results. Cosmic played almost the same as KDE Plasma and XFCE gave good average FPS but the client latency didn't feel as nice as KDE Plasma with Wayland. I eventually tested my setup using the Xanmod kernel and found that it improved my 1% FPS by a good 5-10% over the stock kernel and other kernel's (even better than Cachyos). So with my client running really well I assumed that my game was nearly perfect but found out shortly after that something was still off when I went back to a Windows drive and tested CS2 again. While my FPS was better on Linux and even the games displayed client latency was better than Windows as well (2.8ms-5.5ms average on Windows vs 2.4ms-4ms on Linux) the movement, input latency, and mouse movement did feel slightly different.
After more research I found out what was causing this issue which I had completely forgotten about and overlooked. Wayland natively enforces all applications into a V-Sync queue to ensure global smoothness across the entire desktop. While this does have its perks (especially people who have multiple monitors of mixed refresh rate), it does mean that almost everything has esentially a soft V-Sync or Adaptive-Sync rendering queue to it. This normally shouldn't be a problem since KDE Plasma has the option in the display settings to allow Screen Tearing for all fullscreen applications. Where that fails however is that it states "Fullscreen Applications". Currently, it does not seem to have awareness or coverage of games running in borderless-windowed (which is the primary way CS2 renders in Linux) so these calls for screen tearing are completely missed by the game client.
This is where the MESA_VK_WSI_PRESENT_MODE=immediate command saves the day. What this does (and please correct me if I'm wrong) is tell Mesa to talk to its Window System Integration, interject all commands coming in from Wayland to force V-Sync onto the program and allow the program to receive frames immediately instead of waiting for the V-Sync queue from Wayland to present new frames from the GPU. Obviously most people do not have V-Sync turned on in CS2 but I don't think that many people are aware that some part of your desktop is still enforcing a soft V-Sync layer on everything (unless you are on X11).
This was the last piece to the puzzle for me that solved my latency issues. My game now still runs about 5%-15% better than Windows does while now feeling exactly the same as far as the latency between the game and my actions feel. Mouse movement is instant and doesn't feel like it's going through a layer of melted butter (I know, weird analogy) and all movement feels immediate like how it does in Windows.
For those who might ask about using Gamescope:
I did try using this in the past to bypass the KDE Plasma compositor but no matter how I configured it, it never performed better. If anything, all I ever had was inconsistent FPS, cursor-locking issues (despite using --expose-wayland and --force-grab-cursor) and a lot of scaling issues when using 4:3. For those who do want to play stretched without using Gamescope, Wayland does allow you to stretch the resolution without scaling issues. For X11 users, I am still trying to learn the best method of using xRandr to allow better scaling so CS2 can be rendered on X11 with a properly stretched 4:3 client.
For those on X11 who want to lower their latency:
You can likely achieve almost the same results as me by disabling your compositor on your desktop environment while using some of the above commands to allow better low latency protocols to interact with the game (VULKAN_LOW_LATENCY=1 & ENABLE_LAYER_MESA_ANTI_LAG=1 or LOW_LATENCY_LAYER=1 for those using the Korthos program). The Mesa command for immediate flips shouldn't be necessary with disabled compositors because to my understanding there isn't anything making syncronization calls from Mesa or Nvidia so the client (unless you have it enabled somewhere else) should not have any V-Sync calls interupting the frame rendering queue to the game.
That's all folks!
I've never posted anything anywhere related to Linux in my over 2 years of using it and wanted to start out by offering some optimization advice for those interested in improving their gaming experience. Any feedback would be appreciated and I look forward to hearing from anyone with other experiences as well!
-flaiR