Moved Gamemode Init out of performance critical code and placed in its own files to try and get more performance

This commit is contained in:
adas20 2025-06-24 11:07:31 -04:00
parent cd8acc9771
commit 7f37a66c9d
5 changed files with 38 additions and 22 deletions

View file

@ -63,13 +63,6 @@
#include "llvm/Config/llvm-config.h"
#endif
// GameMode Inclusion
#ifdef GAMEMODE_AVAILABLE
#pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
extern "C" {
#include "3rdparty/feralinteractive/feralinteractive/lib/gamemode_client.h"
}
LOG_CHANNEL(sys_log, "SYS");
@ -994,12 +987,6 @@ void Emulator::SetContinuousMode(bool continuous_mode)
game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch, usz recursion_count)
{
if (g_cfg.misc.enable_gamemode) {
u8 s_gamemode_start = gamemode_request_start();
if(s_gamemode_start < 0 ) {
fprintf(stderr, "gamemode start request failed: %s\n", gamemode_error_string());
}
}
if (recursion_count == 0 && m_restrict_emu_state_change)
{
@ -3067,13 +3054,6 @@ 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)
{
if (g_cfg.misc.enable_gamemode) {
u8 s_gamemode_end = gamemode_request_end();
if(s_gamemode_end < 0 ) {
fprintf(stderr, "gamemode exit request failed: %s\n", gamemode_error_string());
}
}
static const auto make_ptr = [](auto ptr)
{
return std::shared_ptr<std::remove_pointer_t<decltype(ptr)>>(ptr);

View file

@ -480,4 +480,3 @@ extern Emulator Emu;
extern bool g_use_rtm;
extern u64 g_rtm_tx_limit1;
extern u64 g_rtm_tx_limit2;
extern b8 g_FERAL_GAMEMODE_ON;

34
rpcs3/enable_gamemode.cpp Normal file
View file

@ -0,0 +1,34 @@
#include "enable_gamemode.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
}
// Enables GameMode
// Returns -2 if Gamemode isn't supported.
// Returns the value of gamemode_request_start() otherwise.
// This is either 0 or -1 depending on whether gamemode was successfully enabled or not respectively.
int enable_gamemode(bool enabled) {
if (!gamemode_supported()) {
return -2;
}
// Enable Gamemode
if (enabled) {
u8 s_gamemode_start = gamemode_request_start();
return s_gamemode_start;
}
}

4
rpcs3/enable_gamemode.h Normal file
View file

@ -0,0 +1,4 @@
#pragma once
bool gamemode_supported();
int enable_gamemode(bool enabled);

View file

@ -1315,7 +1315,6 @@ int run_rpcs3(int argc, char** argv)
Emu.Quit(true);
return 0;
}
// run event loop (maybe only needed for the gui application)
return app->exec();
}