game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
anonymous_namespace{game_process.cpp} Namespace Reference

Classes

class  GameModeAPI

Functions

void addApplicationSpecificFixes (std::ostringstream &cmd, const Game &game)
 Add application-specific environment variables for known problematic apps.
void addGPUOptimizations (std::ostringstream &cmd, bool isProton=false)
 Add GPU-specific optimization environment variables.
void addSyncEnvironment (std::ostringstream &cmd, const GameRunnerConfig &config, bool isProton=false)
 Add synchronization environment variables.
std::string buildGamescopeWrapper (const GameRunnerConfig &config, std::string &modeInfo)
 Build the Gamescope wrapper prefix.
std::string buildWrapperChain (const GameRunnerConfig &config, const std::string &gameId)
 Build the wrapper chain for a game launch.
std::string detectGPUVendor ()
 Detect GPU vendor for GPU-specific optimizations.
time_t getProcessStartTimeFromProc (int pid)
bool isWrapperAvailable (const std::string &name)
 Check if a wrapper/tool is available in PATH.
bool kernelSupportsFsync ()
 Check if kernel supports Fsync (futex2).
bool kernelSupportsNTSync ()
 Check if kernel supports NTSync (kernel 6.14+ or CachyOS backport).
const std::vector< std::string > & kWineSystemExes ()

Function Documentation

◆ addApplicationSpecificFixes()

void anonymous_namespace{game_process.cpp}::addApplicationSpecificFixes ( std::ostringstream & cmd,
const Game & game )

Add application-specific environment variables for known problematic apps.

Parameters
cmdThe command stream to append to
gameThe game being launched

Some applications require specific environment variables to work correctly under Wine/Proton. This function detects known problematic applications and adds the necessary fixes automatically.

Known fixes:

  • Battle.net: Requires WINE_SIMULATE_WRITECOPY=1 to prevent "Update Agent went to sleep"
  • EA App/Origin: May need specific DXVK settings
  • Ubisoft Connect: May need specific dll overrides

Definition at line 2007 of file game_process.cpp.

References GameRunnerConfig::executablePath, Logger::info(), Game::name, Game::runnerConfig, and Logger::warn().

◆ addGPUOptimizations()

void anonymous_namespace{game_process.cpp}::addGPUOptimizations ( std::ostringstream & cmd,
bool isProton = false )

Add GPU-specific optimization environment variables.

Parameters
cmdThe command stream to append to
isProtonWhether this is a Proton launch (vs plain Wine)

Note: RADV_PERFTEST is no longer set. In modern Mesa (24.x+), all commonly useful flags (rt, nggc, sam, gpl) have graduated to being on by default.

Definition at line 1970 of file game_process.cpp.

References detectGPUVendor(), and Logger::info().

◆ addSyncEnvironment()

void anonymous_namespace{game_process.cpp}::addSyncEnvironment ( std::ostringstream & cmd,
const GameRunnerConfig & config,
bool isProton = false )

Add synchronization environment variables.

Parameters
cmdThe command stream to append to
configThe runner configuration
isProtonWhether this is a Proton launch (vs plain Wine)

Sync method priority (best to fallback):

  1. NTSync - New kernel sync primitive (6.14+ or CachyOS backport)
    • Proton: PROTON_USE_NTSYNC=1 (required on GE-Proton <=10-9; harmless no-op on GE-Proton 10-10+ where it auto-enables). Disable with PROTON_NO_NTSYNC=1.
    • Plain Wine: auto-detects via /dev/ntsync; no env var needed.
  2. Fsync - futex2-based sync (kernel 5.16+)
  3. Esync - eventfd-based sync (always available)

Note: WINEFSYNC/WINEESYNC should both be set as Esync serves as fallback for code paths that don't support Fsync. Proton also supports PROTON_NO_ESYNC/PROTON_NO_FSYNC to explicitly disable.

Definition at line 1926 of file game_process.cpp.

References GameRunnerConfig::autoDetectSync, GameRunnerConfig::enableFsync, Logger::info(), kernelSupportsFsync(), and kernelSupportsNTSync().

◆ buildGamescopeWrapper()

std::string anonymous_namespace{game_process.cpp}::buildGamescopeWrapper ( const GameRunnerConfig & config,
std::string & modeInfo )

Build the Gamescope wrapper prefix.

Parameters
configThe runner configuration
modeInfoOutput parameter for launch info display
Returns
Gamescope command prefix (empty if disabled or unavailable)

Gamescope is a Wayland compositor for gaming that provides:

  • FSR upscaling (render at lower res, upscale to native)
  • VRR (Variable Refresh Rate) support
  • HDR output
  • Tearing control
  • Improved fullscreen behavior

Command structure: gamescope -W {width} -H {height} [-w {internal_w} -h {internal_h}] [options] -- {command}

Definition at line 1714 of file game_process.cpp.

References GameRunnerConfig::enableGamescope, GameRunnerConfig::enableMangoHud, GameRunnerConfig::gamescopeBorderless, GameRunnerConfig::gamescopeEnableFSR, GameRunnerConfig::gamescopeEnableHDR, GameRunnerConfig::gamescopeEnableITM, GameRunnerConfig::gamescopeEnableVRR, GameRunnerConfig::gamescopeForceGrabCursor, GameRunnerConfig::gamescopeFSRSharpness, GameRunnerConfig::gamescopeFullscreen, GameRunnerConfig::gamescopeHeight, GameRunnerConfig::gamescopeIntegerScaling, GameRunnerConfig::gamescopeInternalHeight, GameRunnerConfig::gamescopeInternalWidth, GameRunnerConfig::gamescopeITMSDRNits, GameRunnerConfig::gamescopeRefreshRate, GameRunnerConfig::gamescopeWidth, Logger::info(), and isWrapperAvailable().

◆ buildWrapperChain()

std::string anonymous_namespace{game_process.cpp}::buildWrapperChain ( const GameRunnerConfig & config,
const std::string & gameId )

Build the wrapper chain for a game launch.

Parameters
configThe runner configuration.
gameIdGame ID, used to resolve any per-game wrapper config (e.g. MangoHud per-launch config file in ${XDG_STATE_HOME}/gamelauncher/<id>/mangohud.conf).
Returns
String containing wrappers to prepend to command.

CachyOS best practices: game-performance should be the OUTERMOST wrapper so it can apply scheduling optimizations to the entire process tree. Order: game-performance -> gamemoderun -> command MangoHud and VkBasalt are activated via env vars (MANGOHUD=1, ENABLE_VKBASALT=1)

Note: Gamescope is handled separately via buildGamescopeWrapper() as it wraps the entire command differently (gamescope [opts] -- {command}).

Definition at line 1846 of file game_process.cpp.

References FrameMetricsService::buildMangoHudLaunchConfigFile(), GameRunnerConfig::enableGameMode, GameRunnerConfig::enableGamePerformance, GameRunnerConfig::enableGamescope, GameRunnerConfig::enableMangoHud, GameRunnerConfig::enableVkBasalt, ShellUtils::escapeArg(), Logger::info(), FrameMetricsService::instance(), SystemInfoService::instance(), isWrapperAvailable(), and GameRunnerConfig::mangoHudConfigFile.

◆ detectGPUVendor()

std::string anonymous_namespace{game_process.cpp}::detectGPUVendor ( )

Detect GPU vendor for GPU-specific optimizations.

Returns
"AMD", "NVIDIA", "Intel", or "Unknown"

Definition at line 1561 of file game_process.cpp.

Referenced by addGPUOptimizations().

◆ getProcessStartTimeFromProc()

time_t anonymous_namespace{game_process.cpp}::getProcessStartTimeFromProc ( int pid)

Definition at line 869 of file game_process.cpp.

◆ isWrapperAvailable()

bool anonymous_namespace{game_process.cpp}::isWrapperAvailable ( const std::string & name)

Check if a wrapper/tool is available in PATH.

Parameters
nameName of the wrapper (e.g., "mangohud", "gamemoderun")
Returns
true if available

Definition at line 1676 of file game_process.cpp.

Referenced by buildGamescopeWrapper(), and buildWrapperChain().

◆ kernelSupportsFsync()

bool anonymous_namespace{game_process.cpp}::kernelSupportsFsync ( )

Check if kernel supports Fsync (futex2).

Returns
true if Fsync is supported

Definition at line 1620 of file game_process.cpp.

Referenced by addSyncEnvironment().

◆ kernelSupportsNTSync()

bool anonymous_namespace{game_process.cpp}::kernelSupportsNTSync ( )

Check if kernel supports NTSync (kernel 6.14+ or CachyOS backport).

Returns
true if NTSync is available and the module is loaded

NTSync is a new synchronization primitive that provides better Wine/Proton performance than Fsync. It was merged in kernel 6.14 but CachyOS and some other distributions backport it to earlier kernels.

Detection checks:

  1. /dev/ntsync device exists (module loaded)
  2. /sys/module/ntsync exists (module loaded as module)
  3. /proc/kallsyms contains ntsync symbols (built-in)

Definition at line 1665 of file game_process.cpp.

References SystemInfoService::instance(), and SystemInfoService::supportsNTSync().

Referenced by addSyncEnvironment().

◆ kWineSystemExes()

const std::vector< std::string > & anonymous_namespace{game_process.cpp}::kWineSystemExes ( )

Definition at line 1546 of file game_process.cpp.