Gaming

From ArchWiki
Revision as of 09:50, 25 July 2012 by Procyon (Talk | contribs) (Keyboard Grabbing: change in packages)

Jump to: navigation, search

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end

This page only contains information about running games and related system configuration tips. For lists of popular games for GNU/Linux see Common Applications/Games and Netbook Games.

Game Environments

Different environments exist to play games in Linux:

  • Native – Games written for Linux (usually Free & Open Source).
  • Browser – you need only browser and Internet connection to play this games.
    • Plugin-based – you need to install plugin to play.
      • Java Webstart – to install cross-platform games very easily.
      • Flash games are very common on the Web.
      • Unity – specialized plugin for browser, currently works only in Google Chrome. Most games are commercial.
    • HTML 5 games use brand new canvas and WebGL technologies and work in all modern browsers but can be very slow on weak machines.
  • Specialized environments (software emulators) – you should first install emulator, then find games yourself (most are protected by Copyright!)
    • Wine – allows running of some Windows games.
    • Crossover Games - members of the Codeweavers team are prime supporters of Wine. Using Crossover Games makes the installation & setting up of some games easier, more reliable & even possible, when compared to using other methods. Crossover is an inexpensive commercial product, which also provides a forum where the developers are very much involved in the community.
    • Cedega – game-oriented Wine derivative. Its packaged version is not free of charge unlike its CVS version.
    • DosBox – DOS games
    • scummvm – lots of old adventure games
  • Hardware emulators – emulate the whole device instead of software environment. The same thing about Copyright here.

Getting games

Native

A good number are available in the Official repositories or in the AUR. Loki provides installers for several games. Desura can be considered good source of games (if you don't care about security and bugs too much).

Wine

  • Centralized source of information about running games (and other applications) in Wine is Wine AppDB.
  • See also Category:Wine.

Flash

Several huge flash games portals exists, among them are:

Java

Running games in Arch

Certain games or game types may need special configuration to run or to run as expected. For the most part, games will work right out of the box in Arch Linux with possibly better performance than on other distributions due to compile time optimizations. However, some special setups may require a bit of configuration or scripting to make games run as smoothly as desired.

Multi-screen setups

Running a multi-screen setup may lead to problems with fullscreen games. In such a case, running a second X server is one possible solution. Another solution may be found in the NVIDIA article (may also apply to non-NVIDIA users).

Keyboard Grabbing

Some games grab the keyboard, noticeably preventing you from switching windows (also known as alt-tabbing). Download sdl-nokeyboardgrabAUR to gain the ability to use keyboard commands while in SDL games. If you wish to turn it up to 11, you can disable keyboard grabbing at X11 level using libx11-nokeyboardgrabAUR, or with more fine-grained control with libx11-ldpreloadnograbAUR using the LD_PRELOAD environment variable to run applications with particular grab prevention. Wine/lib32 users should also look at the respective lib32 libraries.

Note: SDL is known to sometimes not be able to grab the input system. In such a case, it may succeed in grabbing it after a few seconds of waiting.

Starting games in a separate X server

In some cases like those mentioned above, it may be necessary or desired to run a second X server. Running a second X server has multiple advantages such as better performance, the ability to "tab" out of your game by using CTRL-ALT-F7 / CTRL-ALT-F8, no crashing your primary X session (which may have open work on) in case a game conflicts with the graphics driver. To start a second X server (using Nexuiz as an example) you can simply do:

xinit /usr/bin/nexuiz-glx -- :1

This can further be spiced up by usi ng a seperate X configuration file:

xinit /usr/bin/nexuiz-glx -- :1 -xf86config xorg-game.conf 

A good reason to provide an alternative xorg.conf here may be that your primary configuration makes use of NVIDIA's Twinview which would render your 3D games like Nexuiz in the middle of your multiscreen setup, spanned across all screens. This is undesirable, thus starting a second X with an alternative config where the second screen is disabled is advised.

A game starting script making use of Openbox for your home directory or /usr/local/bin may look like this:

$ cat ~/game.sh
if [ $# -ge 1 ]; then
  game="`which $1`"
  openbox="`which openbox`"
  tmpgame="/tmp/tmpgame.sh"
  DISPLAY=:1.0
  echo -e "${openbox} &\n${game}" > ${tmpgame}
  echo "starting ${game}"
  xinit ${tmpgame} -- :1 -xf86config xorg-game.conf || exit 1
else
  echo "not a valid argument"
fi

So after a chmod +x you would be able to use this script like:

$ ~/game.sh nexuiz-glx

Adjusting mouse detections

For games that require exceptional amount of mouse skill, adjusting the response rate can help improve accuracy. Read more here.

HRTF filters with OpenAL

For games using OpenAL, if you use headphones you may get much better positional audio using OpenAL's HRTF filters. To enable, edit /etc/openal/alsoft.conf (Or copy the example configuration file if it doesn't exist) and change:

#hrtf = false

to

hrtf = true

Ulatencyd

Ulatencyd is a daemon which uses dynamic cgroups to give the kernel hints to reduce latency in the system. It comes with a number of configs, and is extensively helpful in prioritizing disk I/O. Installing it will again increase responsiveness and reduce input lag. To use, simply install and add to your DAEMONS in rc.conf.

In addition, Ulatencyd has it's own method for specifically reducing latency in games, by focusing in on that one individual process. To take advantage of this, add entries into /etc/ulatencyd/simple.d/games.conf:

bit.trip.runner user.game
hl2.exe         user.game
/opt/cogs/*     user.game inherit=1

If you are using an SSD or simply have changed the default scheduler for any block devices, it may be advisable to edit the default settings, as Ulatencyd reverts the default scheduler back to cfq.

Improving framerates and responsiveness with scheduling policies

Most every game can benefit if given the correct scheduling policies for the kernel to prioritize the task. However, without the help of a daemon, this rescheduling would have to be carried out manually or through the use of several daemons for each policy. Luckily, one tool known as schedtool, and it's associated daemon schedtoold (available on the AUR) can handle many of these tasks automatically. To edit what programs relieve what policies, simply edit /etc/schedtoold.conf and add the program followed by the schedtool arguments desired.

Policies

First and foremost, setting the scheduling policy to SCHED_ISO will not only allow the process to use a maximum of 80 percent of the CPU, but will attempt to reduce latency and stuttering wherever possible. SCHED_ISO requires Linux-ck to operate, as it has only been implemented in that kernel. Linux-ck itself provides a hefty latency reduction, and should ideally be installed Most if not all games will benefit from this:

bit.trip.runner -I

For users not using Linux-ck, SCHED_FIFO provides an alternative, that can even work better. You should test to see if your applications run more smoothly with SCHED_FIFO, in which case by all means use it instead. Be warned though, as SCHED_FIFO runs the risk of starving the system! Use this in cases where -I is used below:

bit.trip.runner -F -p 15

Nice levels

Secondly, the nice level sets which tasks are processed first, in ascending order. A nice level of -4 is reccommended for most multimedia tasks, including games:

bit.trip.runner -n -4

Core affinity

There is some confusion in development as to whether the driver should be multithreading, or the program. In any case where they both attempt it, it causes drops in framerate and crashes. Examples of this include a number of modern games, and any WINE program which is running without GLSL disabled. To select a single core and allow only the driver to handle this process, simply use the -a 0x# flag:

bit.trip.runner -a 0x1 #Use cores 1

Some CPUs are hyperthreaded and have only 2 or 4 cores but show up as 4 or 8, and are best accounted for:

bit.trip.runner -a 0x5 #Use virtual cores 0101, or 1 and 3

General case

For most games which require high framerates and low latency, usage of all of these flags seems to work best. Affinity should be checked per-program, however, as most native games can understand the correct usage. For a general case:

bit.trip.runner -I -n -4
Amnesia.bin64 -I -n -4
hl2.exe -I -n -4 -a 0x1 #Wine with GLSL enabled

etc, etc.

Optimus, and other helping programs

As a general rule, any other process which the game requires to operate should be reniced to a level above that of the game itself. Strangely, Wine has a problem known as 'reverse scheduling', it can often have benefits when the more important processes are set to a higher nice level. Wineserver also seems unconditionally to benefit from SCHED_FIFO, since rarely consumes the whole CPU and needs higher prioritization when possible.

optirun -I -n -5
wineserver -F -p 20 -n 19
steam.exe -I -n -5

See also