VMManager: Add SetDefaultSettings()

Also removes the affinity control default for <=2 threads, best to let
the OS handle this.
This commit is contained in:
Connor McLaughlin 2022-09-07 17:41:39 +10:00 committed by refractionpcsx2
parent 1b3bf89ee8
commit d86abebb50
3 changed files with 27 additions and 26 deletions

View File

@ -237,19 +237,12 @@ bool QtHost::InitializeConfig()
void QtHost::SetDefaultConfig() void QtHost::SetDefaultConfig()
{ {
EmuConfig = Pcsx2Config();
EmuFolders::SetDefaults(); EmuFolders::SetDefaults();
EmuFolders::EnsureFoldersExist(); EmuFolders::EnsureFoldersExist();
VMManager::SetHardwareDependentDefaultSettings(EmuConfig);
SettingsInterface& si = *s_base_settings_interface.get(); SettingsInterface& si = *s_base_settings_interface.get();
si.SetUIntValue("UI", "SettingsVersion", SETTINGS_VERSION); si.SetUIntValue("UI", "SettingsVersion", SETTINGS_VERSION);
VMManager::SetDefaultSettings(si);
{
SettingsSaveWrapper wrapper(si);
EmuConfig.LoadSave(wrapper);
}
EmuFolders::Save(si); EmuFolders::Save(si);
PAD::SetDefaultControllerConfig(si); PAD::SetDefaultControllerConfig(si);
PAD::SetDefaultHotkeyConfig(si); PAD::SetDefaultHotkeyConfig(si);

View File

@ -102,6 +102,7 @@ namespace VMManager
std::string filename, s32 slot_for_message); std::string filename, s32 slot_for_message);
static void SetTimerResolutionIncreased(bool enabled); static void SetTimerResolutionIncreased(bool enabled);
static void SetHardwareDependentDefaultSettings(SettingsInterface& si);
static void EnsureCPUInfoInitialized(); static void EnsureCPUInfoInitialized();
static void SetEmuThreadAffinities(); static void SetEmuThreadAffinities();
} // namespace VMManager } // namespace VMManager
@ -1703,6 +1704,20 @@ bool VMManager::ReloadGameSettings()
return true; return true;
} }
void VMManager::SetDefaultSettings(SettingsInterface& si)
{
{
Pcsx2Config temp_config;
SettingsSaveWrapper ssw(si);
temp_config.LoadSave(ssw);
}
// Settings not part of the Pcsx2Config struct.
si.SetBoolValue("EmuCore", "EnableFastBoot", true);
SetHardwareDependentDefaultSettings(si);
}
static void HotkeyAdjustTargetSpeed(double delta) static void HotkeyAdjustTargetSpeed(double delta)
{ {
EmuConfig.Framerate.NominalScalar = EmuConfig.GS.LimitScalar + delta; EmuConfig.Framerate.NominalScalar = EmuConfig.GS.LimitScalar + delta;
@ -2003,7 +2018,7 @@ static void InitializeCPUInfo()
Console.WriteLn(ss.str()); Console.WriteLn(ss.str());
} }
static void SetMTVUAndAffinityControlDefault(Pcsx2Config& config) static void SetMTVUAndAffinityControlDefault(SettingsInterface& si)
{ {
VMManager::EnsureCPUInfoInitialized(); VMManager::EnsureCPUInfoInitialized();
@ -2029,23 +2044,16 @@ static void SetMTVUAndAffinityControlDefault(Pcsx2Config& config)
const u32 big_cores = cpuinfo_get_cluster(0)->core_count + ((cluster_count > 2) ? cpuinfo_get_cluster(1)->core_count : 0u); const u32 big_cores = cpuinfo_get_cluster(0)->core_count + ((cluster_count > 2) ? cpuinfo_get_cluster(1)->core_count : 0u);
Console.WriteLn("Guessing we have %u big/medium cores...", big_cores); Console.WriteLn("Guessing we have %u big/medium cores...", big_cores);
bool mtvu_enable; if (big_cores >= 3)
bool affinity_control;
if (big_cores >= 3 || big_cores == 1)
{ {
Console.WriteLn(" So enabling MTVU and disabling affinity control"); Console.WriteLn(" So enabling MTVU.");
mtvu_enable = true; si.SetBoolValue("EmuCore/Speedhacks", "vuThread", true);
affinity_control = false;
} }
else else
{ {
Console.WriteLn(" So disabling MTVU and enabling affinity control"); Console.WriteLn(" So disabling MTVU.");
mtvu_enable = false; si.SetBoolValue("EmuCore/Speedhacks", "vuThread", false);
affinity_control = true;
} }
config.Speedhacks.vuThread = mtvu_enable;
config.Cpu.AffinityControlMode = affinity_control ? 1 : 0;
} }
#else #else
@ -2055,7 +2063,7 @@ static void InitializeCPUInfo()
DevCon.WriteLn("(VMManager) InitializeCPUInfo() not implemented."); DevCon.WriteLn("(VMManager) InitializeCPUInfo() not implemented.");
} }
static void SetMTVUAndAffinityControlDefault(Pcsx2Config& config) static void SetMTVUAndAffinityControlDefault(SettingsInterface& si)
{ {
} }
@ -2127,9 +2135,9 @@ void VMManager::SetEmuThreadAffinities()
GetMTGS().GetThreadHandle().SetAffinity(gs_affinity); GetMTGS().GetThreadHandle().SetAffinity(gs_affinity);
} }
void VMManager::SetHardwareDependentDefaultSettings(Pcsx2Config& config) void VMManager::SetHardwareDependentDefaultSettings(SettingsInterface& si)
{ {
SetMTVUAndAffinityControlDefault(config); SetMTVUAndAffinityControlDefault(si);
} }
const std::vector<u32>& VMManager::GetSortedProcessorList() const std::vector<u32>& VMManager::GetSortedProcessorList()

View File

@ -165,8 +165,8 @@ namespace VMManager
/// If the scale is set to 0, the internal resolution will be used, otherwise it is treated as a multiplier to 1x. /// If the scale is set to 0, the internal resolution will be used, otherwise it is treated as a multiplier to 1x.
void RequestDisplaySize(float scale = 0.0f); void RequestDisplaySize(float scale = 0.0f);
/// Sets default settings based on hardware configuration. /// Initializes default configuration in the specified file.
void SetHardwareDependentDefaultSettings(Pcsx2Config& config); void SetDefaultSettings(SettingsInterface& si);
/// Returns a list of processors in the system, and their corresponding affinity mask. /// Returns a list of processors in the system, and their corresponding affinity mask.
/// This list is ordered by most performant to least performant for pinning threads to. /// This list is ordered by most performant to least performant for pinning threads to.