Skip to content

Commit

Permalink
engine, vstdlib: Leave threadpool affinity only for consoles (newer c…
Browse files Browse the repository at this point in the history
…sgo had it removed)
  • Loading branch information
tyabus committed Sep 3, 2023
1 parent 4dff8b6 commit 0e22916
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions engine/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,9 @@ enum HostThreadMode
ConVar host_thread_mode( "host_thread_mode", ( IsPlatformX360() || IsPlatformPS3() ) ? "1" : "0", FCVAR_DEVELOPMENTONLY, "Run the host in threaded mode, (0 == off, 1 == if multicore, 2 == force)" );
ConVar host_threaded_sound( "host_threaded_sound", ( IsPlatformX360() || IsPlatformPS3()) ? "1" : "0", 0, "Run the sound on a thread (independent of mix)" );
ConVar host_threaded_sound_simplethread( "host_threaded_sound_simplethread", ( IsPlatformPS3()) ? "1" : "0", 0, "Run the sound on a simple thread not a jobthread" );

// Threadpool affinity is no more in newer csgo
#if defined( _X360 ) || defined( _PS3 )
extern ConVar threadpool_affinity;
void OnChangeThreadAffinity( IConVar *var, const char *pOldValue, float flOldValue )
{
Expand All @@ -652,6 +655,7 @@ void OnChangeThreadAffinity( IConVar *var, const char *pOldValue, float flOldVal
}

ConVar threadpool_affinity( "threadpool_affinity", "1", 0, "Enable setting affinity", 0, 0, 0, 0, &OnChangeThreadAffinity );
#endif

extern ConVar threadpool_reserve;
CThreadEvent g_ReleaseThreadReservation( true );
Expand Down
6 changes: 6 additions & 0 deletions vstdlib/jobthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,10 @@ bool CThreadPool::Start( const ThreadPoolStartParams_t &startParams, const char
ThreadSetPriority( (ThreadHandle_t)m_Threads[iThread]->GetThreadHandle(), priority );
}

// Threadpool affinity is no more in newer csgo
#if defined( _X360 ) || defined( _PS3 )
Distribute( bDistribute, startParams.bUseAffinityTable ? (int *)startParams.iAffinityTable : NULL );
#endif

return true;
}
Expand All @@ -1106,6 +1109,8 @@ bool CThreadPool::Start( const ThreadPoolStartParams_t &startParams, const char

void CThreadPool::Distribute( bool bDistribute, int *pAffinityTable )
{
// Threadpool affinity is no more in newer csgo
#if defined( _X360 ) || defined( _PS3 )
if ( bDistribute )
{
const CPUInformation &ci = GetCPUInformation();
Expand Down Expand Up @@ -1183,6 +1188,7 @@ void CThreadPool::Distribute( bool bDistribute, int *pAffinityTable )
}
#endif
}
#endif // _X360 || _PS3
}

//---------------------------------------------------------
Expand Down

0 comments on commit 0e22916

Please sign in to comment.