Become a ninja at Linux gaming: a mega-guide for Wine, DXVK, and more.
In this guide, I want to introduce Linux users to gaming, what tools are available, and how to set it up. This tutorial will be mainly focusing on Wine, but also introduces a number of tools like Gamemode and Gamescope.
The tutorial is written with Ubuntu and Arch users in mind. All information should be relevent for descendants of Ubuntu/Arch (and even Debian, Ubuntu's base). Users of other distros will need to do research for how to get these tools installed.
Before we open the wine, let's see what can be done with just open-source.
Open-Source Games
By far the easiest way get games on Linux is if they are open-source! Even if your favourite game is commercial, proprietary software, There might've been an open-source release of the engine, or a community effort to re-create one. Famous examples include Quake, Morrowind, Rollercoaster Tycoon 2, and others.
You may also find open-source spiritual successors to some of your favourite games. Like 0 A.D., Freeciv, and Flare.
I suggest checking the excellent OSGameClones website, for a comprehensive list of the aforementioned categories.
The advantage of open-source is that the games are running natively on Linux, and they can be ported to other platforms as well. It is also possible to keep them running on newer computers and OS's, since the game's code is available. However it's impractical for every old game to get an open-source engine release, and reverse engineering with infringing copyright takes years.
Wine
Wine is an incredible program! It isn't an emulator or virtual machine, it's a compatibility layer. Wine works by converting Windows API calls into POSIX calls on the fly. POSIX for those who don't know, is the standardised Unix API understood by Linux, macOS, BSD and others. Wine doesn't have perfect compatibility, but it's performance is unmatched by any emulator.
Using Wine, you'll be able to run Windows software. Although Wine tries to re-implement every Windows API (and even other Microsoft ones), not every game will work with Wine's libraries. More on this later.
Wine optionally provides a Mono and Gecko component, which provides support for Microsoft's .NET and web rendering respectively. Wine will ask you if you want to install these each time you create a new prefix. But some package managers will provide those as packages.
Make sure to review the optional dependencies on Arch Linux. You will need the 32bit versions of common libraries for things like audio, graphics to work with 32bit Windows games. For example if you are missing lib32-mpg123
on Arch, then any 32bit game that uses MP3 won't have sound! Thankfully Ubuntu provides the --install-recommends
option which will take care of this for you.
Wine: Installation
Wine has three different release channels. stable, staging, and development. I would suggest the dev branch, and that is the default in Arch Linux. Staging contains new bugfixes/patches that haven't been integrated into the dev/stable branches yet, it's useful if you know you need a patch.
Arch users must enable the multilib repo and then install the following:
sudo pacman -Syu wine wine-mono wine-gecko
For Ubuntu, I'd suggest using the official WineHQ repository, this gives you the latest version. There are fairly clear install instructions on the WineHQ wiki.
Wine: Usage
Start by using the cd
command to change directories to where the .exe file is located.
cd /path/to/game-setup
It is best to do this just in case the exe refers to other files within the same directory.
Using wine at a very basic level is as simple as passing the .exe to wine on the command-line. Which looks something like this:
wine setup.exe
However you rarely want to do this.
It is good practice to utilise multiple prefixes (a.k.a. bottles), which are the Windows environments Wine uses. This is because a patch you may have to make to the Wine environment, could conflict with other games installed. Best practice is: one game = one wine prefix. This will also give us some freedom on where the games are installed on disk.
If you'd like them on your boot drive, I suggest creating a folder under .local in your home directory: mkdir ~/.local/share/wine
. However for a secondary HDD this might be trickier, since it could be mounted under /mnt
, /media/username
, or /run/media/username
depending on what Linux distro, and your setup.
The way you create a prefix is to add the WINEPREFIX=
environment variable before every wine command you want to use with the game:
WINEPREFIX
should equal the path where you want the game stored. You can use $HOME
as shorthand for your home directory:
WINEPREFIX="$HOME/.local/share/wine/game1" wine setup.exe
Now "game1" is installed in it's own environment! But what if the game is so old that the default 64bit Windows environment is causing issues?
First you'll have to delete the prefix, since wine doesn't allow 32/64bit switching once the prefix is created. Then simply add the WINEARCH=win32
environment variable whenever interacting with the prefix:
WINEPREFIX="$HOME/.local/share/wine/game1" WINEARCH=win32 wine setup.exe
Now is a good time to explain how a little how the wine environment works. By default Wine creates two Windows drives that it exposes: C:\
which is the fake Windows environment that Wine creates. And Z:\
, which is your Linux system starting from root. When installing software into the individual Wine bottle, I would suggest installing directly onto the C:\
drive like: C:\game-name
, just to keep things easy for you.
Also don't worry if the game's installer crashes after it finishes, or throws up errors. This is quite common actually, and it's usually nothing.
If the installer is a msi, then according to the Wine User Guide, use msiexec
:
wine msiexec /i setup.msi
Wine: winecfg
It pays to familiarise yourself with the Wine configuration in case you ever need to troubleshoot, or change options for compatibility.
To access winecfg, execute the following:
WINEPREFIX="$HOME/.local/share/wine/game1" winecfg
I will briefly go over all the tabs.
Applications
Let's you set Windows versions, usually not needed as the defaults (Windows XP for 32bit prefixes, and Windows 7 for 64bit prefixes) are fine. Gives a pretty good indication on whether you are in a 32/64bit prefix, since the 64bit prefix will only go back as far as XP.
Libraries
Let's you override certain libraries, such as DirectX and Visual C++, and choose whether Wine will provide that functionality (builtin), or taken from within the Windows environment (native). Be warned, just because the game installed Visual C++, DirectX, .NET framework etc., doesn't mean Wine will use those bundled versions by default. You must manually override here. However, I'd recommended installing any required libraries using Winetricks, since Winetricks automatically overrides for you.
In most cases, you can get away with using builtin libraries. Still, this is good to know. And we will be overriding Direct3D with DXVK later in this guide.
Graphics
A couple of troubleshooting options are available under this menu.
The one you might use the most is "Emulate a virtual desktop". It's extremely useful, should the game not scale properly, crashes, or mouse input is weird. You'll want to set the virtual desktop to be your native screen resolution, so that it'll be in fullscreen.
You should also change the game's resolution to match, so you ensure it scales properly.
Some of the other setting here can also be used for troubleshooting. Unticking both the "Allow the window manager to..." options has helped me out in some cases.
Desktop integration
Under this menu you'll be able to choose mappings for Windows folders (like Desktop, Documents, Pictures etc.) on your host system. If you're annoyed by game files appearing in your Documents folder on the Linux host, this is where you change it.
Drives
Where the aforementioned C:\ and Z:\ drives are set. I've never needed to add another.
Audio
Where Wine integrates with your system audio. Defaults should be fine. If a games audio isn't playing, make sure you have all the required codecs (including 32bit versions) installed on your system.
Wine: Running a game
When it comes to running the game, you have two options.
Execute using the games shortcut, which is created on the desktop. This could be inside the wineprefix under drive_c/users
or on your Linux desktop. Sometimes it can also be located in the installed game's program files as well.
Otherwise you can try and open the .exe
file directly, which will, in the wineprefix, be found under: drive_c/
. Depending on where you installed it; it could be under either of the Programs Files
folders, or directly on the C drive.
We will also introduce the wine start
command. The start
subcommand will change automatically change directory to where the exe is located. You may have to experiment with both styles when starting a game.
Starting shortcut using wine start
:
WINEPREFIX="$HOME/.local/share/wine/game" wine start /unix "$HOME/.local/share/wine/game/drive_c/users/Public/Desktop/game.lnk"
Direct .exe
example (without wine start
):
cd "$HOME/.local/share/wine/game/drive_c/Programs Files (x86)/game"
WINEPREFIX="$HOME/.local/share/wine/game" wine game.exe
Running without start
subcommand will require manually changing directory to the games executable location
Direct .exe
example (with wine start
):
WINEPREFIX="$HOME/.local/share/wine/game" wine start /unix "$HOME/.local/share/wine/game/drive_c/Programs Files (x86)/game/game.exe"
The /unix
options specifies a unix styled path.
DXVK
DXVK is another compatibility layer. It will, on-the-fly, convert the 3D component of DirectX (9, 10 & 11) into Vulkan instructions. This is distributed as a set of 32 and 64bit .dll libraries that must be installed into your Wine prefix and overridden. Thankfully there is also a setup-dxvk.sh script which will do both of these for you.
DXVK will improve the performance of DirectX games under Linux, compared to the builtin Wine version. It is my preferred implementation of Direct3D, and I will usually install it right after the game (if compatible). Just be warned some anti-cheat systems may detect modified DirectX, and ban you.
Before starting, make sure your system and GPU supports Vulkan. Arch users should read this wiki page. Best way to test support would be to install the vulkan-tools
package and then execute:
vulkaninfo | less
If you see info about your graphics card, you're ready to go.
Go to the GitHub releases page, download the latest, and extract the tarball. Arch users, note that you can get dxvk-bin
from the AUR.
Open a terminal, cd
into the extracted folder and run:
WINEPREFIX="$HOME/.local/share/wine/game1" ./setup-dxvk.sh install
You can also issue uninstall
if you want to remove DXVK.
If the game uses a supported version of DirectX, you should get a game1_d3dXX.log
file automatically generated in your current working directory. This is how you find out what version of D3D was used, and a log of what happened.
Winetricks
Winetricks is an optional script, that allows you to easily install official Windows versions of libraries, and it'll automatically override the builtin Wine versions.
I suggest only installing Windows native libraries if the game doesn't work without. The builtin Wine versions, may work fine, and usually have better performance. Keep in mind, if an old tutorial tells you to use winetricks, it might not be necessary in current versions. This is due to the rapid development of Wine.
Arch and Ubuntu users can find winetricks in the distro's respective repositories.
You run winetricks in the command-line. Make sure to call the target WINEPREFIX
first:
WINEPREFIX="$HOME/.local/share/wine/game1" winetricks
Just running winetricks
without any options will launch a cumbersome GUI, which let's you install some tricks. However I strongly suggest learning the command-line instead. You can view all of the options with winetricks --help
.
To list all of the categories of tricks available:
WINEPREFIX=... winetricks list
Of all the categories, we'll be using dlls
the most. To list all of the tricks under a category (e.g. dlls) type:
WINEPREFIX=... winetricks dlls list
You'll get the name of the trick in the first column, and a description on the second.
When you find the libraries you need, just place each trick after the base winetricks
command:
WINEPREFIX=... winetricks vcrun2019 vcrun2017 vcrun2015
In the above example, I installed various versions of the Visual C++ Redistributable.
The best way to find out about what libraries a games uses would be the installer, or PCGamingWiki.
Other useful winetricks are:
corefonts
- Standard Windows fonts, usually not needed in a game.sandbox
- Not a security sandbox! It just the removes link between the Wine user folders, and your Linux home. Helpful if the game makes your home folder messy.settings fontsmooth=rgb
- Font smoothing (for RGB displays)
Gamemode
Enables Linux kernel optimisations whilst the game is running. Read GitHub page. It isn't a wine-specific, and can be used on anything.
Just add gamemoderun
before your game in the command-line. In our case it'll be wine
of course:
WINEPREFIX="$HOME/.local/share/wine/game" gamemoderun wine ...
Once the game is running, you can open another terminal and execute:
gamemoded -s
To see if it's running.
Install on Arch Linux. Ubuntu users can install with sudo apt install gamemode
.
Gamescope
From time-to-time you may experience strange scaling issues, or discrepancies with the mouse cursor behaviour. Traditionally this could be solved using the "Emulating a virtual desktop" option under winecfg. But we now have another tool at our disposal.
Thanks to Valve we have Gamescope, a Wayland microcompositor. Basically it runs your game in an environment that is isolated from your main desktop. But it runs "nested" on top of your current desktop, so you don't have to login to a new desktop session.
This is incredibly useful for isolating a bugs in your chosen Desktop/Window Manager, and you have a lot of control over the screen resolution. This is known as a "spoofed" monitor, where you can upscale a low-res game, limit the refresh rate, and force the game into fullscreen.
Just like DXVK, it uses Vulkan, so make sure your card is compatible.
There's currently only an AUR package for Arch available. So Ubuntu users will need to build from source.
When running Gamescope commands, here are some options to keep in mind:
-w
,-h
- The screen resolution (width and height) that your game will run in.-W
,-H
- This is the resolution of your spoofed monitor.-f
- Make Gamescope fullscreen.-r
- Refresh-rate limit.
Generally the lowercase -w
& -h
should be set to the highest your game can handle (but not above your physical monitor). Whereas the uppercase -W
& -H
should be the native resolution of your monitor.
For a modern game, where resolution will go up to native. You may only need to specify the lowercase width and height options.
For old games you may need to edit an .ini file or install a patch to set to your native screen resolution.
Otherwise set it to the highest the game will allow and then modify the -w
and -h
options. Example:
WINEPREFIX="$HOME/.local/share/wine/game" gamescope -f -w 800 -h 600 -W 1920 -H 1080 -- gamemoderun wine ...
Gamescope will now scale the old game's 800 x 600 display to fill the whole screen.
Application Launcher
As you can see, this command is beginning to get long. We will fix this by creating an application launcher. Some versions of Wine will create a shortcut automatically. Otherwise you may need to do it manually.
Here is an example of one found in my ~/.local/share/applications
folder:
[Desktop Entry]
Name=F.E.A.R. First Encounter Assault Recon
Exec=env WINEPREFIX="/home/user/.local/wine/fear" wine C:\\\\windows\\\\command\\\\start.exe /Unix /home/user/.local/wine/fear/dosdevices/c:/ProgramData/Microsoft/Windows/Start\\ Menu/Programs/GOG.com/F.E.A.R.\\ Platinum\\ Collection/F.E.A.R.\\ First\\ Encounter\\ Assault\\ Recon.lnk
Type=Application
StartupNotify=true
Path=/home/user/.local/wine/fear/dosdevices/c:/GOG Games/F.E.A.R. Platinum Collection/
Icon=1A69_goggame-1423058413.0
StartupWMClass=fear.exe
As you can see it is very messy. Before we clean this up, lets take a note of a few of the most important entries in this file:
Name=
- Name that is used in your app launcher. Required.Exec=
- The command that executes when launched. Note here you need to add commandenv
before yourWINEPREFIX
variable. Required.Type=
- Should always be set to Application in this case. Required.StartupNotify=
- Plays nicely with some desktops. Recommend set to true.Path=
- Sets the working directory. Should be the location of the games exe. Recommended.Icon=
- Sets the icon. Wine auto generates one from the exe and puts it in~/.local/share/icons
. You may need to grab a png off Google images and put it in that same folder. SetIcon=
to the file name of the png. Recommended.StartupWMClass=
- Plays nicely with some desktops. Set to exe name. Recommended.
We will clean up the Exec entry, although this isn't required if it launches just fine.
The command is very similar to what we've been executing this whole time, Wine just autogenerates it in a very verbose manner. Also note how the path here is /wine/fear/dosdevices/c:
rather then the drive_c
path we've been using the whole time. It doesn't matter, as it all links to the same place.
Exec=env WINEPREFIX="$HOME/.local/wine/fear" wine start /unix "$HOME/.local/wine/fear/dosdevices/c:/ProgramData/Microsoft/Windows/Start Menu/Programs/GOG.com/F.E.A.R. Platinum Collection/F.E.A.R. First Encounter Assault Recon.lnk"
Note here you need to add command env
before your WINEPREFIX
variable.
Now let's add in our gamescope
/gamemode
commands:
Exec=env WINEPREFIX="$HOME/.local/wine/fear" gamescope -f -w 1920 -h 1080 -- gamemoderun wine start /unix "$HOME/.local/wine/fear/dosdevices/c:/ProgramData/Microsoft/Windows/Start Menu/Programs/GOG.com/F.E.A.R. Platinum Collection/F.E.A.R. First Encounter Assault Recon.lnk"
If the command doesn't work, copy and paste it into a terminal for troubleshooting.
Also remember you need to add command env
before your WINEPREFIX
variable, when executing from a .desktop
file.
Troubleshooting Workflow
If the game doesn't work correctly (or at all), next things I'll try are:
- Emulating a desktop, or using gamescope.
- If the game has multiple executables/shortcuts I'll try launching each one.
- Uninstall DXVK.
- Try reinstalling in a 32bit wineprefix.
- Install libraries with winetricks.
- Research patches or tweaks.
Resources
At the end of the day, the game still might not work properly (or even at all). Or maybe it will. With some tweaking.
- PCGamingWiki - A wiki for information, known issues, and fixes/workarounds. Windows-oriented, but some of the issues that affect Linux really bad will be mentioned here. Also contains useful information about dependencies or API's the game may use.
- WineHQ AppDB - The official Wine application compatibility site. Here you can find user reports, which can sometimes be helpful figuring out if the game will run easily or not. Just be warned that the how-to's (and even the test reports) can be very outdated. Wine has improved a lot over the years, so anything 3+ years old should be discarded.
- ProtonDB - The game compatibility site for Valve's Proton (which is just Wine w/ patches & DXVK). You can find much more up-to-date test results here, and can occasionally find useful workarounds. Just be warned: Proton is patched, so don't trust it for brand-new games.
- Wine FAQ - Would suggest reading if new to Wine in general.
Not covered
Esync
This helps remove overhead in wine for games that rely heavily on the CPU. It's currently only available in builds of wine with it enabled. So I haven't played with it a whole bunch. Lutris helps you get these builds pretty easily, so that is always an option.
Proton/Steam
Steam provides a very easy way to play games on Linux called Proton. It's really just Wine + DXVK. But it takes a lot of the manual work out of setting this up. With the disadvantage that you're locked into Steam.
Codeweavers CrossOver
Codeweavers are a commercial developer and provider of Wine. They provide CrossOver, a paid Mac and Linux versions of Wine with an easy to use interface. And automated installers to do everything listed here manually.
Lutris
Lutris is an open-source general game manager for Linux, with good support for things like Wine. They even have custom builds with Esync enabled. And provide automated installers as well. The automated installers are nice, but when I used them, they would always insist on downloading the exe, and wouldn't allow you to select an already downloaded exe file, which I found annoying.
Native games
I did mention open source at the top of this article. But I didn't mention Linux ports of commercial games. Some games have native ports, and they may work well. But dependencies are usually the issue. Old games that haven't been updated for more than five years link against old dependencies that newer distro's no longer provide.
DirectX 12
Wine has a built in implementation. I don't know about it's performance, since I haven't has to use it yet.
Games Quirks
To give you an idea of the many weird issues I've come across. I'll just list a few quirks i've had to workaround to get certain games working.
Oblivion
Game would crash on first run, unless I disabled HDR lighting. I was able to turn it back on after first launch. I use DXVK here, previously mentioned issue still happens with/without DXVK.
Deus Ex (2000)
I've had a lot of scaling issues with this game recently. Thankfully sorted with Gamescope or Wine Virtual Desktop.
STALKER: Shadow Of Chernobyl
The game has worked great. But I've recently had issues with scaling. Game will fullscreen fine, but the mouse will act as if it's still 800 x 600, limited where the mouse can travel. Gamescope fixed this one. Wine virtual desktop would but you also needed to uncheck the window manager-related settings. Perhaps a bug with my window manager.
I use DXVK, but make sure to enable dynamic lighting so it'll use DX9.
Games lighting sometimes flickers when widescreen. Also an issue on Windows. Refer to PCGamingWiki.
Crysis
Game would crash on startup until I installed the "c1-launcher" patch. The game has a nasty bug with modern AMD CPU's, I likely ran into that. Haven't played enough of the game to test stability.
Black Mesa
The games UI/menu system is invisible on Linux. Need to launch with old UI (refer to PCGamingWiki).