Gaming on Linux

SammiLucia here 😊

I was trying to play several new games on Linux and quickly became obvious there aren't many clear, up-to-date examples of how to configure Linux for optimal gaming.

First of all, I'd like to address that there are several distros purported to be built for gaming. While this may be true for many people, unfortunately if you're on newer hardware, in general those distros do not give you the most current kernel or packages, which will undoubtedly cause you problems...

We recommend Fedora, followed by Arch for gaming. Fedora probably takes the least work to get going. Also be aware Manjaro is only loosely based on Arch so we don't recommended it. If you're on PopOS! and Ubuntu and having great successβ€”great! However we don't recommend these distros, either.

Thanks to Leopard on the asus-linux Discord for your help with this guide 😊

πŸ”—Arch?

Note, this was originally written for Arch, and adapted for Fedora. Please let me know in the Discord if you find any ploblems.

πŸ”—Feddora

I'm now using Fedora, which does a lot of the prep for games for you (as you'd expect with Fedora). The /etc/environment settings are still useful, however.

πŸ”—Contributing

Please feel free to contribute! I most certainly am not the expert on this topic, just trying to work out how to play games! 😊

Updates should be posted to this blog article, please also update the Changelog below.

πŸ”—Prerequisites

  1. This guide assumes you have the latest NVIDIA drivers installed and working correctly. Version 5.10.xx at the time of writing.

  2. The guide also assumes you have a kernel with FSYNC enabled, this means either kernel 5.17 or higher, or Xanmod. Xanmod enables FSYNC, and Intel Clear patches, and some other performance chages, and generally has the lastest performance (and possibly hardware) updates.

  3. If your distro doesn't yet have the 5.17 kernel (you can check with uname -r), you can install Xanmod by following the instructions here for Arch, or it should be fairly easy to find a recent Xanmod built for your distro.

  4. To enable vsync passthrough (depending on how well a game implements its vsync), add nvidia-drm.modeset=1 to the GRUB_CMDLINE_LINUX_DEFAULT line in /etc/default/grub

  5. You can also reduce mouse latency by adding usbhid.mousepoll=1 to GRUB_CMDLINE_LINUX_DEFAULT. Note this is probably broken since kernel 4.4.x, however it shouldn't hurt to add it.

  6. Regenerate grub by running grub-mkconfig -o /boot/grub/grub.cfg on Arch, or grub2-mkconfig -o /etc/grub2.cfg on Fedora.

  7. Reboot.

πŸ”—Gnome/Wayland Mutter

If your screen has FreeSync or supports variable refresh rate (VRR) and you use Wayland (you really should use Wayland) ensure you're running the latest Mutter (version 42.5.vrr.10-1 on Fedora 36 at the time of writing).

This fixes a bunch of potential screen/cursor lags, as well as halved refresh rates on external monitors. I've been on the beta for several weeks and it's been great.

πŸ”—Steam configuration

  1. Install the latest Steam, login and download your games
  2. If you want Steam to start with certain command line options, create a file ~/.config/steam-runtime-flags.conf and put the options in there. (Note: if this doesn't work for you, you may need to modify the Exec in the steam.desktop shortcut. There are a few ways to list flags... I find one per line clearest, e.g:Screenshot from 2021-12-27 22-51-42
  3. In Steam > Settings > Steam Play > Enable Steam Play for all other titles > Proton Experimental Screenshot from 2021-12-27 22-48-14
  4. Force the new game to run with Proton Experimental: Right click the game > Properties > Compatibility > Force the use of a specific Steam Play compatibility tool > Proton Experimental Screenshot from 2021-12-27 22-53-12
  5. Change the Launch Options for the game to enable gamemode (see below), and force NVIDIA: Right-click game > Properties > General > Launch Options > __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia __VK_LAYER_NV_optimus=NVIDIA_only VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json %command%Screenshot from 2021-12-29 19-06-45

πŸ”—Enable Game Mode scheduling

gamemode is no longer needed, there's no advantage over the regular performance governer/scheduler.

πŸ”—Enable saving the Shader Cache

By default the Shader Cache will generate every time a game is launched. To enable saving of the Shader Cache:

  1. Right-click game > Properties > Shader Pre-Caching > Check Enable Shader Pre-Caching AND Allow background processing of Vulkan shaders:

Screenshot from 2021-12-29 19-06-01

The Shader Cache should now start generating and saving the cache for that game.

πŸ”—Fix laggy screen updates

Note: This has caused a problem for at least one person. I also don't know how it interacts with the latest Mutter VRR

For whatever reason (maybe me not understanding something) vblank_mode=0 still leaves me with a weird laggy display and screen tearing. This fix shouldn't hurt and it works for me. Do:

  1. Create a new config file with nano /etc/drirc.
  2. Add the following to the file:
<driconf>
   <device>
       <application name="Default">
           <option name="vblank_mode" value="0" />
       </application>
   </device>
</driconf>
  1. Reboot.

πŸ”—Using environment variables instead

If you don't want to specify launch options for every single game you can put known safe options into /etc/environment so they are enabled during login. To do this:

  1. Create and edit the file with nano /etc/environment if it doesn't already exist.
  2. Add your desired options, for example:
#
# This file is parsed by pam_env module
#
# Syntax: simple "KEY=VAL" pairs on separate lines
#

# Configure AMD. Only required if you have AMD iGPU and/or dGPU
# "AMDVLK" = AMD's Vulkan driver
# "RADV" = mesa's RADV driver (recommended)
AMD_VULKAN_ICD="RADV"

# Force AMD ACO shader compiler threading (may cause instability in some games)
# Note: mesa alredy enables this for some games. See here for the whitelist:
# https://cgit.freedesktop.org/mesa/mesa/tree/src/util/00-mesa-defaults.conf
#mesa_glthread=true

# Set video decode to AMD. This should be set automatically since 12.0.1 of
# libva-mesa-driver. This is only in here for testing.
#VDPAU_DRIVER="radeonsi"

# Enable raytracing (VKD3D-proton). Recommended with RADV above (not AMDVLK).
# Recommendation is to use RADV built from Git.
# dxr=DXR, dxr11=DXR tier 1.1
#VKD3D_CONFIG=dxr11
#VKD3D_CONFIG=dxr
#RADV_PERFTEST=rt

# Pascal speed hack for Vulkan. This could make a big difference for a game but
# is best enabled per in Steam Launch options because it may cause problems.
#VKD3D_CONFIG=force_static_cbv

# Enable DLSS for NVidia. This is still fairly new.
PROTON_ENABLE_NVAPI=1
PROTON_HIDE_NVIDIA_GPU=0

# AMD FidelityFX Super Resolution (FSR) for Vulkan games (dxvk and vkd3d-proton
# included) and Proton Experimental or ProtonGE. Some games may not need this
# setting.
#WINE_FULLSCREEN_FSR=1
# The amount of FSR sharpening to be applied: 5 being the default, 2 is AMD's
# recommendation.
#WINE_FULLSCREEN_FSR_STRENGTH=5

# Compensate for compositing Window Managers:
# 1 = Display _previous_ rendered frame. Highest FPS, but higher latency
# 2 = Display _latest_ rendered frame, better latency, but _possibly_ lower FPS
PRIMUS_SYNC=2

# Enable shader disk cache per game instead of regenerating the cache at every
# game launch. The disk cache path should no longer be required, however if
# the shader cache is being regenerated each launch, try specifying it.
__GL_SHADER_DISK_CACHE=1
#__GL_SHADER_DISK_CACHE_PATH=/var/cache/shaders

# Enable threaded optomisation for OpenGL.
__GL_THREADED_OPTIMIZATION=1
  1. In the above example you would still use the Launch Options above to force the use of NVIDIA. Using Launch Options this way enables you to still run some games on the iGPU, so you can play less demanding games on battery.

πŸ”—Asus fan settings

If you are on a recent Asus notebook, see asus-linux.org for guides on how to properly configure NVIDIA drivers and support for configurable fan curves.

I use the following commands to set fan curves for the Performance power profile with asusctl. You don't need sudo for these:

  1. asusctl fan-curve -m "balanced" -f cpu -D "20c:0%,40c:0%,50c:0%,60c:5%,70c:15%,80c:40%,90c:70%,100c:80% to set the CPU fan curve.
  2. asusctl fan-curve -m "balanced" -f gpu -D "20c:0%,40c:0%,50c:0%,60c:5%,70c:15%,80c:40%,90c:70%,100c:80% to set the GPU fan curve.

πŸ”—Lutris installation

Warning: For me, installing Lutris made games run worse. I don't yet know why, however games became extremely choppy and unplayable. Removing Lutris fixed this(!)

With all the above config, you actually shoudln't need Lutris.

You can install Lutris, which provides a single interface for all your games, and runs games with community optimised settings.

To install, do:

  1. pacman -S lutris python-magic
  2. Ensure your Steam profile and games list is set to public. This is how Lutris discovers your games list. (Everything else can be set to private.) Screenshot from 2021-12-28 16-20-58
  3. Run a game, and run gamemoded -s to check gamemode is still active while launching a game from Lutris.

That should be it! Run Lutris to start and configure games from Lutris. If you have any problems, you can run lutris -d to see what might be going on.

πŸ”—What do the flags do?

Note: This has caused a problem for at least one person. I also don't know how it interacts with the latest Mutter VRR

  • vblank_mode=0 prevents Proton for trying to wait for vblank (the next screen redraw), which depending on a number of factors (desktop environment, and your specific config), it may not even get. This can lead to a really weird tearing effect. If you don't see this problem, you do not need to enable this flag. This may vary by game, depending on how each game has implemented vsync (i.e: "well", or "poorly").
  • __NV_PRIME_RENDER_OFFLOAD=1 causes VK_LAYER_NV_optimus (Vulkan) to be loaded. I'm not sure this is needed any more.
  • __GLX_VENDOR_LIBRARY_NAME=nvidia together with __NV_PRIME_RENDER_OFFLOAD=1 forces OpenGL to choose the NVIDIA driver.
  • __VK_LAYER_NV_optimus=NVIDIA_onlytogether with __NV_PRIME_RENDER_OFFLOAD=1 forces Vulkan to choose the NVIDIA driver.

πŸ”—"Experimental" flags

  • VKD3D_CONFIG=dxr11 or VKD3D_CONFIG=dxr enables RTX/raytracing support. This may cause some games to not start up, but is starting to get better. Raytracing support is still in active development.
  • __GL_THREADED_OPTIMIZATION=1 allows the NVIDIA driver to work multithreaded for OpenGL only (not Vulkan), however be aware threading is not always good! As a rule of thumb if the GPU is under heavy burden, this may actually decrease FPS.

πŸ”—Futher reading

  • Lutris docs - a list of many launch flags.
  • Gaming - ArchWiki the Arch Wiki may have some other tweaks. Please note the section on schedule and scheduled should not be required with Game Mode (unverified).
  • Xanmod kernel - including the Asus ROG patches from (Asus Linux)[https://asus-linux.org/]

πŸ”—Changelog

19-Sep-22:

  • Added Mutter
  • Added Fedora note
  • Removed gamemode, no longer requireed
  • Added FSR settings
  • Cleaned up/clarified /etc/environment
  • Added warning about vblank_mode
  • Added grub command for Fedora
  • Updated fan curves

15-Apr-22:

  • Moved to asus-linux.org website
  • Updated for 5.17 kernel and NVidia 5.10.x drivers
  • Added warning about non Arch/Fedora distros

29-Dec-21:

  • Added changelog
  • Enabled launching of some games on iGPU
  • Added warning about Lutris
  • Fixed fan curve typos

28-Dec-21:

  • Added Lutris

27-Dec-21 #2:

  • Added renice
  • Added gamemode
  • Added renice fix
  • Added fan curves
  • Added vblank fix

27-Dec-21 #1:

  • Initial version

Has this post helped you?

If this site helps you and you want to contribute we welcome you to help with development, search for issues, join the discord, and add to this website.

You can also donate

Your support on Pateron or Paypal helps us buy ASUS devices for development to support new features and drivers.
Patreon button image or PayPal button image