This commit is contained in:
ADAS2024 2025-06-30 02:45:33 -04:00 committed by GitHub
commit 136d6bed26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 128 additions and 0 deletions

4
.gitmodules vendored
View file

@ -108,3 +108,7 @@
path = 3rdparty/GPUOpen/VulkanMemoryAllocator
url = ../../GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
ignore = dirty
[submodule "3rdparty/feralinteractive/feralinteractive"]
path = 3rdparty/feralinteractive/feralinteractive
url = ../../FeralInteractive/gamemode.git
ignore = dirty

View file

@ -357,6 +357,9 @@ add_subdirectory(opencv EXCLUDE_FROM_ALL)
# FUSION
add_subdirectory(fusion EXCLUDE_FROM_ALL)
# FERAL INTERACTIVE
add_subdirectory(feralinteractive EXCLUDE_FROM_ALL)
# add nice ALIAS targets for ease of use
if(USE_SYSTEM_LIBUSB)
add_library(3rdparty::libusb ALIAS usb-1.0-shared)
@ -389,3 +392,4 @@ add_library(3rdparty::miniupnpc ALIAS libminiupnpc-static)
add_library(3rdparty::rtmidi ALIAS rtmidi)
add_library(3rdparty::opencv ALIAS ${OPENCV_TARGET})
add_library(3rdparty::fusion ALIAS Fusion)
add_library(3rdparty::feralinteractive ALIAS 3rdparty_feralinteractive)

View file

@ -0,0 +1,9 @@
# Feral Interactive
add_library(3rdparty_feralinteractive INTERFACE)
if (CMAKE_SYSTEM MATCHES "Linux")
target_include_directories(3rdparty_feralinteractive INTERFACE feralinteractive/lib)
target_compile_definitions(3rdparty_feralinteractive INTERFACE -DGAMEMODE_AVAILABLE)
target_link_libraries(3rdparty_feralinteractive INTERFACE feralinteractive)
endif()

@ -0,0 +1 @@
Subproject commit af07e169d58b574fac2a093296aa37605313bb2b

View file

@ -152,6 +152,15 @@ if(NOT WIN32)
add_compile_options(-pthread)
endif()
## Look for Gamemode if its installed on Linux
if(LINUX)
find_program(GAMEMODE_FOUND gamemoded) ## Only works if gamemode is installed on system (might include lib32 case)
if(GAMEMODE_FOUND)
add_compile_definitions(GAMEMODE_AVAILABLE)
endif()
message(GAMEMODE_AVAILABLE="${GAMEMODE_AVAILABLE}")
endif()
# TODO: do real installation, including copying directory structure
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${PROJECT_BINARY_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${PROJECT_BINARY_DIR}/bin")

View file

@ -986,6 +986,7 @@ void Emulator::SetContinuousMode(bool continuous_mode)
game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch, usz recursion_count)
{
if (recursion_count == 0 && m_restrict_emu_state_change)
{
return game_boot_result::currently_restricted;
@ -2477,6 +2478,11 @@ void Emulator::Run(bool start_playtime)
{
Emu.GetCallbacks().enable_display_sleep(false);
}
if (g_cfg.misc.enable_gamemode)
{
Emu.GetCallbacks().enable_gamemode(true);
}
}
void Emulator::RunPPU()
@ -3051,6 +3057,7 @@ extern bool try_lock_spu_threads_in_a_state_compatible_with_savestates(bool reve
void Emulator::Kill(bool allow_autoexit, bool savestate, savestate_stage* save_stage)
{
static const auto make_ptr = [](auto ptr)
{
return std::shared_ptr<std::remove_pointer_t<decltype(ptr)>>(ptr);

View file

@ -112,6 +112,8 @@ struct EmuCallbacks
std::function<void(bool)> enable_display_sleep;
std::function<void()> check_microphone_permissions;
std::function<std::unique_ptr<class video_source>()> make_video_source;
std::function<bool()> gamemode_supported;
std::function<void(bool)> enable_gamemode;
};
namespace utils

View file

@ -358,6 +358,7 @@ struct cfg_root : cfg::node
cfg::_bool silence_all_logs{ this, "Silence All Logs", false, true };
cfg::string title_format{ this, "Window Title Format", "FPS: %F | %R | %V | %T [%t]", true };
cfg::_bool pause_during_home_menu{this, "Pause Emulation During Home Menu", false, false };
cfg::_bool enable_gamemode{ this, "Enable GameMode", false, false };
} misc{ this };

View file

@ -0,0 +1,39 @@
#include "gamemode_control.h"
#ifdef GAMEMODE_AVAILABLE
#pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
extern "C" {
#include "3rdparty/feralinteractive/feralinteractive/lib/gamemode_client.h"
}
// Checks if Gamemode is supported on system
bool gamemode_supported()
{
#if defined(GAMEMODE_AVAILABLE)
return true;
#else
return false;
#endif
}
// TODO: Might add later
/*
static int gamemode_status() {
return gamemode_query_status();
}
*/
// Enables and Disables GameMode based on user settings and system
void enable_gamemode(bool enabled) {
if (!gamemode_supported()) {
return;
}
// Enable and Disable Gamemode
if (enabled) {
gamemode_request_start();
} else {
gamemode_request_end();
}
}

5
rpcs3/gamemode_control.h Normal file
View file

@ -0,0 +1,5 @@
#pragma once
bool gamemode_supported();
void enable_gamemode(bool enabled);
//static int gamemode_status(); // Might add later TODO

View file

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "main_application.h"
#include "display_sleep_control.h"
#include "gamemode_control.h"
#include "util/types.hpp"
#include "util/logs.hpp"

View file

@ -133,6 +133,7 @@ add_library(rpcs3_ui STATIC
welcome_dialog.ui
../display_sleep_control.cpp
../gamemode_control.cpp
../headless_application.cpp
../main_application.cpp
../module_verifier.cpp

View file

@ -186,6 +186,8 @@ enum class emu_settings_type
ShowMouseAndKeyboardToggleHint,
WindowTitleFormat,
PauseDuringHomeMenu,
EnableGamemode,
// Network
InternetStatus,
@ -388,6 +390,8 @@ inline static const std::map<emu_settings_type, cfg_location> settings_location
{ emu_settings_type::SilenceAllLogs, { "Miscellaneous", "Silence All Logs" }},
{ emu_settings_type::WindowTitleFormat, { "Miscellaneous", "Window Title Format" }},
{ emu_settings_type::PauseDuringHomeMenu, { "Miscellaneous", "Pause Emulation During Home Menu" }},
{ emu_settings_type::EnableGamemode, { "Miscellaneous", "Enable GameMode" }},
// Networking
{ emu_settings_type::InternetStatus, { "Net", "Internet enabled"}},

View file

@ -15,6 +15,7 @@
#include "qt_music_handler.h"
#include "rpcs3_version.h"
#include "display_sleep_control.h"
#include "gamemode_control.h"
#ifdef WITH_DISCORD_RPC
#include "_discord_utils.h"
@ -950,6 +951,9 @@ void gui_application::InitializeCallbacks()
callbacks.display_sleep_control_supported = [](){ return display_sleep_control_supported(); };
callbacks.enable_display_sleep = [](bool enabled){ enable_display_sleep(enabled); };
callbacks.gamemode_supported = [](){ return gamemode_supported(); };
callbacks.enable_gamemode = [](bool enabled){ enable_gamemode(enabled); };
callbacks.check_microphone_permissions = []()
{
Emu.BlockingCallFromMainThread([]()

View file

@ -96,6 +96,10 @@
#define RPCS3_UPDATE_SUPPORTED
#endif
#ifdef GAMEMODE_AVAILABLE
#include "../gamemode_control.h"
#endif
LOG_CHANNEL(gui_log, "GUI");
extern atomic_t<bool> g_user_asked_for_frame_capture;
@ -285,6 +289,13 @@ bool main_window::Init([[maybe_unused]] bool with_cli_boot)
update_gui_pad_thread();
// Enable Gamemode
#if defined GAMEMODE_AVAILABLE && defined __linux__
// NOTE: Compiler complains if I pass the config value directly so I have to do this
if (g_cfg.misc.enable_gamemode) {
enable_gamemode(true);
}
#endif
return true;
}

View file

@ -1844,6 +1844,17 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
m_emu_settings->EnhanceCheckBox(ui->useNativeInterface, emu_settings_type::UseNativeInterface);
SubscribeTooltip(ui->useNativeInterface, tooltips.settings.use_native_interface);
#if defined(__linux__)
ui->enableGamemode->setVisible(true);
#endif
#if defined(GAMEMODE_AVAILABLE)
ui->enableGamemode->setEnabled(true);
m_emu_settings->EnhanceCheckBox(ui->enableGamemode, emu_settings_type::EnableGamemode);
SubscribeTooltip(ui->enableGamemode, tooltips.settings.enable_gamemode);
#else
SubscribeTooltip(ui->enableGamemode, tooltips.settings.no_gamemode);
#endif
m_emu_settings->EnhanceCheckBox(ui->showShaderCompilationHint, emu_settings_type::ShowShaderCompilationHint);
SubscribeTooltip(ui->showShaderCompilationHint, tooltips.settings.show_shader_compilation_hint);

View file

@ -3022,6 +3022,19 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableGamemode">
<property name="enabled">
<bool>false</bool>
</property>
<property name="visible">
<bool>false</bool>
</property>
<property name="text">
<string>Enable GameMode</string>
</property>
</widget>
</item>
<item>
<spacer name="emulatorTabSpacerLeft">
<property name="orientation">

View file

@ -129,6 +129,8 @@ public:
// emulator
const QString enable_gamemode = tr("Activate Feral Interactive's GameMode.\nThis is a series of CPU and GPU optimizations and can potentially benefit game performance on some systems.");
const QString no_gamemode = tr("This requires Feral Interactive's GameMode to be installed.\nGameMode is a series of CPU and GPU optimizations and can potentially benefit game performance on some systems.\nTo install GameMode for your specific Linux distribution, go to the GitHub page:https://github.com/FeralInteractive/gamemode.");
const QString exit_on_stop = tr("Automatically close RPCS3 when closing a game, or when a game closes itself.");
const QString pause_on_focus_loss = tr("Automatically pause emulation when RPCS3 loses its focus or the application is inactive in order to save power and reduce CPU usage.\nDo note that emulation pausing in general is not perfect and may not be compatible with all games.\nAlthough it currently also pauses gameplay, it is not recommended to rely on it as this behavior may be changed in the future and it is not the purpose of this setting.");
const QString start_game_fullscreen = tr("Automatically puts the game window in fullscreen.\nDouble click on the game window or press Alt+Enter to toggle fullscreen and windowed mode.");