@@ -1207,6 +1207,12 @@ void CSettings::CreateGUI()
12071207 m_pPhotoSavingCheckbox->AutoSize (NULL , 20 .0f );
12081208 vecTemp.fY += fLineHeight ;
12091209
1210+ // Process affinity
1211+ m_pProcessAffinityCheckbox = reinterpret_cast <CGUICheckBox*>(pManager->CreateCheckBox (pTabAdvanced, _ (" Set CPU 0 affinity to improve game performance" ), true ));
1212+ m_pProcessAffinityCheckbox->SetPosition (CVector2D (vecTemp.fX , vecTemp.fY ));
1213+ m_pProcessAffinityCheckbox->AutoSize (nullptr , 20 .0f );
1214+ vecTemp.fY += fLineHeight ;
1215+
12101216 // Auto updater section label
12111217 m_pAdvancedUpdaterLabel = reinterpret_cast <CGUILabel*>(pManager->CreateLabel (pTabAdvanced, _ (" Auto updater" )));
12121218 m_pAdvancedUpdaterLabel->SetPosition (CVector2D (vecTemp.fX - 10 .0f , vecTemp.fY ));
@@ -3228,6 +3234,22 @@ void CSettings::LoadData()
32283234 CVARS_GET (" photosaving" , bVar);
32293235 m_pPhotoSavingCheckbox->SetSelected (bVar);
32303236
3237+ // Process CPU Affinity
3238+ CVARS_GET (" process_cpu_affinity" , bVar);
3239+ m_pProcessAffinityCheckbox->SetSelected (bVar);
3240+
3241+ DWORD_PTR affinityMask = 0 ;
3242+ if (bVar)
3243+ affinityMask = 1 << 0 ; // CPU 0 only
3244+ else
3245+ {
3246+ SYSTEM_INFO sysInfo;
3247+ GetSystemInfo (&sysInfo);
3248+
3249+ affinityMask = (1 << sysInfo.dwNumberOfProcessors ) - 1 ; // All cores (default)
3250+ }
3251+ SetProcessAffinityMask (GetCurrentProcess (), affinityMask);
3252+
32313253 // Update build type
32323254 CVARS_GET (" update_build_type" , iVar);
32333255 if (iVar == 0 || iVar == 1 )
@@ -3624,6 +3646,22 @@ void CSettings::SaveData()
36243646 CVARS_SET (" photosaving" , photoSaving);
36253647 CScreenShot::SetPhotoSavingInsideDocuments (photoSaving);
36263648
3649+ // Process CPU Affinity
3650+ bool cpuAffinity = m_pProcessAffinityCheckbox->GetSelected ();
3651+ CVARS_SET (" process_cpu_affinity" , cpuAffinity);
3652+
3653+ DWORD_PTR affinityMask = 0 ;
3654+ if (cpuAffinity)
3655+ affinityMask = 1 << 0 ; // CPU 0 only
3656+ else
3657+ {
3658+ SYSTEM_INFO sysInfo;
3659+ GetSystemInfo (&sysInfo);
3660+
3661+ affinityMask = (1 << sysInfo.dwNumberOfProcessors ) - 1 ; // All cores (default)
3662+ }
3663+ SetProcessAffinityMask (GetCurrentProcess (), affinityMask);
3664+
36273665 // Debug setting
36283666 if (CGUIListItem* pSelected = m_pDebugSettingCombo->GetSelectedItem ())
36293667 {
0 commit comments