Skip to content

Host/Linux: Implement GameMode#14246

Open
kamfretoz wants to merge 2 commits intoPCSX2:masterfrom
kamfretoz:gamemode-test
Open

Host/Linux: Implement GameMode#14246
kamfretoz wants to merge 2 commits intoPCSX2:masterfrom
kamfretoz:gamemode-test

Conversation

@kamfretoz
Copy link
Copy Markdown
Contributor

@kamfretoz kamfretoz commented Apr 3, 2026

Description of Changes

This PR implements support for Feral Interactive's GameMode. (Only for Linux)

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

GameMode was designed primarily as a stop-gap solution to problems with the Intel and AMD CPU powersave or ondemand governors, but is now host to a range of optimisation features and configurations.

For more information, check out the Arch Linux Wiki.

You can find the settings on Settings -> Emulation -> Enable Feral GameMode

Note: You will need to have the actual gamemode's daemon itself installed on your system, otherwise PCSX2 will not do anything on its own.

PCSX2 will also detects if you have the daemon available and will automatically hide the setting if its not available on the running system.

NOTE 2: You have to enable advanced settings as well for the setting to show up. If this is too restrictive, further discussion are welcome.

2026-04-03.20-18-37.mp4
Screenshot_20260403_204418 Screenshot_20260403_205134

Rationale behind Changes

Hopefully better performance for those who needs it.

Closes #13237

Suggested Testing Steps

-1. Use Linux
0. Make sure GameMode is installed on your system

  1. Open PCSX2 and open the log window, this is to check for gamemode related logs
  2. Run any game (or the bios)
  3. Check the logs and see if gamemode are properly kickstarted (search for "GameMode" string)

Also make sure nothing is broken on Windows and macOS side.

Did you use AI to help find, test, or implement this issue or feature?

Nop

@github-actions github-actions bot added Build | Project System Documentation Dependencies Pull requests that update a dependency file GUI/Qt labels Apr 3, 2026
Copy link
Copy Markdown
Member

@chaoticgd chaoticgd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found some problems, haven't benchmarked it.

<item row="4" column="0">
<widget class="QCheckBox" name="feralGameMode">
<property name="text">
<string>Enable Thread Pinning</string>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an odd gap when the fast CDVD option is disabled but the game mode option is enabled. You should add some logic to the .cpp file to correct this. Ideally we'd have a layout that just deals with it, but I think for now we should just do it manually.

#include "common/Darwin/DarwinMisc.h"
#endif

#ifdef __linux__
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be two separate layers of ifdefs checking the OS. I would remove the ones here and keep the ones in GameMode.h.

#include "common/Console.h"

namespace GameMode {
static std::atomic<bool> s_gamemode_active{false};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this atomic? It looks like it's only accessed from a single thread.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, thinking about this some more, it appears to be possible for another process to enable game mode for PCSX2 on its behalf, so we should probably be using gamemode_query_status rather than storing this in a variable.

#include <atomic>
#include "common/Console.h"

namespace GameMode {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this namespace line and prefix function names with "GameMode::" instead. That way you can run clang-format and everything won't be indented.

@@ -0,0 +1,26 @@
Copyright (c) 2017-2025, Feral Interactive and the GameMode contributors
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also add this to the third party licenses file.

@@ -0,0 +1,234 @@
## 1.8.2
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the changelog.

${LIBC_LIBRARIES}
)

if(LINUX)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks when -DUSE_GAMEMODE=OFF is passed to CMake since the library hasn't been added.

set(pcsx2LinuxSources
CDVD/Linux/DriveUtility.cpp
CDVD/Linux/IOCtlSrc.cpp
Host/Linux/GameMode.cpp
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the ifdefs are going to go in GameMode.cpp/GameMode.h, these shouldn't be platform-specific sources.


if (enabled)
{
if (gamemode_request_start() == 0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this logic is actually required, or if you could just call gamemode_request_start/gamemode_request_stop repeatedly without issue.

SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.precacheCDVD, "EmuCore", "CdvdPrecache", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.feralGameMode, "EmuCore", "EnableGameMode", false);

m_ui.feralGameMode->setVisible(GameMode::IsAvailable() && QtHost::ShouldShowAdvancedSettings());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a good reason to gate this behind the advanced settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Linux GameMode

3 participants