From 2140ac15e45ef3f555d426fc3ee65e7d76251933 Mon Sep 17 00:00:00 2001 From: skidau Date: Wed, 29 Oct 2014 23:22:17 +1100 Subject: [PATCH 1/3] Removed the DSP LLE on separate thread option. The DSP thread will be enabled if the game is an AX ucode game and if the host has more than two cores (not including hyperthreading). --- Source/Core/Core/BootManager.cpp | 3 --- Source/Core/Core/ConfigManager.cpp | 2 -- Source/Core/Core/Core.cpp | 5 +++++ Source/Core/Core/CoreParameter.cpp | 1 - Source/Core/Core/HW/DSPLLE/DSPLLE.cpp | 17 +++++++++++++++++ Source/Core/DolphinWX/ConfigMain.cpp | 10 ---------- Source/Core/DolphinWX/ConfigMain.h | 2 -- 7 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index 2152e4e546..f74ca281a1 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -125,7 +125,6 @@ bool BootCore(const std::string& _rFilename) config_cache.strBackend = StartUp.m_strVideoBackend; config_cache.m_strGPUDeterminismMode = StartUp.m_strGPUDeterminismMode; config_cache.m_EnableJIT = SConfig::GetInstance().m_DSPEnableJIT; - config_cache.bDSPThread = StartUp.bDSPThread; config_cache.Volume = SConfig::GetInstance().m_Volume; config_cache.sBackend = SConfig::GetInstance().sBackend; config_cache.framelimit = SConfig::GetInstance().m_Framelimit; @@ -165,7 +164,6 @@ bool BootCore(const std::string& _rFilename) core_section->Get("FastDiscSpeed", &StartUp.bFastDiscSpeed, StartUp.bFastDiscSpeed); core_section->Get("BlockMerging", &StartUp.bMergeBlocks, StartUp.bMergeBlocks); core_section->Get("DSPHLE", &StartUp.bDSPHLE, StartUp.bDSPHLE); - core_section->Get("DSPThread", &StartUp.bDSPThread, StartUp.bDSPThread); core_section->Get("GFXBackend", &StartUp.m_strVideoBackend, StartUp.m_strVideoBackend); core_section->Get("CPUCore", &StartUp.iCPUCore, StartUp.iCPUCore); core_section->Get("HLE_BS2", &StartUp.bHLE_BS2, StartUp.bHLE_BS2); @@ -292,7 +290,6 @@ void Stop() StartUp.bFastDiscSpeed = config_cache.bFastDiscSpeed; StartUp.bMergeBlocks = config_cache.bMergeBlocks; StartUp.bDSPHLE = config_cache.bDSPHLE; - StartUp.bDSPThread = config_cache.bDSPThread; StartUp.m_strVideoBackend = config_cache.strBackend; StartUp.m_strGPUDeterminismMode = config_cache.m_strGPUDeterminismMode; VideoBackend::ActivateBackend(StartUp.m_strVideoBackend); diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index a18af93913..a15538ab63 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -289,7 +289,6 @@ void SConfig::SaveCoreSettings(IniFile& ini) core->Set("CPUCore", m_LocalCoreStartupParameter.iCPUCore); core->Set("Fastmem", m_LocalCoreStartupParameter.bFastmem); core->Set("CPUThread", m_LocalCoreStartupParameter.bCPUThread); - core->Set("DSPThread", m_LocalCoreStartupParameter.bDSPThread); core->Set("DSPHLE", m_LocalCoreStartupParameter.bDSPHLE); core->Set("SkipIdle", m_LocalCoreStartupParameter.bSkipIdle); core->Set("DefaultISO", m_LocalCoreStartupParameter.m_strDefaultISO); @@ -508,7 +507,6 @@ void SConfig::LoadCoreSettings(IniFile& ini) core->Get("CPUCore", &m_LocalCoreStartupParameter.iCPUCore, SCoreStartupParameter::CORE_INTERPRETER); #endif core->Get("Fastmem", &m_LocalCoreStartupParameter.bFastmem, true); - core->Get("DSPThread", &m_LocalCoreStartupParameter.bDSPThread, false); core->Get("DSPHLE", &m_LocalCoreStartupParameter.bDSPHLE, true); core->Get("CPUThread", &m_LocalCoreStartupParameter.bCPUThread, true); core->Get("SkipIdle", &m_LocalCoreStartupParameter.bSkipIdle, true); diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 5d2ff0ab96..f8d7326c6e 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -348,6 +348,11 @@ void EmuThread() OSD::AddMessage("Dolphin " + g_video_backend->GetName() + " Video Backend.", 5000); + if (cpu_info.HTT) + SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPThread = cpu_info.num_cores > 4; + else + SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPThread = cpu_info.num_cores > 2; + if (!DSP::GetDSPEmulator()->Initialize(core_parameter.bWii, core_parameter.bDSPThread)) { HW::Shutdown(); diff --git a/Source/Core/Core/CoreParameter.cpp b/Source/Core/Core/CoreParameter.cpp index bef3eb9f52..b7b46325db 100644 --- a/Source/Core/Core/CoreParameter.cpp +++ b/Source/Core/Core/CoreParameter.cpp @@ -71,7 +71,6 @@ void SCoreStartupParameter::LoadDefaults() bSkipIdle = false; bRunCompareServer = false; bDSPHLE = true; - bDSPThread = true; bFastmem = true; bFPRF = false; bBAT = false; diff --git a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp index fdd1aefaf3..b1180a1b47 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp @@ -40,6 +40,7 @@ DSPLLE::DSPLLE() static Common::Event dspEvent; static Common::Event ppcEvent; +static bool requestDisableThread; void DSPLLE::DoState(PointerWrap &p) { @@ -161,6 +162,7 @@ bool DSPLLE::Initialize(bool bWii, bool bDSPThread) { m_bWii = bWii; m_bDSPThread = bDSPThread; + requestDisableThread = false; DSPInitOptions opts; if (!FillDSPInitOptions(&opts)) @@ -209,6 +211,13 @@ u16 DSPLLE::DSP_WriteControlRegister(u16 _uFlag) // and immediately process it, if it has. if (_uFlag & 2) { + if (m_bDSPThread) + { + // External interrupt pending: this is the zelda ucode. + // Disable the DSP thread because there is no performance gain. + requestDisableThread = true; + } + if (!m_bDSPThread) { DSPCore_CheckExternalInterrupt(); @@ -305,6 +314,14 @@ void DSPLLE::DSP_Update(int cycles) soundStream->Update(); } */ + if (requestDisableThread) + { + DSP_StopSoundStream(); + m_bDSPThread = false; + requestDisableThread = false; + SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPThread = false; + } + // If we're not on a thread, run cycles here. if (!m_bDSPThread) { diff --git a/Source/Core/DolphinWX/ConfigMain.cpp b/Source/Core/DolphinWX/ConfigMain.cpp index 835d6f6a8a..a8d1e0fbc9 100644 --- a/Source/Core/DolphinWX/ConfigMain.cpp +++ b/Source/Core/DolphinWX/ConfigMain.cpp @@ -144,7 +144,6 @@ EVT_CHECKBOX(ID_NTSCJ, CConfigMain::CoreSettingsChanged) EVT_RADIOBOX(ID_DSPENGINE, CConfigMain::AudioSettingsChanged) -EVT_CHECKBOX(ID_DSPTHREAD, CConfigMain::AudioSettingsChanged) EVT_CHECKBOX(ID_ENABLE_THROTTLE, CConfigMain::AudioSettingsChanged) EVT_CHECKBOX(ID_DPL2DECODER, CConfigMain::AudioSettingsChanged) EVT_CHOICE(ID_BACKEND, CConfigMain::AudioSettingsChanged) @@ -240,7 +239,6 @@ void CConfigMain::UpdateGUI() // Disable stuff on AudioPage DSPEngine->Disable(); - DSPThread->Disable(); DPL2Decoder->Disable(); Latency->Disable(); @@ -373,7 +371,6 @@ void CConfigMain::InitializeGUIValues() VolumeSlider->Enable(SupportsVolumeChanges(SConfig::GetInstance().sBackend)); VolumeSlider->SetValue(SConfig::GetInstance().m_Volume); VolumeText->SetLabel(wxString::Format("%d %%", SConfig::GetInstance().m_Volume)); - DSPThread->SetValue(startup_params.bDSPThread); DPL2Decoder->Enable(std::string(SConfig::GetInstance().sBackend) == BACKEND_OPENAL); DPL2Decoder->SetValue(startup_params.bDPL2Decoder); Latency->Enable(std::string(SConfig::GetInstance().sBackend) == BACKEND_OPENAL); @@ -524,7 +521,6 @@ void CConfigMain::InitializeGUITooltips() InterfaceLang->SetToolTip(_("Change the language of the user interface.\nRequires restart.")); // Audio tooltips - DSPThread->SetToolTip(_("Run DSP LLE on a dedicated thread (not recommended: might cause freezes).")); BackendSelection->SetToolTip(_("Changing this will have no effect while the emulator is running!")); // GameCube - Devices @@ -655,7 +651,6 @@ void CConfigMain::CreateGUIControls() // Audio page DSPEngine = new wxRadioBox(AudioPage, ID_DSPENGINE, _("DSP Emulator Engine"), wxDefaultPosition, wxDefaultSize, arrayStringFor_DSPEngine, 0, wxRA_SPECIFY_ROWS); - DSPThread = new wxCheckBox(AudioPage, ID_DSPTHREAD, _("DSPLLE on Separate Thread")); DPL2Decoder = new wxCheckBox(AudioPage, ID_DPL2DECODER, _("Dolby Pro Logic II decoder")); VolumeSlider = new wxSlider(AudioPage, ID_VOLUME, 0, 1, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL|wxSL_INVERSE); VolumeText = new wxStaticText(AudioPage, wxID_ANY, ""); @@ -674,7 +669,6 @@ void CConfigMain::CreateGUIControls() // Create sizer and add items to dialog wxStaticBoxSizer *sbAudioSettings = new wxStaticBoxSizer(wxVERTICAL, AudioPage, _("Sound Settings")); sbAudioSettings->Add(DSPEngine, 0, wxALL | wxEXPAND, 5); - sbAudioSettings->Add(DSPThread, 0, wxALL, 5); sbAudioSettings->Add(DPL2Decoder, 0, wxALL, 5); wxStaticBoxSizer *sbVolume = new wxStaticBoxSizer(wxVERTICAL, AudioPage, _("Volume")); @@ -973,10 +967,6 @@ void CConfigMain::AudioSettingsChanged(wxCommandEvent& event) VolumeText->SetLabel(wxString::Format("%d %%", VolumeSlider->GetValue())); break; - case ID_DSPTHREAD: - SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPThread = DSPThread->IsChecked(); - break; - case ID_DPL2DECODER: SConfig::GetInstance().m_LocalCoreStartupParameter.bDPL2Decoder = DPL2Decoder->IsChecked(); break; diff --git a/Source/Core/DolphinWX/ConfigMain.h b/Source/Core/DolphinWX/ConfigMain.h index 02791a1c74..6a12189048 100644 --- a/Source/Core/DolphinWX/ConfigMain.h +++ b/Source/Core/DolphinWX/ConfigMain.h @@ -80,7 +80,6 @@ private: ID_FRAMELIMIT, ID_CPUENGINE, - ID_DSPTHREAD, ID_NTSCJ, @@ -149,7 +148,6 @@ private: // Advanced wxRadioBox* CPUEngine; - wxCheckBox* DSPThread; wxCheckBox* _NTSCJ; From 5c862adfa71b246612612edb2cf1439515538c8a Mon Sep 17 00:00:00 2001 From: skidau Date: Fri, 31 Oct 2014 12:12:24 +1100 Subject: [PATCH 2/3] Disabled the DSP thread if netplay or a movie has been started --- Source/Core/Core/HW/DSPLLE/DSPLLE.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp index b1180a1b47..2d245348a9 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp @@ -17,6 +17,8 @@ #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/Host.h" +#include "Core/Movie.h" +#include "Core/NetPlayProto.h" #include "Core/DSP/DSPCaptureLogger.h" #include "Core/DSP/DSPCore.h" #include "Core/DSP/DSPDisassembler.h" @@ -31,7 +33,6 @@ #include "Core/HW/DSPLLE/DSPLLEGlobals.h" #include "Core/HW/DSPLLE/DSPSymbols.h" - DSPLLE::DSPLLE() { m_bIsRunning = false; @@ -314,12 +315,15 @@ void DSPLLE::DSP_Update(int cycles) soundStream->Update(); } */ - if (requestDisableThread) + if (m_bDSPThread) { - DSP_StopSoundStream(); - m_bDSPThread = false; - requestDisableThread = false; - SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPThread = false; + if (requestDisableThread || NetPlay::IsNetPlayRunning() || Movie::IsMovieActive()) + { + DSP_StopSoundStream(); + m_bDSPThread = false; + requestDisableThread = false; + SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPThread = false; + } } // If we're not on a thread, run cycles here. From baaccfd2f07dba0584b9391ce4ad5015e95d0081 Mon Sep 17 00:00:00 2001 From: skidau Date: Sat, 1 Nov 2014 13:57:24 +1100 Subject: [PATCH 3/3] Take into account the want_determinism option and do not create a DSP thread if determinism is needed. --- Source/Core/Core/HW/DSPLLE/DSPLLE.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp index 2d245348a9..ee3e2bcb9b 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp @@ -162,7 +162,9 @@ static bool FillDSPInitOptions(DSPInitOptions* opts) bool DSPLLE::Initialize(bool bWii, bool bDSPThread) { m_bWii = bWii; - m_bDSPThread = bDSPThread; + m_bDSPThread = true; + if (NetPlay::IsNetPlayRunning() || Movie::IsMovieActive() || Core::g_want_determinism || !bDSPThread) + m_bDSPThread = false; requestDisableThread = false; DSPInitOptions opts; @@ -317,7 +319,7 @@ void DSPLLE::DSP_Update(int cycles) */ if (m_bDSPThread) { - if (requestDisableThread || NetPlay::IsNetPlayRunning() || Movie::IsMovieActive()) + if (requestDisableThread || NetPlay::IsNetPlayRunning() || Movie::IsMovieActive() || Core::g_want_determinism) { DSP_StopSoundStream(); m_bDSPThread = false;