@@ -2401,6 +2401,15 @@ bool CShaderDeviceDx8::CreateD3DDevice( void* pHWnd, int nAdapter, const ShaderD
24012401
24022402 g_pHardwareConfig->SetupHardwareCaps ( info, g_ShaderDeviceMgrDx8.GetHardwareCaps ( nAdapter ) );
24032403
2404+ #if defined(IS_WINDOWS_PC) && defined(SHADERAPIDX9)
2405+ if ( g_ShaderDeviceUsingD3D9Ex )
2406+ {
2407+ Dx9ExDevice ()->SetMaximumFrameLatency (2 );
2408+ static ConVarRef mat_forcehardwaresync (" mat_forcehardwaresync" );
2409+ mat_forcehardwaresync.SetValue (0 );
2410+ }
2411+ #endif
2412+
24042413 // FIXME: Bake this into hardware config
24052414 // What texture formats do we support?
24062415 if ( D3DSupportsCompressedTextures () )
@@ -3371,20 +3380,35 @@ void CShaderDeviceDx8::Present()
33713380 // if we're in queued mode, don't present if the device is already lost
33723381 bool bValidPresent = true ;
33733382 bool bInMainThread = ThreadInMainThread ();
3374- if ( !bInMainThread )
3383+ static bool s_bSetPriority = true ;
3384+ if ( bInMainThread )
3385+ {
3386+ s_bSetPriority = true ;
3387+ }
3388+ else
33753389 {
33763390 // don't present if the device is in an invalid state and in queued mode
33773391 if ( m_DeviceState != DEVICE_STATE_OK )
33783392 {
3393+ s_bSetPriority = true ;
33793394 bValidPresent = false ;
33803395 }
33813396 // check for lost device early in threaded mode
33823397 CheckDeviceLost ( m_bOtherAppInitializing );
33833398 if ( m_DeviceState != DEVICE_STATE_OK )
33843399 {
3400+ s_bSetPriority = true ;
33853401 bValidPresent = false ;
33863402 }
33873403 }
3404+ #if defined(IS_WINDOWS_PC) && defined(SHADERAPIDX9)
3405+ if ( bValidPresent && s_bSetPriority && g_ShaderDeviceUsingD3D9Ex )
3406+ {
3407+ s_bSetPriority = false ;
3408+ Dx9ExDevice ()->SetGPUThreadPriority (7 );
3409+ Dx9ExDevice ()->SetMaximumFrameLatency (2 );
3410+ }
3411+ #endif
33883412 // Copy the back buffer into the non-interactive temp buffer
33893413 if ( m_NonInteractiveRefresh.m_Mode == MATERIAL_NON_INTERACTIVE_MODE_LEVEL_LOAD )
33903414 {
0 commit comments