@@ -1029,7 +1029,7 @@ bool CMaterialSystem::AllowThreading( bool bAllow, int nServiceThread )
1029
1029
1030
1030
bool bOldAllow = m_bAllowQueuedRendering;
1031
1031
1032
- if ( GetCPUInformation ()->m_nPhysicalProcessors >= 2 )
1032
+ if ( GetCPUInformation ()->m_nLogicalProcessors >= 2 )
1033
1033
{
1034
1034
m_bAllowQueuedRendering = bAllow;
1035
1035
bool bQueued = m_IdealThreadMode != MATERIAL_SINGLE_THREADED;
@@ -1806,11 +1806,7 @@ static ConVar mat_normalmaps( "mat_normalmaps", "0", FCVAR_CHEAT );
1806
1806
static ConVar mat_measurefillrate ( " mat_measurefillrate" , " 0" , FCVAR_CHEAT );
1807
1807
static ConVar mat_fillrate ( " mat_fillrate" , " 0" , FCVAR_CHEAT );
1808
1808
static ConVar mat_reversedepth ( " mat_reversedepth" , " 0" , FCVAR_CHEAT );
1809
- #ifdef DX_TO_GL_ABSTRACTION
1810
- static ConVar mat_bufferprimitives ( " mat_bufferprimitives" , " 0" ); // I'm not seeing any benefit speed wise for buffered primitives on GLM/POSIX (checked via TF2 timedemo) - default to zero
1811
- #else
1812
1809
static ConVar mat_bufferprimitives ( " mat_bufferprimitives" , " 1" );
1813
- #endif
1814
1810
static ConVar mat_drawflat ( " mat_drawflat" ," 0" , FCVAR_CHEAT );
1815
1811
static ConVar mat_softwarelighting ( " mat_softwarelighting" , " 0" , FCVAR_ALLOWED_IN_COMPETITIVE );
1816
1812
static ConVar mat_proxy ( " mat_proxy" , " 0" , FCVAR_CHEAT, " " , MatProxyCallback );
@@ -2780,8 +2776,8 @@ IMaterial* CMaterialSystem::FindMaterialEx( char const* pMaterialName, const cha
2780
2776
{
2781
2777
// We need lower-case symbols for this to work
2782
2778
int nLen = Q_strlen ( pMaterialName ) + 1 ;
2783
- char *pFixedNameTemp = (char *)malloc ( nLen );
2784
- char *pTemp = (char *)malloc ( nLen );
2779
+ char *pFixedNameTemp = (char *)stackalloc ( nLen );
2780
+ char *pTemp = (char *)stackalloc ( nLen );
2785
2781
Q_strncpy ( pFixedNameTemp, pMaterialName, nLen );
2786
2782
Q_strlower ( pFixedNameTemp );
2787
2783
#ifdef POSIX
@@ -2883,9 +2879,6 @@ IMaterial* CMaterialSystem::FindMaterialEx( char const* pMaterialName, const cha
2883
2879
}
2884
2880
}
2885
2881
2886
- free (pTemp);
2887
- free (pFixedNameTemp);
2888
-
2889
2882
return g_pErrorMaterial->GetRealTimeVersion ();
2890
2883
}
2891
2884
@@ -3103,20 +3096,12 @@ void CMaterialSystem::ResetTempHWMemory( bool bExitingLevel )
3103
3096
// -----------------------------------------------------------------------------
3104
3097
void CMaterialSystem::CacheUsedMaterials ( )
3105
3098
{
3099
+ printf (" Cache materials\n " );
3100
+
3106
3101
g_pShaderAPI->EvictManagedResources ();
3107
- size_t count = 0 ;
3102
+
3108
3103
for (MaterialHandle_t i = FirstMaterial (); i != InvalidMaterial (); i = NextMaterial (i) )
3109
3104
{
3110
- // Some (mac) drivers (amd) seem to keep extra resources around on uploads until the next frame swap. This
3111
- // injects pointless synthetic swaps (between already-static load frames)
3112
- if ( mat_texture_reload_frame_swap_workaround.GetBool () )
3113
- {
3114
- if ( count++ % 20 == 0 )
3115
- {
3116
- Flush (true );
3117
- SwapBuffers (); // Not the right thing to call
3118
- }
3119
- }
3120
3105
IMaterialInternal* pMat = GetMaterialInternal (i);
3121
3106
Assert ( pMat->GetReferenceCount () >= 0 );
3122
3107
if ( pMat->GetReferenceCount () > 0 )
@@ -3703,9 +3688,13 @@ void CMaterialSystem::EndFrame( void )
3703
3688
ThreadAcquire ( true );
3704
3689
}
3705
3690
3691
+ IThreadPool* pThreadPool = CreateMatQueueThreadPool ();
3692
+
3706
3693
if ( m_pActiveAsyncJob && !m_pActiveAsyncJob->IsFinished () )
3707
3694
{
3708
- m_pActiveAsyncJob->WaitForFinish ();
3695
+ m_pActiveAsyncJob->WaitForFinish (TT_INFINITE, pThreadPool);
3696
+
3697
+ // Sync with GPU if we had a job for it, even if it finished early on CPU!
3709
3698
if ( !IsPC () && g_config.ForceHWSync () )
3710
3699
{
3711
3700
g_pShaderAPI->ForceHardwareSync ();
@@ -3730,7 +3719,6 @@ void CMaterialSystem::EndFrame( void )
3730
3719
}
3731
3720
}
3732
3721
3733
- IThreadPool *pThreadPool = CreateMatQueueThreadPool ();
3734
3722
pThreadPool->AddJob ( m_pActiveAsyncJob );
3735
3723
break ;
3736
3724
}
@@ -4664,20 +4652,9 @@ void CMaterialSystem::BeginRenderTargetAllocation( void )
4664
4652
4665
4653
void CMaterialSystem::EndRenderTargetAllocation ( void )
4666
4654
{
4667
- // Any GPU newer than 2005 doesn't need to do this, and it eats up ~40% of our level load time!
4668
- const bool cbRequiresRenderTargetAllocationFirst = mat_requires_rt_alloc_first.GetBool ();
4669
-
4670
4655
g_pShaderAPI->FlushBufferedPrimitives ();
4671
4656
m_bAllocatingRenderTargets = false ;
4672
4657
4673
- if ( IsPC () && cbRequiresRenderTargetAllocationFirst && g_pShaderAPI->CanDownloadTextures () )
4674
- {
4675
- // Simulate an Alt-Tab...will cause RTs to be allocated first
4676
-
4677
- g_pShaderDevice->ReleaseResources ();
4678
- g_pShaderDevice->ReacquireResources ();
4679
- }
4680
-
4681
4658
TextureManager ()->CacheExternalStandardRenderTargets ();
4682
4659
}
4683
4660
0 commit comments