Skip to content

Commit a9c0a2b

Browse files
committed
optimizations
1 parent 6b07a57 commit a9c0a2b

File tree

5 files changed

+270
-232
lines changed

5 files changed

+270
-232
lines changed

game/client/tf/vgui/tf_classmenu.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,10 @@ void CTFClassMenu::SetVisible( bool state )
12001200

12011201
if ( state )
12021202
{
1203-
m_pTFPlayerModelPanel->SetVisible(true);
1203+
if (m_pTFPlayerModelPanel)
1204+
{
1205+
m_pTFPlayerModelPanel->SetVisible(true);
1206+
}
12041207
engine->ServerCmd( "menuopen" ); // to the server
12051208
engine->ClientCmd( "_cl_classmenuopen 1" ); // for other panels
12061209
CBroadcastRecipientFilter filter;
@@ -1221,7 +1224,10 @@ void CTFClassMenu::SetVisible( bool state )
12211224
engine->ServerCmd( "menuclosed" );
12221225
engine->ClientCmd( "_cl_classmenuopen 0" );
12231226

1224-
m_pTFPlayerModelPanel->SetVisible(false);
1227+
if (m_pTFPlayerModelPanel)
1228+
{
1229+
m_pTFPlayerModelPanel->SetVisible(false);
1230+
}
12251231

12261232
if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() )
12271233
{

materialsystem/shaderapidx9/shaderdevicedx8.cpp

Lines changed: 55 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ bool CShaderDeviceMgrDx8::Connect( CreateInterfaceFn factory )
155155
( CommandLine()->ParmValue( "-dxlevel", 100 ) < 90 );
156156

157157
bool bD3D9ExAvailable = false;
158-
if ( HMODULE hMod = ::LoadLibraryA( "d3d9.dll" ) )
158+
if ( HMODULE hMod = ::LoadLibraryA ( "d3d9.dll" ) )
159159
{
160160
typedef HRESULT ( WINAPI *CreateD3D9ExFunc_t )( UINT, IUnknown** );
161161
if ( CreateD3D9ExFunc_t pfnCreateD3D9Ex = (CreateD3D9ExFunc_t) ::GetProcAddress( hMod, "Direct3DCreate9Ex" ) )
@@ -1775,50 +1775,57 @@ void CShaderDeviceDx8::SetPresentParameters( void* hWnd, int nAdapter, const Sha
17751775
m_PresentParameters.BackBufferCount = 0;
17761776
}
17771777

1778-
if ( info.m_nAASamples > 1 && ( m_PresentParameters.SwapEffect == D3DSWAPEFFECT_DISCARD ) )
1778+
if ( info.m_nAASamples > 1 )
17791779
{
1780-
D3DMULTISAMPLE_TYPE multiSampleType = ComputeMultisampleType( info.m_nAASamples );
1781-
DWORD nQualityLevel;
1782-
1783-
// FIXME: Should we add the quality level to the ShaderAdapterMode_t struct?
1784-
// 16x on nVidia refers to CSAA or "Coverage Sampled Antialiasing"
1785-
const HardwareCaps_t &adapterCaps = g_ShaderDeviceMgrDx8.GetHardwareCaps( nAdapter );
1786-
if ( ( info.m_nAASamples == 16 ) && ( adapterCaps.m_VendorID == VENDORID_NVIDIA ) )
1787-
{
1788-
multiSampleType = ComputeMultisampleType(4);
1789-
hr = D3D()->CheckDeviceMultiSampleType( nAdapter, DX8_DEVTYPE,
1790-
m_PresentParameters.BackBufferFormat, m_PresentParameters.Windowed,
1791-
multiSampleType, &nQualityLevel ); // 4x at highest quality level
1792-
1793-
if ( !FAILED( hr ) && ( nQualityLevel == 16 ) )
1794-
{
1795-
nQualityLevel = nQualityLevel - 1; // Highest quality level triggers 16x CSAA
1796-
}
1797-
else
1798-
{
1799-
nQualityLevel = 0; // No CSAA
1800-
}
1801-
}
1802-
else // Regular MSAA on any old vendor
1803-
{
1804-
hr = D3D()->CheckDeviceMultiSampleType( nAdapter, DX8_DEVTYPE,
1805-
m_PresentParameters.BackBufferFormat, m_PresentParameters.Windowed,
1806-
multiSampleType, &nQualityLevel );
1807-
1808-
nQualityLevel = 0;
1809-
}
1810-
1811-
if ( !FAILED( hr ) )
1780+
if (m_PresentParameters.SwapEffect == D3DSWAPEFFECT_DISCARD)
18121781
{
1813-
m_PresentParameters.MultiSampleType = multiSampleType;
1814-
m_PresentParameters.MultiSampleQuality = nQualityLevel;
1782+
D3DMULTISAMPLE_TYPE multiSampleType = ComputeMultisampleType( info.m_nAASamples );
1783+
DWORD nQualityLevel;
1784+
1785+
// FIXME: Should we add the quality level to the ShaderAdapterMode_t struct?
1786+
// 16x on nVidia refers to CSAA or "Coverage Sampled Antialiasing"
1787+
const HardwareCaps_t &adapterCaps = g_ShaderDeviceMgrDx8.GetHardwareCaps( nAdapter );
1788+
if ( ( info.m_nAASamples == 16 ) && ( adapterCaps.m_VendorID == VENDORID_NVIDIA ) )
1789+
{
1790+
multiSampleType = ComputeMultisampleType(4);
1791+
hr = D3D()->CheckDeviceMultiSampleType( nAdapter, DX8_DEVTYPE,
1792+
m_PresentParameters.BackBufferFormat, m_PresentParameters.Windowed,
1793+
multiSampleType, &nQualityLevel ); // 4x at highest quality level
1794+
1795+
if ( !FAILED( hr ) && ( nQualityLevel == 16 ) )
1796+
{
1797+
nQualityLevel = nQualityLevel - 1; // Highest quality level triggers 16x CSAA
1798+
}
1799+
else
1800+
{
1801+
nQualityLevel = 0; // No CSAA
1802+
}
1803+
}
1804+
else // Regular MSAA on any old vendor
1805+
{
1806+
hr = D3D()->CheckDeviceMultiSampleType( nAdapter, DX8_DEVTYPE,
1807+
m_PresentParameters.BackBufferFormat, m_PresentParameters.Windowed,
1808+
multiSampleType, &nQualityLevel );
1809+
1810+
nQualityLevel = 0;
1811+
}
1812+
1813+
if ( !FAILED( hr ) )
1814+
{
1815+
m_PresentParameters.MultiSampleType = multiSampleType;
1816+
m_PresentParameters.MultiSampleQuality = nQualityLevel;
1817+
return;
1818+
}
18151819
}
18161820
}
1817-
else
1821+
m_PresentParameters.MultiSampleType = D3DMULTISAMPLE_NONE;
1822+
m_PresentParameters.MultiSampleQuality = 0;
1823+
#if defined(IS_WINDOWS_PC) && defined(SHADERAPIDX9)
1824+
if (m_PresentParameters.Windowed && g_ShaderDeviceUsingD3D9Ex)
18181825
{
1819-
m_PresentParameters.MultiSampleType = D3DMULTISAMPLE_NONE;
1820-
m_PresentParameters.MultiSampleQuality = 0;
1826+
m_PresentParameters.SwapEffect = D3DSWAPEFFECT_FLIPEX;
18211827
}
1828+
#endif
18221829
}
18231830

18241831

@@ -2410,7 +2417,7 @@ bool CShaderDeviceDx8::CreateD3DDevice( void* pHWnd, int nAdapter, const ShaderD
24102417

24112418
g_pHardwareConfig->SetupHardwareCaps( info, g_ShaderDeviceMgrDx8.GetHardwareCaps( nAdapter ) );
24122419

2413-
#ifndef DX_TO_GL_ABSTRACTION
2420+
#if defined(IS_WINDOWS_PC) && defined(SHADERAPIDX9)
24142421
if (g_ShaderDeviceUsingD3D9Ex)
24152422
{
24162423
Dx9ExDevice()->SetMaximumFrameLatency(1);
@@ -3409,8 +3416,8 @@ void CShaderDeviceDx8::Present()
34093416
s_bSetPriority = true;
34103417
bValidPresent = false;
34113418
}
3412-
#ifndef DX_TO_GL_ABSTRACTION
3413-
if (s_bSetPriority && g_ShaderDeviceUsingD3D9Ex)
3419+
#if defined(IS_WINDOWS_PC) && defined(SHADERAPIDX9)
3420+
if (bValidPresent && s_bSetPriority && g_ShaderDeviceUsingD3D9Ex)
34143421
{
34153422
s_bSetPriority = false;
34163423
Dx9ExDevice()->SetGPUThreadPriority(7);
@@ -3453,10 +3460,14 @@ void CShaderDeviceDx8::Present()
34533460
else
34543461
{
34553462
g_pShaderAPI->OwnGPUResources( false );
3456-
#ifndef DX_TO_GL_ABSTRACTION
3457-
if (g_ShaderDeviceUsingD3D9Ex && m_PresentParameters.PresentationInterval != D3DPRESENT_INTERVAL_IMMEDIATE)
3463+
#if defined(IS_WINDOWS_PC) && defined(SHADERAPIDX9)
3464+
if (g_ShaderDeviceUsingD3D9Ex)
34583465
{
34593466
int flags = D3DPRESENT_DONOTWAIT;
3467+
if (m_PresentParameters.PresentationInterval == D3DPRESENT_INTERVAL_IMMEDIATE && m_PresentParameters.SwapEffect == D3DSWAPEFFECT_FLIPEX)
3468+
{
3469+
flags |= D3DPRESENT_FORCEIMMEDIATE;
3470+
}
34603471
hr = Dx9ExDevice()->PresentEx(0, 0, 0, 0, flags);
34613472
}
34623473
else

materialsystem/shaderapidx9/shaderdevicedx8.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ FORCEINLINE IDirect3DDevice9 *Dx9Device()
360360
{
361361
return g_pD3DDevice;
362362
}
363-
#ifndef DX_TO_GL_ABSTRACTION
363+
#if defined(IS_WINDOWS_PC) && defined(SHADERAPIDX9)
364364
FORCEINLINE IDirect3DDevice9Ex* Dx9ExDevice()
365365
{
366366
return (IDirect3DDevice9Ex*)g_pD3DDevice;

0 commit comments

Comments
 (0)