@@ -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
0 commit comments