Ei kuvausta

Marc Di Luzio 1ad1f3bbcf Set theme jekyll-theme-midnight 6 vuotta sitten
.github 42d2fda05c Update issue templates 6 vuotta sitten
daemon bd1f9bc543 Log the version on startup 6 vuotta sitten
data 5ebc77a0f1 Add defaultgov and desiredgov config settings 6 vuotta sitten
example fec4732740 Add an example .desktop file 6 vuotta sitten
lib eac854b753 Allow failure when finding functions that are new to the API 6 vuotta sitten
scripts d9072607d9 Label master as 1.2-dev 6 vuotta sitten
subprojects 17efeaa699 subprojects: Switch inih to a properly managed git submodule 7 vuotta sitten
.clang-format ee1c51d0b0 Add clang format file 7 vuotta sitten
.gitignore 17efeaa699 subprojects: Switch inih to a properly managed git submodule 7 vuotta sitten
.gitmodules 17efeaa699 subprojects: Switch inih to a properly managed git submodule 7 vuotta sitten
.travis.yml 1f12bcb892 Add a basic travis file for unit tests 7 vuotta sitten
CHANGELOG 20828da140 Refactor getting config values to stop duplicating the rwlock 6 vuotta sitten
LICENSE.txt 4f14c807ba 1.0: Finalised for release 7 vuotta sitten
README.md 2c68ae67e6 added info about overclocking (#49) 6 vuotta sitten
_config.yml 1ad1f3bbcf Set theme jekyll-theme-midnight 6 vuotta sitten
bootstrap.sh 21b8ec76dc Restart the service in bootstrap.sh 6 vuotta sitten
meson.build d9072607d9 Label master as 1.2-dev 6 vuotta sitten
meson_options.txt 7f26122c62 Allow controlling whether systemd is used or not 7 vuotta sitten

README.md

GameMode

GameMode is a daemon/lib combo for Linux that allows games to request a set of optimisations be temporarily applied to the host OS.

The design has a clear-cut abstraction between the host daemon and library (gamemoded and libgamemode), and the client loaders (libgamemodeauto and gamemode_client.h) that allows for safe use without worrying about whether the daemon is installed or running. This design also means that while the host library currently relies on systemd for exchanging messages with the daemon, it's entirely possible to implement other internals that still work with the same clients.

GameMode was designed primarily as a stop-gap solution to problems with the Intel and AMD CPU powersave or ondemand governors, but is now able to launch custom user defined plugins, and is intended to be expanded further, as there are a wealth of automation tasks one might want to apply.

Issues with GameMode should be reported here in the issues section, and not reported to Feral directly.


Building and installing

If your distribution already has GameMode packaged, it is preferable to install it directly from there. There are Solus and AUR packages already available.

GameMode depends on meson for building and systemd for internal communication. This repo contains a bootstrap.sh script to allow for quick install to the user bus, but check meson_options.txt for custom settings.

Ubuntu/Debian (you may also need dbus-user-session)

apt install meson libsystemd-dev pkg-config ninja-build git

Arch

pacman -S meson systemd git

Fedora

dnf install meson systemd-devel pkg-config git

Then clone, build and install GameMode:

git clone https://github.com/FeralInteractive/gamemode.git
cd gamemode
git checkout 1.1
./bootstrap.sh

Requesting GameMode

Users

After installing libgamemodeauto.so simply preload it into the game:

LD_PRELOAD=/usr/\$LIB/libgamemodeauto.so ./game

Or edit the steam launch options:

LD_PRELOAD=$LD_PRELOAD:/usr/\$LIB/libgamemodeauto.so %command%

Please note the backslash here in \$LIB is required.

Developers

Developers can build the request directly into an app. Note that none of these client methods force your users to have the daemon installed or running - they will safely no-op if the host is missing.

// Manually with error checking
#include "gamemode_client.h"

	if( gamemode_request_start() < 0 ) {
		fprintf( stderr, "gamemode request failed: %s\n", gamemode_error_string() );
	}

	/* run game... */

	gamemode_request_end(); // Not required, gamemoded can clean up after game exits
// Automatically on program start and finish
#define GAMEMODE_AUTO
#include "gamemode_client.h"

Or, distribute libgamemodeauto.so and either add -lgamemodeauto to your linker arguments, or add it to an LD_PRELOAD in a launch script.


Components

gamemoded runs in the background, activates game mode on request, refcounts and also checks caller PID lifetime. Run man gamemoded for command line options.

libgamemode is an internal library used to dispatch requests to the daemon. Note: libgamemode should never be linked with directly.

libgamemodeauto is a simple dynamic library that automatically requests game mode when loaded. Useful to LD_PRELOAD into any game as needed.

gamemode_client.h is as single header lib that lets a game request game mode and handle errors.


Configuration

The daemon can currently be configured using a gamemode.ini file. gamemode.ini is an example of what this file would look like, with explanations for all the variables.

Config files are loaded and merged from the following directories, in order:

  1. /usr/share/gamemode/
  2. /etc/
  3. $XDG_CONFIG_HOME or $HOME/.config/
  4. $PWD

The file parsing uses inih.


For those with overclocked CPUs

If you have an AMD CPU and have disabled Cool'n'Quiet, or you have an Intel CPU and have disabled SpeedStep, then GameMode's governor settings will not work, as your CPU is not running with a governor. You are already getting maximum performance.

If you are unsure, bootstrap.sh will warn you if your system lacks CPU governor control.

Scripts and other features will still work.


Contributions

Pull Requests

Pull requests must match with the coding style found in the .clang-format file, please run this before committing:

clang-format -i $(find . -name '*.[ch]' -not -path "*subprojects/*")

Planned Features

  • Additional mode-switch plugins
  • Improved client state tracking (PID is unreliable)

Maintained by

Feral Interactive

See the contributors section for an extended list of contributors.


License

Copyright © 2018 Feral Interactive

GameMode is available under the terms of the BSD 3-Clause License (Revised)