Skip to content

Commit 7b2cc23

Browse files
committed
adjust according to performance profiling
optimize async sound loads by starting load early allow for 0 decals some more details on the threading changes: with a queued renderer, having the character rendering be threaded has a lot of contention with locks, especially in the queue. cl_threaded_bone_setup 1 seems to work client leaf system was causing hitches when it was not threaded.
1 parent 32ca9c9 commit 7b2cc23

File tree

5 files changed

+40
-30
lines changed

5 files changed

+40
-30
lines changed

engine/audio/private/snd_wave_data.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,19 +2071,20 @@ bool CWaveDataStreamAsync::IsReadyToMix()
20712071
{
20722072
if ( IsPC() )
20732073
{
2074-
// If not async loaded, start mixing right away
2075-
if ( !m_source.IsAsyncLoad() && !snd_async_fullyasync.GetBool() )
2076-
{
2077-
return true;
2078-
}
2079-
2074+
// Notify load
20802075
bool bCacheValid;
20812076
bool bLoaded = wavedatacache->IsDataLoadCompleted( m_hCache, &bCacheValid );
20822077
if ( !bCacheValid )
20832078
{
20842079
wavedatacache->RestartDataLoad( &m_hCache, GetFileName(), m_dataSize, m_dataStart );
20852080
}
2086-
return bLoaded;
2081+
2082+
// Start mixing right away unless not loaded
2083+
if (bLoaded || !m_source.IsAsyncLoad() && !snd_async_fullyasync.GetBool())
2084+
{
2085+
return true;
2086+
}
2087+
return false;
20872088
}
20882089

20892090
if ( IsX360() )
@@ -2334,11 +2335,10 @@ bool CWaveDataMemoryAsync::IsReadyToMix()
23342335
if ( !m_source.IsAsyncLoad() && !snd_async_fullyasync.GetBool() )
23352336
{
23362337
// Wait until we're pending at least
2337-
if ( m_source.GetCacheStatus() == CAudioSource::AUDIO_NOT_LOADED )
2338+
if ( m_source.GetCacheStatus() != CAudioSource::AUDIO_NOT_LOADED )
23382339
{
2339-
return false;
2340+
return true;
23402341
}
2341-
return true;
23422342
}
23432343

23442344
if ( m_source.IsCached() )

engine/r_decal.cpp

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -823,18 +823,31 @@ static decal_t *R_DecalAlloc( int flags )
823823

824824
if ( iSlot == -1 )
825825
{
826-
iSlot = R_FindDynamicDecalSlot( g_iLastReplacedDynamic+1 );
827-
if ( iSlot == -1 )
826+
// if the user has requested 0 decals, let them
827+
if (dynamicDecalLimit > 0)
828+
{
829+
iSlot = R_FindDynamicDecalSlot(g_iLastReplacedDynamic + 1);
830+
if ( iSlot == -1 )
831+
{
832+
if ( !bWarningOnce )
833+
{
834+
// Can't find a free slot. Just kill the first one.
835+
DevWarning( 1, "Exceeded MAX_DECALS (%d).\n", g_nMaxDecals );
836+
bWarningOnce = true;
837+
}
838+
iSlot = 0;
839+
}
840+
}
841+
else if (bPermanent)
828842
{
829-
if ( !bWarningOnce )
830-
{
831-
// Can't find a free slot. Just kill the first one.
832-
DevWarning( 1, "Exceeded MAX_DECALS (%d).\n", g_nMaxDecals );
833-
bWarningOnce = true;
834-
}
835843
iSlot = 0;
836844
}
837845

846+
if (iSlot == -1)
847+
{
848+
return NULL;
849+
}
850+
838851
R_DecalUnlink( s_aDecalPool[iSlot], host_state.worldbrush );
839852
g_iLastReplacedDynamic = iSlot;
840853
}
@@ -1700,6 +1713,11 @@ static void R_DecalCreate( decalinfo_t* decalinfo, SurfaceHandle_t surfID, float
17001713
}
17011714

17021715
pdecal = R_DecalAlloc( decalinfo->m_Flags );
1716+
1717+
if (!pdecal)
1718+
{
1719+
return;
1720+
}
17031721

17041722
pdecal->flags = decalinfo->m_Flags;
17051723
pdecal->color = decalinfo->m_Color;

game/client/c_baseanimating.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2728,7 +2728,7 @@ ConVar cl_warn_thread_contested_bone_setup("cl_warn_thread_contested_bone_setup"
27282728
// Marked this developmentonly because it currently crashes, and users are enabling it and complaining because of
27292729
// course. Once this actually works it should just be FCVAR_INTERNAL_USE.
27302730
// UNDONE(mastercoms)
2731-
ConVar cl_threaded_bone_setup("cl_threaded_bone_setup", "0", FCVAR_INTERNAL_USE,
2731+
ConVar cl_threaded_bone_setup("cl_threaded_bone_setup", "1", FCVAR_INTERNAL_USE,
27322732
"Enable parallel processing of C_BaseAnimating::SetupBones()" );
27332733

27342734
//-----------------------------------------------------------------------------

game/client/clientleafsystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class VMatrix; // forward decl
3232
static ConVar cl_drawleaf("cl_drawleaf", "-1", FCVAR_CHEAT );
3333
static ConVar r_PortalTestEnts( "r_PortalTestEnts", "1", FCVAR_CHEAT, "Clip entities against portal frustums." );
3434
static ConVar r_portalsopenall( "r_portalsopenall", "0", FCVAR_CHEAT, "Open all portals" );
35-
static ConVar cl_threaded_client_leaf_system("cl_threaded_client_leaf_system", "0" );
35+
static ConVar cl_threaded_client_leaf_system("cl_threaded_client_leaf_system", "1" );
3636

3737

3838
DEFINE_FIXEDSIZE_ALLOCATOR( CClientRenderablesList, 1, CUtlMemoryPool::GROW_SLOW );

game/client/viewrender.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ ConVar r_drawviewmodel( "r_drawviewmodel","1", FCVAR_CHEAT );
116116
#endif
117117
static ConVar r_drawtranslucentrenderables( "r_drawtranslucentrenderables", "1", FCVAR_CHEAT );
118118
static ConVar r_drawopaquerenderables( "r_drawopaquerenderables", "1", FCVAR_CHEAT );
119-
static ConVar r_threaded_renderables( "r_threaded_renderables", "1" );
120-
static ConVar r_threaded_character_rendering("r_threaded_character_rendering", "1");
119+
static ConVar r_threaded_renderables( "r_threaded_renderables", "0" );
121120

122121
// FIXME: This is not static because we needed to turn it off for TF2 playtests
123122
ConVar r_DrawDetailProps( "r_DrawDetailProps", "1", FCVAR_NONE, "0=Off, 1=Normal, 2=Wireframe" );
@@ -4159,14 +4158,7 @@ void CRendering3dView::DrawOpaqueRenderables( ERenderDepthMode DepthMode )
41594158
//
41604159
// Draw NPCs now
41614160
//
4162-
if (r_threaded_character_rendering.GetBool())
4163-
{
4164-
DrawOpaqueRenderables_Parallel(arrRenderEntsNpcsFirst.Base(), numNpcs, DepthMode, "Draw NPCs");
4165-
}
4166-
else
4167-
{
4168-
DrawOpaqueRenderables_Range(arrRenderEntsNpcsFirst.Base(), arrRenderEntsNpcsFirst.Base() + numNpcs, DepthMode);
4169-
}
4161+
DrawOpaqueRenderables_Range(arrRenderEntsNpcsFirst.Base(), arrRenderEntsNpcsFirst.Base() + numNpcs, DepthMode);
41704162

41714163
//
41724164
// Ropes and particles

0 commit comments

Comments
 (0)