diff --git a/Source/Core/Core/Src/ConfigManager.cpp b/Source/Core/Core/Src/ConfigManager.cpp index 4b520555c5..c26f002ff5 100644 --- a/Source/Core/Core/Src/ConfigManager.cpp +++ b/Source/Core/Core/Src/ConfigManager.cpp @@ -136,6 +136,7 @@ void SConfig::SaveSettings() // Core ini.Set("Core", "HLE_BS2", m_LocalCoreStartupParameter.bHLE_BS2); + ini.Set("Core", "EnableOpenCL", m_LocalCoreStartupParameter.bEnableOpenCL); ini.Set("Core", "CPUCore", m_LocalCoreStartupParameter.iCPUCore); ini.Set("Core", "CPUThread", m_LocalCoreStartupParameter.bCPUThread); ini.Set("Core", "DSPThread", m_LocalCoreStartupParameter.bDSPThread); @@ -260,6 +261,7 @@ void SConfig::LoadSettings() // Core ini.Get("Core", "HLE_BS2", &m_LocalCoreStartupParameter.bHLE_BS2, true); + ini.Get("Core", "EnableOpenCL", &m_LocalCoreStartupParameter.bHLE_BS2, false); ini.Get("Core", "CPUCore", &m_LocalCoreStartupParameter.iCPUCore, 1); ini.Get("Core", "DSPThread", &m_LocalCoreStartupParameter.bDSPThread, false); ini.Get("Core", "CPUThread", &m_LocalCoreStartupParameter.bCPUThread, true); diff --git a/Source/Core/Core/Src/CoreParameter.h b/Source/Core/Core/Src/CoreParameter.h index 74930873ca..0274f53eff 100644 --- a/Source/Core/Core/Src/CoreParameter.h +++ b/Source/Core/Core/Src/CoreParameter.h @@ -69,6 +69,7 @@ struct SCoreStartupParameter bool bSkipIdle; bool bNTSC; bool bHLE_BS2; + bool bEnableOpenCL; bool bUseFastMem; bool bLockThreads; bool bEnableCheats; diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index 56d129c964..9ad2067f39 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -30,6 +30,8 @@ #include "Frame.h" #include "HotkeyDlg.h" +#include "..\..\Common\Src\OpenCL.h" + #ifdef __APPLE__ #include #endif @@ -62,6 +64,7 @@ EVT_CHOICE(ID_FRAMELIMIT, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_FRAMELIMIT_USEFPSFORLIMITING, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_ALWAYS_HLE_BS2, CConfigMain::CoreSettingsChanged) +EVT_CHECKBOX(ID_ENABLE_OPENCL, CConfigMain::CoreSettingsChanged) EVT_RADIOBOX(ID_CPUENGINE, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_LOCKTHREADS, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_DSPTHREAD, CConfigMain::CoreSettingsChanged) @@ -158,6 +161,7 @@ void CConfigMain::UpdateGUI() EnableCheats->Disable(); AlwaysHLE_BS2->Disable(); + EnableOpenCL->Disable(); CPUEngine->Disable(); LockThreads->Disable(); DSPThread->Disable(); @@ -261,6 +265,7 @@ void CConfigMain::InitializeGUIValues() // General - Advanced AlwaysHLE_BS2->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bHLE_BS2); + EnableOpenCL->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableOpenCL); CPUEngine->SetSelection(SConfig::GetInstance().m_LocalCoreStartupParameter.iCPUCore); LockThreads->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bLockThreads); DSPThread->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPThread); @@ -328,6 +333,7 @@ void CConfigMain::InitializeGUITooltips() // General - Advanced DSPThread->SetToolTip(wxT("Run DSPLLE on a dedicated thread (not recommended).")); + EnableOpenCL->SetToolTip(wxT("Allow videocard to accelerate texture decoding.")); // Display - Display @@ -397,6 +403,10 @@ void CConfigMain::CreateGUIControls() // Core Settings - Advanced sbAdvanced = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, wxT("Advanced Settings")); AlwaysHLE_BS2 = new wxCheckBox(GeneralPage, ID_ALWAYS_HLE_BS2, wxT("HLE the IPL (recommended)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + EnableOpenCL = new wxCheckBox(GeneralPage, ID_ENABLE_OPENCL, wxT("Enable OpenCL"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); +#if !(defined(HAVE_OPENCL) && HAVE_OPENCL) + EnableOpenCL->Enable(false); +#endif CPUEngine = new wxRadioBox(GeneralPage, ID_CPUENGINE, wxT("CPU Emulator Engine"), wxDefaultPosition, wxDefaultSize, arrayStringFor_CPUEngine, 0, wxRA_SPECIFY_ROWS); LockThreads = new wxCheckBox(GeneralPage, ID_LOCKTHREADS, wxT("Lock threads to cores"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); DSPThread = new wxCheckBox(GeneralPage, ID_DSPTHREAD, wxT("DSPLLE on thread"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); @@ -412,6 +422,7 @@ void CConfigMain::CreateGUIControls() sbBasic->Add(sFramelimit, 0, wxALL | wxEXPAND, 5); sbAdvanced->Add(AlwaysHLE_BS2, 0, wxALL, 5); + sbAdvanced->Add(EnableOpenCL, 0, wxALL, 5); sbAdvanced->Add(CPUEngine, 0, wxALL, 5); sbAdvanced->Add(LockThreads, 0, wxALL, 5); sbAdvanced->Add(DSPThread, 0, wxALL, 5); @@ -807,6 +818,9 @@ void CConfigMain::CoreSettingsChanged(wxCommandEvent& event) case ID_ALWAYS_HLE_BS2: SConfig::GetInstance().m_LocalCoreStartupParameter.bHLE_BS2 = AlwaysHLE_BS2->IsChecked(); break; + case ID_ENABLE_OPENCL: + SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableOpenCL = EnableOpenCL->IsChecked(); + break; case ID_CPUENGINE: SConfig::GetInstance().m_LocalCoreStartupParameter.iCPUCore = CPUEngine->GetSelection(); if (main_frame->g_pCodeWindow) diff --git a/Source/Core/DolphinWX/Src/ConfigMain.h b/Source/Core/DolphinWX/Src/ConfigMain.h index 649403effe..192f4c0db0 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.h +++ b/Source/Core/DolphinWX/Src/ConfigMain.h @@ -67,6 +67,7 @@ private: // Advanced wxCheckBox* AlwaysHLE_BS2; + wxCheckBox* EnableOpenCL; wxRadioBox* CPUEngine; wxCheckBox* DSPThread; wxCheckBox* LockThreads; @@ -185,6 +186,7 @@ private: ID_FRAMELIMIT_USEFPSFORLIMITING, ID_ALWAYS_HLE_BS2, + ID_ENABLE_OPENCL, ID_CPUENGINE, ID_LOCKTHREADS, ID_DSPTHREAD, diff --git a/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp b/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp index 61218b9203..c284a9643e 100644 --- a/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp +++ b/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp @@ -45,6 +45,7 @@ #include "OpenCL.h" #if defined(HAVE_OPENCL) && HAVE_OPENCL #include "OpenCL/OCLTextureDecoder.h" +#include "VideoConfig.h" #endif u8* g_pVideoData = 0; @@ -385,8 +386,11 @@ void OpcodeDecoder_Init() g_pVideoData = FAKE_GetFifoStartPtr(); #if defined(HAVE_OPENCL) && HAVE_OPENCL - OpenCL::Initialize(); - TexDecoder_OpenCL_Initialize(); + if (g_Config.bEnableOpenCL) + { + OpenCL::Initialize(); + TexDecoder_OpenCL_Initialize(); + } #endif } @@ -394,8 +398,11 @@ void OpcodeDecoder_Init() void OpcodeDecoder_Shutdown() { #if defined(HAVE_OPENCL) && HAVE_OPENCL - TexDecoder_OpenCL_Shutdown(); - OpenCL::Destroy(); + if (g_Config.bEnableOpenCL) + { + TexDecoder_OpenCL_Shutdown(); + OpenCL::Destroy(); + } #endif } diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.cpp b/Source/Core/VideoCommon/Src/TextureDecoder.cpp index ae41f822c2..509def5a74 100644 --- a/Source/Core/VideoCommon/Src/TextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/TextureDecoder.cpp @@ -32,6 +32,7 @@ #include "OpenCL.h" #if defined(HAVE_OPENCL) && HAVE_OPENCL #include "OpenCL/OCLTextureDecoder.h" +#include "VideoConfig.h" #endif #include "LookUpTables.h" @@ -1269,7 +1270,8 @@ PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, in PC_TexFormat retval = PC_TEX_FMT_NONE; #if defined(HAVE_OPENCL) && HAVE_OPENCL - retval = TexDecoder_Decode_OpenCL(dst, src, width, height, texformat, tlutaddr, tlutfmt, rgbaOnly); + if (g_Config.bEnableOpenCL) + retval = TexDecoder_Decode_OpenCL(dst, src, width, height, texformat, tlutaddr, tlutfmt, rgbaOnly); #endif if(retval == PC_TEX_FMT_NONE) diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp index 51e2c0f86e..e3051c6e91 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.cpp +++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp @@ -107,6 +107,7 @@ void VideoConfig::Load(const char *ini_file) bool bTmp; iniFile.Get("Interface", "UsePanicHandlers", &bTmp, true); SetEnableAlert(bTmp); + iniFile.Get("Core", "EnableOpenCL", &bEnableOpenCL, false); } void VideoConfig::GameIniLoad(const char *ini_file) diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h index bbcc56da5f..7f5e45f8bf 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.h +++ b/Source/Core/VideoCommon/Src/VideoConfig.h @@ -77,6 +77,9 @@ struct VideoConfig bool bUseRealXFB; bool bAutoScale; // Removes annoying borders without using XFB. Doesn't always work perfectly. bool bUseNativeMips; + + // OpenCL + bool bEnableOpenCL; // Enhancements int iMultisampleMode;